]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.8.7-201304142158.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.8.7-201304142158.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 85204da..9d99250 100644
263 --- a/Makefile
264 +++ b/Makefile
265 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
266
267 HOSTCC = gcc
268 HOSTCXX = g++
269 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
270 -HOSTCXXFLAGS = -O2
271 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
272 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
273 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
274
275 # Decide whether to build built-in, modular, or both.
276 # Normally, just do built-in.
277 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
278 # Rules shared between *config targets and build targets
279
280 # Basic helpers built in scripts/
281 -PHONY += scripts_basic
282 -scripts_basic:
283 +PHONY += scripts_basic gcc-plugins
284 +scripts_basic: gcc-plugins
285 $(Q)$(MAKE) $(build)=scripts/basic
286 $(Q)rm -f .tmp_quiet_recordmcount
287
288 @@ -575,6 +576,65 @@ else
289 KBUILD_CFLAGS += -O2
290 endif
291
292 +ifndef DISABLE_PAX_PLUGINS
293 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
294 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
295 +else
296 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
297 +endif
298 +ifneq ($(PLUGINCC),)
299 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
300 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
301 +endif
302 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
303 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
304 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
305 +endif
306 +ifdef CONFIG_KALLOCSTAT_PLUGIN
307 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
308 +endif
309 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
310 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
311 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
312 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
313 +endif
314 +ifdef CONFIG_CHECKER_PLUGIN
315 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
316 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
317 +endif
318 +endif
319 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
320 +ifdef CONFIG_PAX_SIZE_OVERFLOW
321 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
322 +endif
323 +ifdef CONFIG_PAX_LATENT_ENTROPY
324 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
325 +endif
326 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
327 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
328 +endif
329 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
330 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
331 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
332 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
333 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
334 +ifeq ($(KBUILD_EXTMOD),)
335 +gcc-plugins:
336 + $(Q)$(MAKE) $(build)=tools/gcc
337 +else
338 +gcc-plugins: ;
339 +endif
340 +else
341 +gcc-plugins:
342 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
343 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
344 +else
345 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
346 +endif
347 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
348 +endif
349 +endif
350 +
351 include $(srctree)/arch/$(SRCARCH)/Makefile
352
353 ifdef CONFIG_READABLE_ASM
354 @@ -731,7 +791,7 @@ export mod_sign_cmd
355
356
357 ifeq ($(KBUILD_EXTMOD),)
358 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
359 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
360
361 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
362 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
363 @@ -778,6 +838,8 @@ endif
364
365 # The actual objects are generated when descending,
366 # make sure no implicit rule kicks in
367 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
368 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
369 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
370
371 # Handle descending into subdirectories listed in $(vmlinux-dirs)
372 @@ -787,7 +849,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
373 # Error messages still appears in the original language
374
375 PHONY += $(vmlinux-dirs)
376 -$(vmlinux-dirs): prepare scripts
377 +$(vmlinux-dirs): gcc-plugins prepare scripts
378 $(Q)$(MAKE) $(build)=$@
379
380 # Store (new) KERNELRELASE string in include/config/kernel.release
381 @@ -831,6 +893,7 @@ prepare0: archprepare FORCE
382 $(Q)$(MAKE) $(build)=.
383
384 # All the preparing..
385 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
386 prepare: prepare0
387
388 # Generate some files
389 @@ -938,6 +1001,8 @@ all: modules
390 # using awk while concatenating to the final file.
391
392 PHONY += modules
393 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
394 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
395 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
396 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
397 @$(kecho) ' Building modules, stage 2.';
398 @@ -953,7 +1018,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
399
400 # Target to prepare building external modules
401 PHONY += modules_prepare
402 -modules_prepare: prepare scripts
403 +modules_prepare: gcc-plugins prepare scripts
404
405 # Target to install modules
406 PHONY += modules_install
407 @@ -1019,7 +1084,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
408 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
409 signing_key.priv signing_key.x509 x509.genkey \
410 extra_certificates signing_key.x509.keyid \
411 - signing_key.x509.signer
412 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
413
414 # clean - Delete most, but leave enough to build external modules
415 #
416 @@ -1059,6 +1124,7 @@ distclean: mrproper
417 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
418 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
419 -o -name '.*.rej' \
420 + -o -name '.*.rej' -o -name '*.so' \
421 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
422 -type f -print | xargs rm -f
423
424 @@ -1219,6 +1285,8 @@ PHONY += $(module-dirs) modules
425 $(module-dirs): crmodverdir $(objtree)/Module.symvers
426 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
427
428 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
429 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
430 modules: $(module-dirs)
431 @$(kecho) ' Building modules, stage 2.';
432 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
433 @@ -1355,17 +1423,21 @@ else
434 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
435 endif
436
437 -%.s: %.c prepare scripts FORCE
438 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
439 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
440 +%.s: %.c gcc-plugins prepare scripts FORCE
441 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
442 %.i: %.c prepare scripts FORCE
443 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
444 -%.o: %.c prepare scripts FORCE
445 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
446 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
447 +%.o: %.c gcc-plugins prepare scripts FORCE
448 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
449 %.lst: %.c prepare scripts FORCE
450 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
451 -%.s: %.S prepare scripts FORCE
452 +%.s: %.S gcc-plugins prepare scripts FORCE
453 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
454 -%.o: %.S prepare scripts FORCE
455 +%.o: %.S gcc-plugins prepare scripts FORCE
456 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
457 %.symtypes: %.c prepare scripts FORCE
458 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
459 @@ -1375,11 +1447,15 @@ endif
460 $(cmd_crmodverdir)
461 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
462 $(build)=$(build-dir)
463 -%/: prepare scripts FORCE
464 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
465 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
466 +%/: gcc-plugins prepare scripts FORCE
467 $(cmd_crmodverdir)
468 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
469 $(build)=$(build-dir)
470 -%.ko: prepare scripts FORCE
471 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
472 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
473 +%.ko: gcc-plugins prepare scripts FORCE
474 $(cmd_crmodverdir)
475 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
476 $(build)=$(build-dir) $(@:.ko=.o)
477 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
478 index c2cbe4f..f7264b4 100644
479 --- a/arch/alpha/include/asm/atomic.h
480 +++ b/arch/alpha/include/asm/atomic.h
481 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
482 #define atomic_dec(v) atomic_sub(1,(v))
483 #define atomic64_dec(v) atomic64_sub(1,(v))
484
485 +#define atomic64_read_unchecked(v) atomic64_read(v)
486 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
487 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
488 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
489 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
490 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
491 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
492 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
493 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
494 +
495 #define smp_mb__before_atomic_dec() smp_mb()
496 #define smp_mb__after_atomic_dec() smp_mb()
497 #define smp_mb__before_atomic_inc() smp_mb()
498 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
499 index ad368a9..fbe0f25 100644
500 --- a/arch/alpha/include/asm/cache.h
501 +++ b/arch/alpha/include/asm/cache.h
502 @@ -4,19 +4,19 @@
503 #ifndef __ARCH_ALPHA_CACHE_H
504 #define __ARCH_ALPHA_CACHE_H
505
506 +#include <linux/const.h>
507
508 /* Bytes per L1 (data) cache line. */
509 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
510 -# define L1_CACHE_BYTES 64
511 # define L1_CACHE_SHIFT 6
512 #else
513 /* Both EV4 and EV5 are write-through, read-allocate,
514 direct-mapped, physical.
515 */
516 -# define L1_CACHE_BYTES 32
517 # define L1_CACHE_SHIFT 5
518 #endif
519
520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
521 #define SMP_CACHE_BYTES L1_CACHE_BYTES
522
523 #endif
524 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
525 index 968d999..d36b2df 100644
526 --- a/arch/alpha/include/asm/elf.h
527 +++ b/arch/alpha/include/asm/elf.h
528 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
529
530 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
531
532 +#ifdef CONFIG_PAX_ASLR
533 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
534 +
535 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
536 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
537 +#endif
538 +
539 /* $0 is set by ld.so to a pointer to a function which might be
540 registered using atexit. This provides a mean for the dynamic
541 linker to call DT_FINI functions for shared libraries that have
542 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
543 index bc2a0da..8ad11ee 100644
544 --- a/arch/alpha/include/asm/pgalloc.h
545 +++ b/arch/alpha/include/asm/pgalloc.h
546 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
547 pgd_set(pgd, pmd);
548 }
549
550 +static inline void
551 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
552 +{
553 + pgd_populate(mm, pgd, pmd);
554 +}
555 +
556 extern pgd_t *pgd_alloc(struct mm_struct *mm);
557
558 static inline void
559 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
560 index 81a4342..348b927 100644
561 --- a/arch/alpha/include/asm/pgtable.h
562 +++ b/arch/alpha/include/asm/pgtable.h
563 @@ -102,6 +102,17 @@ struct vm_area_struct;
564 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
565 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
566 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
567 +
568 +#ifdef CONFIG_PAX_PAGEEXEC
569 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
570 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
571 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
572 +#else
573 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
574 +# define PAGE_COPY_NOEXEC PAGE_COPY
575 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
576 +#endif
577 +
578 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
579
580 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
581 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
582 index 2fd00b7..cfd5069 100644
583 --- a/arch/alpha/kernel/module.c
584 +++ b/arch/alpha/kernel/module.c
585 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
586
587 /* The small sections were sorted to the end of the segment.
588 The following should definitely cover them. */
589 - gp = (u64)me->module_core + me->core_size - 0x8000;
590 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
591 got = sechdrs[me->arch.gotsecindex].sh_addr;
592
593 for (i = 0; i < n; i++) {
594 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
595 index 14db93e..47bed62 100644
596 --- a/arch/alpha/kernel/osf_sys.c
597 +++ b/arch/alpha/kernel/osf_sys.c
598 @@ -1295,16 +1295,16 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
599 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
600
601 static unsigned long
602 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
603 - unsigned long limit)
604 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
605 + unsigned long limit, unsigned long flags)
606 {
607 struct vm_area_struct *vma = find_vma(current->mm, addr);
608 -
609 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
610 while (1) {
611 /* At this point: (!vma || addr < vma->vm_end). */
612 if (limit - len < addr)
613 return -ENOMEM;
614 - if (!vma || addr + len <= vma->vm_start)
615 + if (check_heap_stack_gap(vma, addr, len, offset))
616 return addr;
617 addr = vma->vm_end;
618 vma = vma->vm_next;
619 @@ -1340,20 +1340,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
620 merely specific addresses, but regions of memory -- perhaps
621 this feature should be incorporated into all ports? */
622
623 +#ifdef CONFIG_PAX_RANDMMAP
624 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
625 +#endif
626 +
627 if (addr) {
628 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
629 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
630 if (addr != (unsigned long) -ENOMEM)
631 return addr;
632 }
633
634 /* Next, try allocating at TASK_UNMAPPED_BASE. */
635 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
636 - len, limit);
637 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
638 +
639 if (addr != (unsigned long) -ENOMEM)
640 return addr;
641
642 /* Finally, try allocating in low memory. */
643 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
644 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
645
646 return addr;
647 }
648 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
649 index 0c4132d..88f0d53 100644
650 --- a/arch/alpha/mm/fault.c
651 +++ b/arch/alpha/mm/fault.c
652 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
653 __reload_thread(pcb);
654 }
655
656 +#ifdef CONFIG_PAX_PAGEEXEC
657 +/*
658 + * PaX: decide what to do with offenders (regs->pc = fault address)
659 + *
660 + * returns 1 when task should be killed
661 + * 2 when patched PLT trampoline was detected
662 + * 3 when unpatched PLT trampoline was detected
663 + */
664 +static int pax_handle_fetch_fault(struct pt_regs *regs)
665 +{
666 +
667 +#ifdef CONFIG_PAX_EMUPLT
668 + int err;
669 +
670 + do { /* PaX: patched PLT emulation #1 */
671 + unsigned int ldah, ldq, jmp;
672 +
673 + err = get_user(ldah, (unsigned int *)regs->pc);
674 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
675 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
676 +
677 + if (err)
678 + break;
679 +
680 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
681 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
682 + jmp == 0x6BFB0000U)
683 + {
684 + unsigned long r27, addr;
685 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
686 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
687 +
688 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
689 + err = get_user(r27, (unsigned long *)addr);
690 + if (err)
691 + break;
692 +
693 + regs->r27 = r27;
694 + regs->pc = r27;
695 + return 2;
696 + }
697 + } while (0);
698 +
699 + do { /* PaX: patched PLT emulation #2 */
700 + unsigned int ldah, lda, br;
701 +
702 + err = get_user(ldah, (unsigned int *)regs->pc);
703 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
704 + err |= get_user(br, (unsigned int *)(regs->pc+8));
705 +
706 + if (err)
707 + break;
708 +
709 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
710 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
711 + (br & 0xFFE00000U) == 0xC3E00000U)
712 + {
713 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
714 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
715 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
716 +
717 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
718 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
719 + return 2;
720 + }
721 + } while (0);
722 +
723 + do { /* PaX: unpatched PLT emulation */
724 + unsigned int br;
725 +
726 + err = get_user(br, (unsigned int *)regs->pc);
727 +
728 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
729 + unsigned int br2, ldq, nop, jmp;
730 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
731 +
732 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
733 + err = get_user(br2, (unsigned int *)addr);
734 + err |= get_user(ldq, (unsigned int *)(addr+4));
735 + err |= get_user(nop, (unsigned int *)(addr+8));
736 + err |= get_user(jmp, (unsigned int *)(addr+12));
737 + err |= get_user(resolver, (unsigned long *)(addr+16));
738 +
739 + if (err)
740 + break;
741 +
742 + if (br2 == 0xC3600000U &&
743 + ldq == 0xA77B000CU &&
744 + nop == 0x47FF041FU &&
745 + jmp == 0x6B7B0000U)
746 + {
747 + regs->r28 = regs->pc+4;
748 + regs->r27 = addr+16;
749 + regs->pc = resolver;
750 + return 3;
751 + }
752 + }
753 + } while (0);
754 +#endif
755 +
756 + return 1;
757 +}
758 +
759 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
760 +{
761 + unsigned long i;
762 +
763 + printk(KERN_ERR "PAX: bytes at PC: ");
764 + for (i = 0; i < 5; i++) {
765 + unsigned int c;
766 + if (get_user(c, (unsigned int *)pc+i))
767 + printk(KERN_CONT "???????? ");
768 + else
769 + printk(KERN_CONT "%08x ", c);
770 + }
771 + printk("\n");
772 +}
773 +#endif
774
775 /*
776 * This routine handles page faults. It determines the address,
777 @@ -133,8 +251,29 @@ retry:
778 good_area:
779 si_code = SEGV_ACCERR;
780 if (cause < 0) {
781 - if (!(vma->vm_flags & VM_EXEC))
782 + if (!(vma->vm_flags & VM_EXEC)) {
783 +
784 +#ifdef CONFIG_PAX_PAGEEXEC
785 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
786 + goto bad_area;
787 +
788 + up_read(&mm->mmap_sem);
789 + switch (pax_handle_fetch_fault(regs)) {
790 +
791 +#ifdef CONFIG_PAX_EMUPLT
792 + case 2:
793 + case 3:
794 + return;
795 +#endif
796 +
797 + }
798 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
799 + do_group_exit(SIGKILL);
800 +#else
801 goto bad_area;
802 +#endif
803 +
804 + }
805 } else if (!cause) {
806 /* Allow reads even for write-only mappings */
807 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
808 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
809 index 67874b8..9aa2d62 100644
810 --- a/arch/arm/Kconfig
811 +++ b/arch/arm/Kconfig
812 @@ -1427,6 +1427,16 @@ config ARM_ERRATA_775420
813 to deadlock. This workaround puts DSB before executing ISB if
814 an abort may occur on cache maintenance.
815
816 +config ARM_ERRATA_798181
817 + bool "ARM errata: TLBI/DSB failure on Cortex-A15"
818 + depends on CPU_V7 && SMP
819 + help
820 + On Cortex-A15 (r0p0..r3p2) the TLBI*IS/DSB operations are not
821 + adequately shooting down all use of the old entries. This
822 + option enables the Linux kernel workaround for this erratum
823 + which sends an IPI to the CPUs that are running the same ASID
824 + as the one being invalidated.
825 +
826 endmenu
827
828 source "arch/arm/common/Kconfig"
829 @@ -1813,7 +1823,7 @@ config ALIGNMENT_TRAP
830
831 config UACCESS_WITH_MEMCPY
832 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
833 - depends on MMU
834 + depends on MMU && !PAX_MEMORY_UDEREF
835 default y if CPU_FEROCEON
836 help
837 Implement faster copy_to_user and clear_user methods for CPU
838 diff --git a/arch/arm/common/gic.c b/arch/arm/common/gic.c
839 index 87dfa902..3a523fc 100644
840 --- a/arch/arm/common/gic.c
841 +++ b/arch/arm/common/gic.c
842 @@ -81,7 +81,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
843 * Supported arch specific GIC irq extension.
844 * Default make them NULL.
845 */
846 -struct irq_chip gic_arch_extn = {
847 +irq_chip_no_const gic_arch_extn __read_only = {
848 .irq_eoi = NULL,
849 .irq_mask = NULL,
850 .irq_unmask = NULL,
851 @@ -329,7 +329,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
852 chained_irq_exit(chip, desc);
853 }
854
855 -static struct irq_chip gic_chip = {
856 +static irq_chip_no_const gic_chip __read_only = {
857 .name = "GIC",
858 .irq_mask = gic_mask_irq,
859 .irq_unmask = gic_unmask_irq,
860 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
861 index c79f61f..9ac0642 100644
862 --- a/arch/arm/include/asm/atomic.h
863 +++ b/arch/arm/include/asm/atomic.h
864 @@ -17,17 +17,35 @@
865 #include <asm/barrier.h>
866 #include <asm/cmpxchg.h>
867
868 +#ifdef CONFIG_GENERIC_ATOMIC64
869 +#include <asm-generic/atomic64.h>
870 +#endif
871 +
872 #define ATOMIC_INIT(i) { (i) }
873
874 #ifdef __KERNEL__
875
876 +#define _ASM_EXTABLE(from, to) \
877 +" .pushsection __ex_table,\"a\"\n"\
878 +" .align 3\n" \
879 +" .long " #from ", " #to"\n" \
880 +" .popsection"
881 +
882 /*
883 * On ARM, ordinary assignment (str instruction) doesn't clear the local
884 * strex/ldrex monitor on some implementations. The reason we can use it for
885 * atomic_set() is the clrex or dummy strex done on every exception return.
886 */
887 #define atomic_read(v) (*(volatile int *)&(v)->counter)
888 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
889 +{
890 + return v->counter;
891 +}
892 #define atomic_set(v,i) (((v)->counter) = (i))
893 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
894 +{
895 + v->counter = i;
896 +}
897
898 #if __LINUX_ARM_ARCH__ >= 6
899
900 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
901 int result;
902
903 __asm__ __volatile__("@ atomic_add\n"
904 +"1: ldrex %1, [%3]\n"
905 +" adds %0, %1, %4\n"
906 +
907 +#ifdef CONFIG_PAX_REFCOUNT
908 +" bvc 3f\n"
909 +"2: bkpt 0xf103\n"
910 +"3:\n"
911 +#endif
912 +
913 +" strex %1, %0, [%3]\n"
914 +" teq %1, #0\n"
915 +" bne 1b"
916 +
917 +#ifdef CONFIG_PAX_REFCOUNT
918 +"\n4:\n"
919 + _ASM_EXTABLE(2b, 4b)
920 +#endif
921 +
922 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
923 + : "r" (&v->counter), "Ir" (i)
924 + : "cc");
925 +}
926 +
927 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
928 +{
929 + unsigned long tmp;
930 + int result;
931 +
932 + __asm__ __volatile__("@ atomic_add_unchecked\n"
933 "1: ldrex %0, [%3]\n"
934 " add %0, %0, %4\n"
935 " strex %1, %0, [%3]\n"
936 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
937 smp_mb();
938
939 __asm__ __volatile__("@ atomic_add_return\n"
940 +"1: ldrex %1, [%3]\n"
941 +" adds %0, %1, %4\n"
942 +
943 +#ifdef CONFIG_PAX_REFCOUNT
944 +" bvc 3f\n"
945 +" mov %0, %1\n"
946 +"2: bkpt 0xf103\n"
947 +"3:\n"
948 +#endif
949 +
950 +" strex %1, %0, [%3]\n"
951 +" teq %1, #0\n"
952 +" bne 1b"
953 +
954 +#ifdef CONFIG_PAX_REFCOUNT
955 +"\n4:\n"
956 + _ASM_EXTABLE(2b, 4b)
957 +#endif
958 +
959 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
960 + : "r" (&v->counter), "Ir" (i)
961 + : "cc");
962 +
963 + smp_mb();
964 +
965 + return result;
966 +}
967 +
968 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
969 +{
970 + unsigned long tmp;
971 + int result;
972 +
973 + smp_mb();
974 +
975 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
976 "1: ldrex %0, [%3]\n"
977 " add %0, %0, %4\n"
978 " strex %1, %0, [%3]\n"
979 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
980 int result;
981
982 __asm__ __volatile__("@ atomic_sub\n"
983 +"1: ldrex %1, [%3]\n"
984 +" subs %0, %1, %4\n"
985 +
986 +#ifdef CONFIG_PAX_REFCOUNT
987 +" bvc 3f\n"
988 +"2: bkpt 0xf103\n"
989 +"3:\n"
990 +#endif
991 +
992 +" strex %1, %0, [%3]\n"
993 +" teq %1, #0\n"
994 +" bne 1b"
995 +
996 +#ifdef CONFIG_PAX_REFCOUNT
997 +"\n4:\n"
998 + _ASM_EXTABLE(2b, 4b)
999 +#endif
1000 +
1001 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1002 + : "r" (&v->counter), "Ir" (i)
1003 + : "cc");
1004 +}
1005 +
1006 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1007 +{
1008 + unsigned long tmp;
1009 + int result;
1010 +
1011 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1012 "1: ldrex %0, [%3]\n"
1013 " sub %0, %0, %4\n"
1014 " strex %1, %0, [%3]\n"
1015 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1016 smp_mb();
1017
1018 __asm__ __volatile__("@ atomic_sub_return\n"
1019 -"1: ldrex %0, [%3]\n"
1020 -" sub %0, %0, %4\n"
1021 +"1: ldrex %1, [%3]\n"
1022 +" subs %0, %1, %4\n"
1023 +
1024 +#ifdef CONFIG_PAX_REFCOUNT
1025 +" bvc 3f\n"
1026 +" mov %0, %1\n"
1027 +"2: bkpt 0xf103\n"
1028 +"3:\n"
1029 +#endif
1030 +
1031 " strex %1, %0, [%3]\n"
1032 " teq %1, #0\n"
1033 " bne 1b"
1034 +
1035 +#ifdef CONFIG_PAX_REFCOUNT
1036 +"\n4:\n"
1037 + _ASM_EXTABLE(2b, 4b)
1038 +#endif
1039 +
1040 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1041 : "r" (&v->counter), "Ir" (i)
1042 : "cc");
1043 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1044 return oldval;
1045 }
1046
1047 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1048 +{
1049 + unsigned long oldval, res;
1050 +
1051 + smp_mb();
1052 +
1053 + do {
1054 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1055 + "ldrex %1, [%3]\n"
1056 + "mov %0, #0\n"
1057 + "teq %1, %4\n"
1058 + "strexeq %0, %5, [%3]\n"
1059 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1060 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1061 + : "cc");
1062 + } while (res);
1063 +
1064 + smp_mb();
1065 +
1066 + return oldval;
1067 +}
1068 +
1069 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1070 {
1071 unsigned long tmp, tmp2;
1072 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1073
1074 return val;
1075 }
1076 +
1077 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1078 +{
1079 + return atomic_add_return(i, v);
1080 +}
1081 +
1082 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1083 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1084 +{
1085 + (void) atomic_add_return(i, v);
1086 +}
1087
1088 static inline int atomic_sub_return(int i, atomic_t *v)
1089 {
1090 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1091 return val;
1092 }
1093 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1094 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1095 +{
1096 + (void) atomic_sub_return(i, v);
1097 +}
1098
1099 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1100 {
1101 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1102 return ret;
1103 }
1104
1105 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1106 +{
1107 + return atomic_cmpxchg(v, old, new);
1108 +}
1109 +
1110 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1111 {
1112 unsigned long flags;
1113 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1114 #endif /* __LINUX_ARM_ARCH__ */
1115
1116 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1117 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1118 +{
1119 + return xchg(&v->counter, new);
1120 +}
1121
1122 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1123 {
1124 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1125 }
1126
1127 #define atomic_inc(v) atomic_add(1, v)
1128 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1129 +{
1130 + atomic_add_unchecked(1, v);
1131 +}
1132 #define atomic_dec(v) atomic_sub(1, v)
1133 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1134 +{
1135 + atomic_sub_unchecked(1, v);
1136 +}
1137
1138 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1139 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1140 +{
1141 + return atomic_add_return_unchecked(1, v) == 0;
1142 +}
1143 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1144 #define atomic_inc_return(v) (atomic_add_return(1, v))
1145 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1146 +{
1147 + return atomic_add_return_unchecked(1, v);
1148 +}
1149 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1150 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1151
1152 @@ -241,6 +428,14 @@ typedef struct {
1153 u64 __aligned(8) counter;
1154 } atomic64_t;
1155
1156 +#ifdef CONFIG_PAX_REFCOUNT
1157 +typedef struct {
1158 + u64 __aligned(8) counter;
1159 +} atomic64_unchecked_t;
1160 +#else
1161 +typedef atomic64_t atomic64_unchecked_t;
1162 +#endif
1163 +
1164 #define ATOMIC64_INIT(i) { (i) }
1165
1166 static inline u64 atomic64_read(const atomic64_t *v)
1167 @@ -256,6 +451,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1168 return result;
1169 }
1170
1171 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1172 +{
1173 + u64 result;
1174 +
1175 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1176 +" ldrexd %0, %H0, [%1]"
1177 + : "=&r" (result)
1178 + : "r" (&v->counter), "Qo" (v->counter)
1179 + );
1180 +
1181 + return result;
1182 +}
1183 +
1184 static inline void atomic64_set(atomic64_t *v, u64 i)
1185 {
1186 u64 tmp;
1187 @@ -270,6 +478,20 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1188 : "cc");
1189 }
1190
1191 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1192 +{
1193 + u64 tmp;
1194 +
1195 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1196 +"1: ldrexd %0, %H0, [%2]\n"
1197 +" strexd %0, %3, %H3, [%2]\n"
1198 +" teq %0, #0\n"
1199 +" bne 1b"
1200 + : "=&r" (tmp), "=Qo" (v->counter)
1201 + : "r" (&v->counter), "r" (i)
1202 + : "cc");
1203 +}
1204 +
1205 static inline void atomic64_add(u64 i, atomic64_t *v)
1206 {
1207 u64 result;
1208 @@ -278,6 +500,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1209 __asm__ __volatile__("@ atomic64_add\n"
1210 "1: ldrexd %0, %H0, [%3]\n"
1211 " adds %0, %0, %4\n"
1212 +" adcs %H0, %H0, %H4\n"
1213 +
1214 +#ifdef CONFIG_PAX_REFCOUNT
1215 +" bvc 3f\n"
1216 +"2: bkpt 0xf103\n"
1217 +"3:\n"
1218 +#endif
1219 +
1220 +" strexd %1, %0, %H0, [%3]\n"
1221 +" teq %1, #0\n"
1222 +" bne 1b"
1223 +
1224 +#ifdef CONFIG_PAX_REFCOUNT
1225 +"\n4:\n"
1226 + _ASM_EXTABLE(2b, 4b)
1227 +#endif
1228 +
1229 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1235 +{
1236 + u64 result;
1237 + unsigned long tmp;
1238 +
1239 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1240 +"1: ldrexd %0, %H0, [%3]\n"
1241 +" adds %0, %0, %4\n"
1242 " adc %H0, %H0, %H4\n"
1243 " strexd %1, %0, %H0, [%3]\n"
1244 " teq %1, #0\n"
1245 @@ -289,12 +541,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1246
1247 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1248 {
1249 - u64 result;
1250 - unsigned long tmp;
1251 + u64 result, tmp;
1252
1253 smp_mb();
1254
1255 __asm__ __volatile__("@ atomic64_add_return\n"
1256 +"1: ldrexd %1, %H1, [%3]\n"
1257 +" adds %0, %1, %4\n"
1258 +" adcs %H0, %H1, %H4\n"
1259 +
1260 +#ifdef CONFIG_PAX_REFCOUNT
1261 +" bvc 3f\n"
1262 +" mov %0, %1\n"
1263 +" mov %H0, %H1\n"
1264 +"2: bkpt 0xf103\n"
1265 +"3:\n"
1266 +#endif
1267 +
1268 +" strexd %1, %0, %H0, [%3]\n"
1269 +" teq %1, #0\n"
1270 +" bne 1b"
1271 +
1272 +#ifdef CONFIG_PAX_REFCOUNT
1273 +"\n4:\n"
1274 + _ASM_EXTABLE(2b, 4b)
1275 +#endif
1276 +
1277 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1278 + : "r" (&v->counter), "r" (i)
1279 + : "cc");
1280 +
1281 + smp_mb();
1282 +
1283 + return result;
1284 +}
1285 +
1286 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1287 +{
1288 + u64 result;
1289 + unsigned long tmp;
1290 +
1291 + smp_mb();
1292 +
1293 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1294 "1: ldrexd %0, %H0, [%3]\n"
1295 " adds %0, %0, %4\n"
1296 " adc %H0, %H0, %H4\n"
1297 @@ -318,6 +607,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1298 __asm__ __volatile__("@ atomic64_sub\n"
1299 "1: ldrexd %0, %H0, [%3]\n"
1300 " subs %0, %0, %4\n"
1301 +" sbcs %H0, %H0, %H4\n"
1302 +
1303 +#ifdef CONFIG_PAX_REFCOUNT
1304 +" bvc 3f\n"
1305 +"2: bkpt 0xf103\n"
1306 +"3:\n"
1307 +#endif
1308 +
1309 +" strexd %1, %0, %H0, [%3]\n"
1310 +" teq %1, #0\n"
1311 +" bne 1b"
1312 +
1313 +#ifdef CONFIG_PAX_REFCOUNT
1314 +"\n4:\n"
1315 + _ASM_EXTABLE(2b, 4b)
1316 +#endif
1317 +
1318 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1319 + : "r" (&v->counter), "r" (i)
1320 + : "cc");
1321 +}
1322 +
1323 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1324 +{
1325 + u64 result;
1326 + unsigned long tmp;
1327 +
1328 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1329 +"1: ldrexd %0, %H0, [%3]\n"
1330 +" subs %0, %0, %4\n"
1331 " sbc %H0, %H0, %H4\n"
1332 " strexd %1, %0, %H0, [%3]\n"
1333 " teq %1, #0\n"
1334 @@ -329,18 +648,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1335
1336 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1337 {
1338 - u64 result;
1339 - unsigned long tmp;
1340 + u64 result, tmp;
1341
1342 smp_mb();
1343
1344 __asm__ __volatile__("@ atomic64_sub_return\n"
1345 -"1: ldrexd %0, %H0, [%3]\n"
1346 -" subs %0, %0, %4\n"
1347 -" sbc %H0, %H0, %H4\n"
1348 +"1: ldrexd %1, %H1, [%3]\n"
1349 +" subs %0, %1, %4\n"
1350 +" sbcs %H0, %H1, %H4\n"
1351 +
1352 +#ifdef CONFIG_PAX_REFCOUNT
1353 +" bvc 3f\n"
1354 +" mov %0, %1\n"
1355 +" mov %H0, %H1\n"
1356 +"2: bkpt 0xf103\n"
1357 +"3:\n"
1358 +#endif
1359 +
1360 " strexd %1, %0, %H0, [%3]\n"
1361 " teq %1, #0\n"
1362 " bne 1b"
1363 +
1364 +#ifdef CONFIG_PAX_REFCOUNT
1365 +"\n4:\n"
1366 + _ASM_EXTABLE(2b, 4b)
1367 +#endif
1368 +
1369 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1370 : "r" (&v->counter), "r" (i)
1371 : "cc");
1372 @@ -374,6 +707,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1373 return oldval;
1374 }
1375
1376 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1377 +{
1378 + u64 oldval;
1379 + unsigned long res;
1380 +
1381 + smp_mb();
1382 +
1383 + do {
1384 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1385 + "ldrexd %1, %H1, [%3]\n"
1386 + "mov %0, #0\n"
1387 + "teq %1, %4\n"
1388 + "teqeq %H1, %H4\n"
1389 + "strexdeq %0, %5, %H5, [%3]"
1390 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1391 + : "r" (&ptr->counter), "r" (old), "r" (new)
1392 + : "cc");
1393 + } while (res);
1394 +
1395 + smp_mb();
1396 +
1397 + return oldval;
1398 +}
1399 +
1400 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1401 {
1402 u64 result;
1403 @@ -397,21 +754,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404
1405 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1406 {
1407 - u64 result;
1408 - unsigned long tmp;
1409 + u64 result, tmp;
1410
1411 smp_mb();
1412
1413 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1414 -"1: ldrexd %0, %H0, [%3]\n"
1415 -" subs %0, %0, #1\n"
1416 -" sbc %H0, %H0, #0\n"
1417 +"1: ldrexd %1, %H1, [%3]\n"
1418 +" subs %0, %1, #1\n"
1419 +" sbcs %H0, %H1, #0\n"
1420 +
1421 +#ifdef CONFIG_PAX_REFCOUNT
1422 +" bvc 3f\n"
1423 +" mov %0, %1\n"
1424 +" mov %H0, %H1\n"
1425 +"2: bkpt 0xf103\n"
1426 +"3:\n"
1427 +#endif
1428 +
1429 " teq %H0, #0\n"
1430 -" bmi 2f\n"
1431 +" bmi 4f\n"
1432 " strexd %1, %0, %H0, [%3]\n"
1433 " teq %1, #0\n"
1434 " bne 1b\n"
1435 -"2:"
1436 +"4:\n"
1437 +
1438 +#ifdef CONFIG_PAX_REFCOUNT
1439 + _ASM_EXTABLE(2b, 4b)
1440 +#endif
1441 +
1442 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1443 : "r" (&v->counter)
1444 : "cc");
1445 @@ -434,13 +804,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1446 " teq %0, %5\n"
1447 " teqeq %H0, %H5\n"
1448 " moveq %1, #0\n"
1449 -" beq 2f\n"
1450 +" beq 4f\n"
1451 " adds %0, %0, %6\n"
1452 -" adc %H0, %H0, %H6\n"
1453 +" adcs %H0, %H0, %H6\n"
1454 +
1455 +#ifdef CONFIG_PAX_REFCOUNT
1456 +" bvc 3f\n"
1457 +"2: bkpt 0xf103\n"
1458 +"3:\n"
1459 +#endif
1460 +
1461 " strexd %2, %0, %H0, [%4]\n"
1462 " teq %2, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter), "r" (u), "r" (a)
1473 : "cc");
1474 @@ -453,10 +835,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475
1476 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1477 #define atomic64_inc(v) atomic64_add(1LL, (v))
1478 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1479 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1480 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1481 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1482 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1483 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1484 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1485 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1486 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1487 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1488 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1489 index 75fe66b..ba3dee4 100644
1490 --- a/arch/arm/include/asm/cache.h
1491 +++ b/arch/arm/include/asm/cache.h
1492 @@ -4,8 +4,10 @@
1493 #ifndef __ASMARM_CACHE_H
1494 #define __ASMARM_CACHE_H
1495
1496 +#include <linux/const.h>
1497 +
1498 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1499 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1500 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1501
1502 /*
1503 * Memory returned by kmalloc() may be used for DMA, so we must make
1504 @@ -24,5 +26,6 @@
1505 #endif
1506
1507 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1508 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1509
1510 #endif
1511 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1512 index e1489c5..d418304 100644
1513 --- a/arch/arm/include/asm/cacheflush.h
1514 +++ b/arch/arm/include/asm/cacheflush.h
1515 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1516 void (*dma_unmap_area)(const void *, size_t, int);
1517
1518 void (*dma_flush_range)(const void *, const void *);
1519 -};
1520 +} __no_const;
1521
1522 /*
1523 * Select the calling method
1524 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1525 index 6dcc164..b14d917 100644
1526 --- a/arch/arm/include/asm/checksum.h
1527 +++ b/arch/arm/include/asm/checksum.h
1528 @@ -37,7 +37,19 @@ __wsum
1529 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1530
1531 __wsum
1532 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1533 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1534 +
1535 +static inline __wsum
1536 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1537 +{
1538 + __wsum ret;
1539 + pax_open_userland();
1540 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1541 + pax_close_userland();
1542 + return ret;
1543 +}
1544 +
1545 +
1546
1547 /*
1548 * Fold a partial checksum without adding pseudo headers
1549 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1550 index 7eb18c1..e38b6d2 100644
1551 --- a/arch/arm/include/asm/cmpxchg.h
1552 +++ b/arch/arm/include/asm/cmpxchg.h
1553 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1554
1555 #define xchg(ptr,x) \
1556 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1557 +#define xchg_unchecked(ptr,x) \
1558 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1559
1560 #include <asm-generic/cmpxchg-local.h>
1561
1562 diff --git a/arch/arm/include/asm/delay.h b/arch/arm/include/asm/delay.h
1563 index 720799f..2f67631 100644
1564 --- a/arch/arm/include/asm/delay.h
1565 +++ b/arch/arm/include/asm/delay.h
1566 @@ -25,9 +25,9 @@ extern struct arm_delay_ops {
1567 void (*const_udelay)(unsigned long);
1568 void (*udelay)(unsigned long);
1569 bool const_clock;
1570 -} arm_delay_ops;
1571 +} *arm_delay_ops;
1572
1573 -#define __delay(n) arm_delay_ops.delay(n)
1574 +#define __delay(n) arm_delay_ops->delay(n)
1575
1576 /*
1577 * This function intentionally does not exist; if you see references to
1578 @@ -48,8 +48,8 @@ extern void __bad_udelay(void);
1579 * first constant multiplications gets optimized away if the delay is
1580 * a constant)
1581 */
1582 -#define __udelay(n) arm_delay_ops.udelay(n)
1583 -#define __const_udelay(n) arm_delay_ops.const_udelay(n)
1584 +#define __udelay(n) arm_delay_ops->udelay(n)
1585 +#define __const_udelay(n) arm_delay_ops->const_udelay(n)
1586
1587 #define udelay(n) \
1588 (__builtin_constant_p(n) ? \
1589 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1590 index 6ddbe44..b5e38b1 100644
1591 --- a/arch/arm/include/asm/domain.h
1592 +++ b/arch/arm/include/asm/domain.h
1593 @@ -48,18 +48,37 @@
1594 * Domain types
1595 */
1596 #define DOMAIN_NOACCESS 0
1597 -#define DOMAIN_CLIENT 1
1598 #ifdef CONFIG_CPU_USE_DOMAINS
1599 +#define DOMAIN_USERCLIENT 1
1600 +#define DOMAIN_KERNELCLIENT 1
1601 #define DOMAIN_MANAGER 3
1602 +#define DOMAIN_VECTORS DOMAIN_USER
1603 #else
1604 +
1605 +#ifdef CONFIG_PAX_KERNEXEC
1606 #define DOMAIN_MANAGER 1
1607 +#define DOMAIN_KERNEXEC 3
1608 +#else
1609 +#define DOMAIN_MANAGER 1
1610 +#endif
1611 +
1612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1613 +#define DOMAIN_USERCLIENT 0
1614 +#define DOMAIN_UDEREF 1
1615 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1616 +#else
1617 +#define DOMAIN_USERCLIENT 1
1618 +#define DOMAIN_VECTORS DOMAIN_USER
1619 +#endif
1620 +#define DOMAIN_KERNELCLIENT 1
1621 +
1622 #endif
1623
1624 #define domain_val(dom,type) ((type) << (2*(dom)))
1625
1626 #ifndef __ASSEMBLY__
1627
1628 -#ifdef CONFIG_CPU_USE_DOMAINS
1629 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1630 static inline void set_domain(unsigned val)
1631 {
1632 asm volatile(
1633 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1634 isb();
1635 }
1636
1637 -#define modify_domain(dom,type) \
1638 - do { \
1639 - struct thread_info *thread = current_thread_info(); \
1640 - unsigned int domain = thread->cpu_domain; \
1641 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1642 - thread->cpu_domain = domain | domain_val(dom, type); \
1643 - set_domain(thread->cpu_domain); \
1644 - } while (0)
1645 -
1646 +extern void modify_domain(unsigned int dom, unsigned int type);
1647 #else
1648 static inline void set_domain(unsigned val) { }
1649 static inline void modify_domain(unsigned dom, unsigned type) { }
1650 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1651 index 38050b1..9d90e8b 100644
1652 --- a/arch/arm/include/asm/elf.h
1653 +++ b/arch/arm/include/asm/elf.h
1654 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1655 the loader. We need to make sure that it is out of the way of the program
1656 that it will "exec", and that there is sufficient room for the brk. */
1657
1658 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1659 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1660 +
1661 +#ifdef CONFIG_PAX_ASLR
1662 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1663 +
1664 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1665 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1666 +#endif
1667
1668 /* When the program starts, a1 contains a pointer to a function to be
1669 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1670 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1671 extern void elf_set_personality(const struct elf32_hdr *);
1672 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1673
1674 -struct mm_struct;
1675 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1676 -#define arch_randomize_brk arch_randomize_brk
1677 -
1678 #endif
1679 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1680 index de53547..52b9a28 100644
1681 --- a/arch/arm/include/asm/fncpy.h
1682 +++ b/arch/arm/include/asm/fncpy.h
1683 @@ -81,7 +81,9 @@
1684 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1685 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1686 \
1687 + pax_open_kernel(); \
1688 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1689 + pax_close_kernel(); \
1690 flush_icache_range((unsigned long)(dest_buf), \
1691 (unsigned long)(dest_buf) + (size)); \
1692 \
1693 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1694 index e42cf59..7b94b8f 100644
1695 --- a/arch/arm/include/asm/futex.h
1696 +++ b/arch/arm/include/asm/futex.h
1697 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1698 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1699 return -EFAULT;
1700
1701 + pax_open_userland();
1702 +
1703 smp_mb();
1704 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1705 "1: ldrex %1, [%4]\n"
1706 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1707 : "cc", "memory");
1708 smp_mb();
1709
1710 + pax_close_userland();
1711 +
1712 *uval = val;
1713 return ret;
1714 }
1715 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1716 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1717 return -EFAULT;
1718
1719 + pax_open_userland();
1720 +
1721 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1722 "1: " TUSER(ldr) " %1, [%4]\n"
1723 " teq %1, %2\n"
1724 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1725 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1726 : "cc", "memory");
1727
1728 + pax_close_userland();
1729 +
1730 *uval = val;
1731 return ret;
1732 }
1733 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1734 return -EFAULT;
1735
1736 pagefault_disable(); /* implies preempt_disable() */
1737 + pax_open_userland();
1738
1739 switch (op) {
1740 case FUTEX_OP_SET:
1741 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1742 ret = -ENOSYS;
1743 }
1744
1745 + pax_close_userland();
1746 pagefault_enable(); /* subsumes preempt_enable() */
1747
1748 if (!ret) {
1749 diff --git a/arch/arm/include/asm/hardware/gic.h b/arch/arm/include/asm/hardware/gic.h
1750 index 4b1ce6c..bea3f73 100644
1751 --- a/arch/arm/include/asm/hardware/gic.h
1752 +++ b/arch/arm/include/asm/hardware/gic.h
1753 @@ -34,9 +34,10 @@
1754
1755 #ifndef __ASSEMBLY__
1756 #include <linux/irqdomain.h>
1757 +#include <linux/irq.h>
1758 struct device_node;
1759
1760 -extern struct irq_chip gic_arch_extn;
1761 +extern irq_chip_no_const gic_arch_extn;
1762
1763 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
1764 u32 offset, struct device_node *);
1765 diff --git a/arch/arm/include/asm/highmem.h b/arch/arm/include/asm/highmem.h
1766 index 8c5e828..91b99ab 100644
1767 --- a/arch/arm/include/asm/highmem.h
1768 +++ b/arch/arm/include/asm/highmem.h
1769 @@ -41,6 +41,13 @@ extern void kunmap_high(struct page *page);
1770 #endif
1771 #endif
1772
1773 +/*
1774 + * Needed to be able to broadcast the TLB invalidation for kmap.
1775 + */
1776 +#ifdef CONFIG_ARM_ERRATA_798181
1777 +#undef ARCH_NEEDS_KMAP_HIGH_GET
1778 +#endif
1779 +
1780 #ifdef ARCH_NEEDS_KMAP_HIGH_GET
1781 extern void *kmap_high_get(struct page *page);
1782 #else
1783 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1784 index 83eb2f7..ed77159 100644
1785 --- a/arch/arm/include/asm/kmap_types.h
1786 +++ b/arch/arm/include/asm/kmap_types.h
1787 @@ -4,6 +4,6 @@
1788 /*
1789 * This is the "bare minimum". AIO seems to require this.
1790 */
1791 -#define KM_TYPE_NR 16
1792 +#define KM_TYPE_NR 17
1793
1794 #endif
1795 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1796 index 9e614a1..3302cca 100644
1797 --- a/arch/arm/include/asm/mach/dma.h
1798 +++ b/arch/arm/include/asm/mach/dma.h
1799 @@ -22,7 +22,7 @@ struct dma_ops {
1800 int (*residue)(unsigned int, dma_t *); /* optional */
1801 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1802 const char *type;
1803 -};
1804 +} __do_const;
1805
1806 struct dma_struct {
1807 void *addr; /* single DMA address */
1808 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1809 index 2fe141f..192dc01 100644
1810 --- a/arch/arm/include/asm/mach/map.h
1811 +++ b/arch/arm/include/asm/mach/map.h
1812 @@ -27,13 +27,16 @@ struct map_desc {
1813 #define MT_MINICLEAN 6
1814 #define MT_LOW_VECTORS 7
1815 #define MT_HIGH_VECTORS 8
1816 -#define MT_MEMORY 9
1817 +#define MT_MEMORY_RWX 9
1818 #define MT_ROM 10
1819 -#define MT_MEMORY_NONCACHED 11
1820 +#define MT_MEMORY_NONCACHED_RX 11
1821 #define MT_MEMORY_DTCM 12
1822 #define MT_MEMORY_ITCM 13
1823 #define MT_MEMORY_SO 14
1824 #define MT_MEMORY_DMA_READY 15
1825 +#define MT_MEMORY_RW 16
1826 +#define MT_MEMORY_RX 17
1827 +#define MT_MEMORY_NONCACHED_RW 18
1828
1829 #ifdef CONFIG_MMU
1830 extern void iotable_init(struct map_desc *, int);
1831 diff --git a/arch/arm/include/asm/mmu_context.h b/arch/arm/include/asm/mmu_context.h
1832 index 863a661..a7b85e0 100644
1833 --- a/arch/arm/include/asm/mmu_context.h
1834 +++ b/arch/arm/include/asm/mmu_context.h
1835 @@ -27,6 +27,8 @@ void __check_vmalloc_seq(struct mm_struct *mm);
1836 void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk);
1837 #define init_new_context(tsk,mm) ({ atomic64_set(&mm->context.id, 0); 0; })
1838
1839 +DECLARE_PER_CPU(atomic64_t, active_asids);
1840 +
1841 #else /* !CONFIG_CPU_HAS_ASID */
1842
1843 #ifdef CONFIG_MMU
1844 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1845 index 53426c6..c7baff3 100644
1846 --- a/arch/arm/include/asm/outercache.h
1847 +++ b/arch/arm/include/asm/outercache.h
1848 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1849 #endif
1850 void (*set_debug)(unsigned long);
1851 void (*resume)(void);
1852 -};
1853 +} __no_const;
1854
1855 #ifdef CONFIG_OUTER_CACHE
1856
1857 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1858 index 812a494..71fc0b6 100644
1859 --- a/arch/arm/include/asm/page.h
1860 +++ b/arch/arm/include/asm/page.h
1861 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1862 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1863 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1864 unsigned long vaddr, struct vm_area_struct *vma);
1865 -};
1866 +} __no_const;
1867
1868 #ifdef MULTI_USER
1869 extern struct cpu_user_fns cpu_user;
1870 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1871 index 943504f..c37a730 100644
1872 --- a/arch/arm/include/asm/pgalloc.h
1873 +++ b/arch/arm/include/asm/pgalloc.h
1874 @@ -17,6 +17,7 @@
1875 #include <asm/processor.h>
1876 #include <asm/cacheflush.h>
1877 #include <asm/tlbflush.h>
1878 +#include <asm/system_info.h>
1879
1880 #define check_pgt_cache() do { } while (0)
1881
1882 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1883 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1884 }
1885
1886 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1887 +{
1888 + pud_populate(mm, pud, pmd);
1889 +}
1890 +
1891 #else /* !CONFIG_ARM_LPAE */
1892
1893 /*
1894 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1895 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1896 #define pmd_free(mm, pmd) do { } while (0)
1897 #define pud_populate(mm,pmd,pte) BUG()
1898 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1899
1900 #endif /* CONFIG_ARM_LPAE */
1901
1902 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1903 __free_page(pte);
1904 }
1905
1906 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1907 +{
1908 +#ifdef CONFIG_ARM_LPAE
1909 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1910 +#else
1911 + if (addr & SECTION_SIZE)
1912 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1913 + else
1914 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1915 +#endif
1916 + flush_pmd_entry(pmdp);
1917 +}
1918 +
1919 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1920 pmdval_t prot)
1921 {
1922 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1923 static inline void
1924 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1925 {
1926 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1927 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1928 }
1929 #define pmd_pgtable(pmd) pmd_page(pmd)
1930
1931 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1932 index 5cfba15..f415e1a 100644
1933 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1934 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1935 @@ -20,12 +20,15 @@
1936 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1937 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1938 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1939 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1940 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1941 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1942 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1943 +
1944 /*
1945 * - section
1946 */
1947 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1948 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1949 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1950 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1951 @@ -37,6 +40,7 @@
1952 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1953 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1954 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1955 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1956
1957 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1958 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1959 @@ -66,6 +70,7 @@
1960 * - extended small page/tiny page
1961 */
1962 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1963 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1964 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1965 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1966 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1967 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1968 index f97ee02..07f1be5 100644
1969 --- a/arch/arm/include/asm/pgtable-2level.h
1970 +++ b/arch/arm/include/asm/pgtable-2level.h
1971 @@ -125,6 +125,7 @@
1972 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1973 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1974 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1975 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1976
1977 /*
1978 * These are the memory types, defined to be compatible with
1979 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1980 index d795282..a43ea90 100644
1981 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1982 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1983 @@ -32,15 +32,18 @@
1984 #define PMD_TYPE_SECT (_AT(pmdval_t, 1) << 0)
1985 #define PMD_BIT4 (_AT(pmdval_t, 0))
1986 #define PMD_DOMAIN(x) (_AT(pmdval_t, 0))
1987 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 59) /* PXNTable */
1988
1989 /*
1990 * - section
1991 */
1992 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1993 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1994 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1995 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1996 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1997 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1998 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 53)
1999 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 54)
2000 #define PMD_SECT_AP_WRITE (_AT(pmdval_t, 0))
2001 #define PMD_SECT_AP_READ (_AT(pmdval_t, 0))
2002 @@ -66,6 +69,7 @@
2003 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2004 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
2005 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
2006 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2007 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
2008
2009 /*
2010 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
2011 index a3f3792..7b932a6 100644
2012 --- a/arch/arm/include/asm/pgtable-3level.h
2013 +++ b/arch/arm/include/asm/pgtable-3level.h
2014 @@ -74,6 +74,7 @@
2015 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
2016 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
2017 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
2018 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
2019 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
2020 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
2021 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
2022 @@ -82,6 +83,7 @@
2023 /*
2024 * To be used in assembly code with the upper page attributes.
2025 */
2026 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
2027 #define L_PTE_XN_HIGH (1 << (54 - 32))
2028 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
2029
2030 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
2031 index c094749..a6ff605 100644
2032 --- a/arch/arm/include/asm/pgtable.h
2033 +++ b/arch/arm/include/asm/pgtable.h
2034 @@ -30,6 +30,9 @@
2035 #include <asm/pgtable-2level.h>
2036 #endif
2037
2038 +#define ktla_ktva(addr) (addr)
2039 +#define ktva_ktla(addr) (addr)
2040 +
2041 /*
2042 * Just any arbitrary offset to the start of the vmalloc VM area: the
2043 * current 8MB value just means that there will be a 8MB "hole" after the
2044 @@ -45,6 +48,9 @@
2045 #define LIBRARY_TEXT_START 0x0c000000
2046
2047 #ifndef __ASSEMBLY__
2048 +extern pteval_t __supported_pte_mask;
2049 +extern pmdval_t __supported_pmd_mask;
2050 +
2051 extern void __pte_error(const char *file, int line, pte_t);
2052 extern void __pmd_error(const char *file, int line, pmd_t);
2053 extern void __pgd_error(const char *file, int line, pgd_t);
2054 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2055 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
2056 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
2057
2058 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
2059 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2060 +
2061 +#ifdef CONFIG_PAX_KERNEXEC
2062 +#include <asm/domain.h>
2063 +#include <linux/thread_info.h>
2064 +#include <linux/preempt.h>
2065 +#endif
2066 +
2067 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2068 +static inline int test_domain(int domain, int domaintype)
2069 +{
2070 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2071 +}
2072 +#endif
2073 +
2074 +#ifdef CONFIG_PAX_KERNEXEC
2075 +static inline unsigned long pax_open_kernel(void) {
2076 +#ifdef CONFIG_ARM_LPAE
2077 + /* TODO */
2078 +#else
2079 + preempt_disable();
2080 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2081 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2082 +#endif
2083 + return 0;
2084 +}
2085 +
2086 +static inline unsigned long pax_close_kernel(void) {
2087 +#ifdef CONFIG_ARM_LPAE
2088 + /* TODO */
2089 +#else
2090 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2091 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2092 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2093 + preempt_enable_no_resched();
2094 +#endif
2095 + return 0;
2096 +}
2097 +#else
2098 +static inline unsigned long pax_open_kernel(void) { return 0; }
2099 +static inline unsigned long pax_close_kernel(void) { return 0; }
2100 +#endif
2101 +
2102 /*
2103 * This is the lowest virtual address we can permit any user space
2104 * mapping to be mapped at. This is particularly important for
2105 @@ -63,8 +113,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2106 /*
2107 * The pgprot_* and protection_map entries will be fixed up in runtime
2108 * to include the cachable and bufferable bits based on memory policy,
2109 - * as well as any architecture dependent bits like global/ASID and SMP
2110 - * shared mapping bits.
2111 + * as well as any architecture dependent bits like global/ASID, PXN,
2112 + * and SMP shared mapping bits.
2113 */
2114 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2115
2116 @@ -241,7 +291,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2117 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2118 {
2119 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2120 - L_PTE_NONE | L_PTE_VALID;
2121 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2122 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2123 return pte;
2124 }
2125 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2126 index f3628fb..a0672dd 100644
2127 --- a/arch/arm/include/asm/proc-fns.h
2128 +++ b/arch/arm/include/asm/proc-fns.h
2129 @@ -75,7 +75,7 @@ extern struct processor {
2130 unsigned int suspend_size;
2131 void (*do_suspend)(void *);
2132 void (*do_resume)(void *);
2133 -} processor;
2134 +} __do_const processor;
2135
2136 #ifndef MULTI_CPU
2137 extern void cpu_proc_init(void);
2138 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2139 index 06e7d50..8a8e251 100644
2140 --- a/arch/arm/include/asm/processor.h
2141 +++ b/arch/arm/include/asm/processor.h
2142 @@ -65,9 +65,8 @@ struct thread_struct {
2143 regs->ARM_cpsr |= PSR_ENDSTATE; \
2144 regs->ARM_pc = pc & ~1; /* pc */ \
2145 regs->ARM_sp = sp; /* sp */ \
2146 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2147 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2148 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2149 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2150 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2151 nommu_start_thread(regs); \
2152 })
2153
2154 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2155 index d3a22be..3a69ad5 100644
2156 --- a/arch/arm/include/asm/smp.h
2157 +++ b/arch/arm/include/asm/smp.h
2158 @@ -107,7 +107,7 @@ struct smp_operations {
2159 int (*cpu_disable)(unsigned int cpu);
2160 #endif
2161 #endif
2162 -};
2163 +} __no_const;
2164
2165 /*
2166 * set platform specific SMP operations
2167 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2168 index cddda1f..ff357f7 100644
2169 --- a/arch/arm/include/asm/thread_info.h
2170 +++ b/arch/arm/include/asm/thread_info.h
2171 @@ -77,9 +77,9 @@ struct thread_info {
2172 .flags = 0, \
2173 .preempt_count = INIT_PREEMPT_COUNT, \
2174 .addr_limit = KERNEL_DS, \
2175 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2176 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2177 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2178 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2179 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2180 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2181 .restart_block = { \
2182 .fn = do_no_restart_syscall, \
2183 }, \
2184 @@ -152,6 +152,12 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2185 #define TIF_SYSCALL_AUDIT 9
2186 #define TIF_SYSCALL_TRACEPOINT 10
2187 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2188 +
2189 +/* within 8 bits of TIF_SYSCALL_TRACE
2190 + * to meet flexible second operand requirements
2191 + */
2192 +#define TIF_GRSEC_SETXID 12
2193 +
2194 #define TIF_USING_IWMMXT 17
2195 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2196 #define TIF_RESTORE_SIGMASK 20
2197 @@ -165,10 +171,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2198 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2199 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2200 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2201 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2202
2203 /* Checks for any syscall work in entry-common.S */
2204 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2205 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2206 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2207
2208 /*
2209 * Change these and you break ASM code in entry-common.S
2210 diff --git a/arch/arm/include/asm/tlbflush.h b/arch/arm/include/asm/tlbflush.h
2211 index 6e924d3..a9f3ddf 100644
2212 --- a/arch/arm/include/asm/tlbflush.h
2213 +++ b/arch/arm/include/asm/tlbflush.h
2214 @@ -430,6 +430,21 @@ static inline void local_flush_tlb_kernel_page(unsigned long kaddr)
2215 }
2216 }
2217
2218 +#ifdef CONFIG_ARM_ERRATA_798181
2219 +static inline void dummy_flush_tlb_a15_erratum(void)
2220 +{
2221 + /*
2222 + * Dummy TLBIMVAIS. Using the unmapped address 0 and ASID 0.
2223 + */
2224 + asm("mcr p15, 0, %0, c8, c3, 1" : : "r" (0));
2225 + dsb();
2226 +}
2227 +#else
2228 +static inline void dummy_flush_tlb_a15_erratum(void)
2229 +{
2230 +}
2231 +#endif
2232 +
2233 /*
2234 * flush_pmd_entry
2235 *
2236 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2237 index 7e1f760..752fcb7 100644
2238 --- a/arch/arm/include/asm/uaccess.h
2239 +++ b/arch/arm/include/asm/uaccess.h
2240 @@ -18,6 +18,7 @@
2241 #include <asm/domain.h>
2242 #include <asm/unified.h>
2243 #include <asm/compiler.h>
2244 +#include <asm/pgtable.h>
2245
2246 #define VERIFY_READ 0
2247 #define VERIFY_WRITE 1
2248 @@ -60,10 +61,34 @@ extern int __put_user_bad(void);
2249 #define USER_DS TASK_SIZE
2250 #define get_fs() (current_thread_info()->addr_limit)
2251
2252 +static inline void pax_open_userland(void)
2253 +{
2254 +
2255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2256 + if (get_fs() == USER_DS) {
2257 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2258 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2259 + }
2260 +#endif
2261 +
2262 +}
2263 +
2264 +static inline void pax_close_userland(void)
2265 +{
2266 +
2267 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2268 + if (get_fs() == USER_DS) {
2269 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2270 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2271 + }
2272 +#endif
2273 +
2274 +}
2275 +
2276 static inline void set_fs(mm_segment_t fs)
2277 {
2278 current_thread_info()->addr_limit = fs;
2279 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2280 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2281 }
2282
2283 #define segment_eq(a,b) ((a) == (b))
2284 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2285
2286 #define get_user(x,p) \
2287 ({ \
2288 + int __e; \
2289 might_fault(); \
2290 - __get_user_check(x,p); \
2291 + pax_open_userland(); \
2292 + __e = __get_user_check(x,p); \
2293 + pax_close_userland(); \
2294 + __e; \
2295 })
2296
2297 extern int __put_user_1(void *, unsigned int);
2298 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2299
2300 #define put_user(x,p) \
2301 ({ \
2302 + int __e; \
2303 might_fault(); \
2304 - __put_user_check(x,p); \
2305 + pax_open_userland(); \
2306 + __e = __put_user_check(x,p); \
2307 + pax_close_userland(); \
2308 + __e; \
2309 })
2310
2311 #else /* CONFIG_MMU */
2312 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2313 #define __get_user(x,ptr) \
2314 ({ \
2315 long __gu_err = 0; \
2316 + pax_open_userland(); \
2317 __get_user_err((x),(ptr),__gu_err); \
2318 + pax_close_userland(); \
2319 __gu_err; \
2320 })
2321
2322 #define __get_user_error(x,ptr,err) \
2323 ({ \
2324 + pax_open_userland(); \
2325 __get_user_err((x),(ptr),err); \
2326 + pax_close_userland(); \
2327 (void) 0; \
2328 })
2329
2330 @@ -312,13 +349,17 @@ do { \
2331 #define __put_user(x,ptr) \
2332 ({ \
2333 long __pu_err = 0; \
2334 + pax_open_userland(); \
2335 __put_user_err((x),(ptr),__pu_err); \
2336 + pax_close_userland(); \
2337 __pu_err; \
2338 })
2339
2340 #define __put_user_error(x,ptr,err) \
2341 ({ \
2342 + pax_open_userland(); \
2343 __put_user_err((x),(ptr),err); \
2344 + pax_close_userland(); \
2345 (void) 0; \
2346 })
2347
2348 @@ -418,11 +459,44 @@ do { \
2349
2350
2351 #ifdef CONFIG_MMU
2352 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2353 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2354 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2355 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2356 +
2357 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2358 +{
2359 + unsigned long ret;
2360 +
2361 + check_object_size(to, n, false);
2362 + pax_open_userland();
2363 + ret = ___copy_from_user(to, from, n);
2364 + pax_close_userland();
2365 + return ret;
2366 +}
2367 +
2368 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2369 +{
2370 + unsigned long ret;
2371 +
2372 + check_object_size(from, n, true);
2373 + pax_open_userland();
2374 + ret = ___copy_to_user(to, from, n);
2375 + pax_close_userland();
2376 + return ret;
2377 +}
2378 +
2379 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2380 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2381 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2382 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2383 +
2384 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2385 +{
2386 + unsigned long ret;
2387 + pax_open_userland();
2388 + ret = ___clear_user(addr, n);
2389 + pax_close_userland();
2390 + return ret;
2391 +}
2392 +
2393 #else
2394 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2395 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2396 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2397
2398 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2399 {
2400 + if ((long)n < 0)
2401 + return n;
2402 +
2403 if (access_ok(VERIFY_READ, from, n))
2404 n = __copy_from_user(to, from, n);
2405 else /* security hole - plug it */
2406 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2407
2408 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2409 {
2410 + if ((long)n < 0)
2411 + return n;
2412 +
2413 if (access_ok(VERIFY_WRITE, to, n))
2414 n = __copy_to_user(to, from, n);
2415 return n;
2416 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2417 index 96ee092..37f1844 100644
2418 --- a/arch/arm/include/uapi/asm/ptrace.h
2419 +++ b/arch/arm/include/uapi/asm/ptrace.h
2420 @@ -73,7 +73,7 @@
2421 * ARMv7 groups of PSR bits
2422 */
2423 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2424 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2425 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2426 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2427 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2428
2429 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2430 index 60d3b73..d27ee09 100644
2431 --- a/arch/arm/kernel/armksyms.c
2432 +++ b/arch/arm/kernel/armksyms.c
2433 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2434 #ifdef CONFIG_MMU
2435 EXPORT_SYMBOL(copy_page);
2436
2437 -EXPORT_SYMBOL(__copy_from_user);
2438 -EXPORT_SYMBOL(__copy_to_user);
2439 -EXPORT_SYMBOL(__clear_user);
2440 +EXPORT_SYMBOL(___copy_from_user);
2441 +EXPORT_SYMBOL(___copy_to_user);
2442 +EXPORT_SYMBOL(___clear_user);
2443
2444 EXPORT_SYMBOL(__get_user_1);
2445 EXPORT_SYMBOL(__get_user_2);
2446 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2447 index 0f82098..3dbd3ee 100644
2448 --- a/arch/arm/kernel/entry-armv.S
2449 +++ b/arch/arm/kernel/entry-armv.S
2450 @@ -47,6 +47,87 @@
2451 9997:
2452 .endm
2453
2454 + .macro pax_enter_kernel
2455 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2456 + @ make aligned space for saved DACR
2457 + sub sp, sp, #8
2458 + @ save regs
2459 + stmdb sp!, {r1, r2}
2460 + @ read DACR from cpu_domain into r1
2461 + mov r2, sp
2462 + @ assume 8K pages, since we have to split the immediate in two
2463 + bic r2, r2, #(0x1fc0)
2464 + bic r2, r2, #(0x3f)
2465 + ldr r1, [r2, #TI_CPU_DOMAIN]
2466 + @ store old DACR on stack
2467 + str r1, [sp, #8]
2468 +#ifdef CONFIG_PAX_KERNEXEC
2469 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2470 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2471 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2472 +#endif
2473 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2474 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2475 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2476 +#endif
2477 + @ write r1 to current_thread_info()->cpu_domain
2478 + str r1, [r2, #TI_CPU_DOMAIN]
2479 + @ write r1 to DACR
2480 + mcr p15, 0, r1, c3, c0, 0
2481 + @ instruction sync
2482 + instr_sync
2483 + @ restore regs
2484 + ldmia sp!, {r1, r2}
2485 +#endif
2486 + .endm
2487 +
2488 + .macro pax_open_userland
2489 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2490 + @ save regs
2491 + stmdb sp!, {r0, r1}
2492 + @ read DACR from cpu_domain into r1
2493 + mov r0, sp
2494 + @ assume 8K pages, since we have to split the immediate in two
2495 + bic r0, r0, #(0x1fc0)
2496 + bic r0, r0, #(0x3f)
2497 + ldr r1, [r0, #TI_CPU_DOMAIN]
2498 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2499 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2500 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2501 + @ write r1 to current_thread_info()->cpu_domain
2502 + str r1, [r0, #TI_CPU_DOMAIN]
2503 + @ write r1 to DACR
2504 + mcr p15, 0, r1, c3, c0, 0
2505 + @ instruction sync
2506 + instr_sync
2507 + @ restore regs
2508 + ldmia sp!, {r0, r1}
2509 +#endif
2510 + .endm
2511 +
2512 + .macro pax_close_userland
2513 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2514 + @ save regs
2515 + stmdb sp!, {r0, r1}
2516 + @ read DACR from cpu_domain into r1
2517 + mov r0, sp
2518 + @ assume 8K pages, since we have to split the immediate in two
2519 + bic r0, r0, #(0x1fc0)
2520 + bic r0, r0, #(0x3f)
2521 + ldr r1, [r0, #TI_CPU_DOMAIN]
2522 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2523 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2524 + @ write r1 to current_thread_info()->cpu_domain
2525 + str r1, [r0, #TI_CPU_DOMAIN]
2526 + @ write r1 to DACR
2527 + mcr p15, 0, r1, c3, c0, 0
2528 + @ instruction sync
2529 + instr_sync
2530 + @ restore regs
2531 + ldmia sp!, {r0, r1}
2532 +#endif
2533 + .endm
2534 +
2535 .macro pabt_helper
2536 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2537 #ifdef MULTI_PABORT
2538 @@ -89,11 +170,15 @@
2539 * Invalid mode handlers
2540 */
2541 .macro inv_entry, reason
2542 +
2543 + pax_enter_kernel
2544 +
2545 sub sp, sp, #S_FRAME_SIZE
2546 ARM( stmib sp, {r1 - lr} )
2547 THUMB( stmia sp, {r0 - r12} )
2548 THUMB( str sp, [sp, #S_SP] )
2549 THUMB( str lr, [sp, #S_LR] )
2550 +
2551 mov r1, #\reason
2552 .endm
2553
2554 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2555 .macro svc_entry, stack_hole=0
2556 UNWIND(.fnstart )
2557 UNWIND(.save {r0 - pc} )
2558 +
2559 + pax_enter_kernel
2560 +
2561 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2562 +
2563 #ifdef CONFIG_THUMB2_KERNEL
2564 SPFIX( str r0, [sp] ) @ temporarily saved
2565 SPFIX( mov r0, sp )
2566 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2567 ldmia r0, {r3 - r5}
2568 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2569 mov r6, #-1 @ "" "" "" ""
2570 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2571 + @ offset sp by 8 as done in pax_enter_kernel
2572 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2573 +#else
2574 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2575 +#endif
2576 SPFIX( addeq r2, r2, #4 )
2577 str r3, [sp, #-4]! @ save the "real" r0 copied
2578 @ from the exception stack
2579 @@ -359,6 +453,9 @@ ENDPROC(__pabt_svc)
2580 .macro usr_entry
2581 UNWIND(.fnstart )
2582 UNWIND(.cantunwind ) @ don't unwind the user space
2583 +
2584 + pax_enter_kernel_user
2585 +
2586 sub sp, sp, #S_FRAME_SIZE
2587 ARM( stmib sp, {r1 - r12} )
2588 THUMB( stmia sp, {r0 - r12} )
2589 @@ -456,7 +553,9 @@ __und_usr:
2590 tst r3, #PSR_T_BIT @ Thumb mode?
2591 bne __und_usr_thumb
2592 sub r4, r2, #4 @ ARM instr at LR - 4
2593 + pax_open_userland
2594 1: ldrt r0, [r4]
2595 + pax_close_userland
2596 #ifdef CONFIG_CPU_ENDIAN_BE8
2597 rev r0, r0 @ little endian instruction
2598 #endif
2599 @@ -491,10 +590,14 @@ __und_usr_thumb:
2600 */
2601 .arch armv6t2
2602 #endif
2603 + pax_open_userland
2604 2: ldrht r5, [r4]
2605 + pax_close_userland
2606 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2607 blo __und_usr_fault_16 @ 16bit undefined instruction
2608 + pax_open_userland
2609 3: ldrht r0, [r2]
2610 + pax_close_userland
2611 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2612 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2613 orr r0, r0, r5, lsl #16
2614 @@ -733,7 +836,7 @@ ENTRY(__switch_to)
2615 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2616 THUMB( str sp, [ip], #4 )
2617 THUMB( str lr, [ip], #4 )
2618 -#ifdef CONFIG_CPU_USE_DOMAINS
2619 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2620 ldr r6, [r2, #TI_CPU_DOMAIN]
2621 #endif
2622 set_tls r3, r4, r5
2623 @@ -742,7 +845,7 @@ ENTRY(__switch_to)
2624 ldr r8, =__stack_chk_guard
2625 ldr r7, [r7, #TSK_STACK_CANARY]
2626 #endif
2627 -#ifdef CONFIG_CPU_USE_DOMAINS
2628 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC)
2629 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2630 #endif
2631 mov r5, r0
2632 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2633 index a6c301e..908821b 100644
2634 --- a/arch/arm/kernel/entry-common.S
2635 +++ b/arch/arm/kernel/entry-common.S
2636 @@ -10,18 +10,46 @@
2637
2638 #include <asm/unistd.h>
2639 #include <asm/ftrace.h>
2640 +#include <asm/domain.h>
2641 #include <asm/unwind.h>
2642
2643 +#include "entry-header.S"
2644 +
2645 #ifdef CONFIG_NEED_RET_TO_USER
2646 #include <mach/entry-macro.S>
2647 #else
2648 .macro arch_ret_to_user, tmp1, tmp2
2649 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2650 + @ save regs
2651 + stmdb sp!, {r1, r2}
2652 + @ read DACR from cpu_domain into r1
2653 + mov r2, sp
2654 + @ assume 8K pages, since we have to split the immediate in two
2655 + bic r2, r2, #(0x1fc0)
2656 + bic r2, r2, #(0x3f)
2657 + ldr r1, [r2, #TI_CPU_DOMAIN]
2658 +#ifdef CONFIG_PAX_KERNEXEC
2659 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2660 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2661 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2662 +#endif
2663 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2664 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2665 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2666 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2667 +#endif
2668 + @ write r1 to current_thread_info()->cpu_domain
2669 + str r1, [r2, #TI_CPU_DOMAIN]
2670 + @ write r1 to DACR
2671 + mcr p15, 0, r1, c3, c0, 0
2672 + @ instruction sync
2673 + instr_sync
2674 + @ restore regs
2675 + ldmia sp!, {r1, r2}
2676 +#endif
2677 .endm
2678 #endif
2679
2680 -#include "entry-header.S"
2681 -
2682 -
2683 .align 5
2684 /*
2685 * This is the fast syscall return path. We do as little as
2686 @@ -339,6 +367,7 @@ ENDPROC(ftrace_stub)
2687
2688 .align 5
2689 ENTRY(vector_swi)
2690 +
2691 sub sp, sp, #S_FRAME_SIZE
2692 stmia sp, {r0 - r12} @ Calling r0 - r12
2693 ARM( add r8, sp, #S_PC )
2694 @@ -388,6 +417,12 @@ ENTRY(vector_swi)
2695 ldr scno, [lr, #-4] @ get SWI instruction
2696 #endif
2697
2698 + /*
2699 + * do this here to avoid a performance hit of wrapping the code above
2700 + * that directly dereferences userland to parse the SWI instruction
2701 + */
2702 + pax_enter_kernel_user
2703 +
2704 #ifdef CONFIG_ALIGNMENT_TRAP
2705 ldr ip, __cr_alignment
2706 ldr ip, [ip]
2707 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2708 index 9a8531e..812e287 100644
2709 --- a/arch/arm/kernel/entry-header.S
2710 +++ b/arch/arm/kernel/entry-header.S
2711 @@ -73,9 +73,66 @@
2712 msr cpsr_c, \rtemp @ switch back to the SVC mode
2713 .endm
2714
2715 + .macro pax_enter_kernel_user
2716 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2717 + @ save regs
2718 + stmdb sp!, {r0, r1}
2719 + @ read DACR from cpu_domain into r1
2720 + mov r0, sp
2721 + @ assume 8K pages, since we have to split the immediate in two
2722 + bic r0, r0, #(0x1fc0)
2723 + bic r0, r0, #(0x3f)
2724 + ldr r1, [r0, #TI_CPU_DOMAIN]
2725 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2726 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2727 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2728 +#endif
2729 +#ifdef CONFIG_PAX_KERNEXEC
2730 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2731 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2732 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2733 +#endif
2734 + @ write r1 to current_thread_info()->cpu_domain
2735 + str r1, [r0, #TI_CPU_DOMAIN]
2736 + @ write r1 to DACR
2737 + mcr p15, 0, r1, c3, c0, 0
2738 + @ instruction sync
2739 + instr_sync
2740 + @ restore regs
2741 + ldmia sp!, {r0, r1}
2742 +#endif
2743 + .endm
2744 +
2745 + .macro pax_exit_kernel
2746 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2747 + @ save regs
2748 + stmdb sp!, {r0, r1}
2749 + @ read old DACR from stack into r1
2750 + ldr r1, [sp, #(8 + S_SP)]
2751 + sub r1, r1, #8
2752 + ldr r1, [r1]
2753 +
2754 + @ write r1 to current_thread_info()->cpu_domain
2755 + mov r0, sp
2756 + @ assume 8K pages, since we have to split the immediate in two
2757 + bic r0, r0, #(0x1fc0)
2758 + bic r0, r0, #(0x3f)
2759 + str r1, [r0, #TI_CPU_DOMAIN]
2760 + @ write r1 to DACR
2761 + mcr p15, 0, r1, c3, c0, 0
2762 + @ instruction sync
2763 + instr_sync
2764 + @ restore regs
2765 + ldmia sp!, {r0, r1}
2766 +#endif
2767 + .endm
2768 +
2769 #ifndef CONFIG_THUMB2_KERNEL
2770 .macro svc_exit, rpsr
2771 msr spsr_cxsf, \rpsr
2772 +
2773 + pax_exit_kernel
2774 +
2775 #if defined(CONFIG_CPU_V6)
2776 ldr r0, [sp]
2777 strex r1, r2, [sp] @ clear the exclusive monitor
2778 @@ -121,6 +178,9 @@
2779 .endm
2780 #else /* CONFIG_THUMB2_KERNEL */
2781 .macro svc_exit, rpsr
2782 +
2783 + pax_exit_kernel
2784 +
2785 ldr lr, [sp, #S_SP] @ top of the stack
2786 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2787 clrex @ clear the exclusive monitor
2788 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2789 index 2adda11..7fbe958 100644
2790 --- a/arch/arm/kernel/fiq.c
2791 +++ b/arch/arm/kernel/fiq.c
2792 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2793 #if defined(CONFIG_CPU_USE_DOMAINS)
2794 memcpy((void *)0xffff001c, start, length);
2795 #else
2796 + pax_open_kernel();
2797 memcpy(vectors_page + 0x1c, start, length);
2798 + pax_close_kernel();
2799 #endif
2800 flush_icache_range(0xffff001c, 0xffff001c + length);
2801 if (!vectors_high())
2802 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2803 index e0eb9a1..caee108 100644
2804 --- a/arch/arm/kernel/head.S
2805 +++ b/arch/arm/kernel/head.S
2806 @@ -52,7 +52,9 @@
2807 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2808
2809 .macro pgtbl, rd, phys
2810 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2811 + mov \rd, #TEXT_OFFSET
2812 + sub \rd, #PG_DIR_SIZE
2813 + add \rd, \rd, \phys
2814 .endm
2815
2816 /*
2817 @@ -267,7 +269,7 @@ __create_page_tables:
2818 addne r6, r6, #1 << SECTION_SHIFT
2819 strne r6, [r3]
2820
2821 -#if defined(CONFIG_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2822 +#if defined(CONFIG_ARM_LPAE) && defined(CONFIG_CPU_ENDIAN_BE8)
2823 sub r4, r4, #4 @ Fixup page table pointer
2824 @ for 64-bit descriptors
2825 #endif
2826 @@ -434,7 +436,7 @@ __enable_mmu:
2827 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2828 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2829 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2830 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2831 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2832 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2833 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2834 #endif
2835 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2836 index 5ff2e77..556d030 100644
2837 --- a/arch/arm/kernel/hw_breakpoint.c
2838 +++ b/arch/arm/kernel/hw_breakpoint.c
2839 @@ -1011,7 +1011,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2840 return NOTIFY_OK;
2841 }
2842
2843 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2844 +static struct notifier_block dbg_reset_nb = {
2845 .notifier_call = dbg_reset_notify,
2846 };
2847
2848 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2849 index 1e9be5d..03edbc2 100644
2850 --- a/arch/arm/kernel/module.c
2851 +++ b/arch/arm/kernel/module.c
2852 @@ -37,12 +37,37 @@
2853 #endif
2854
2855 #ifdef CONFIG_MMU
2856 -void *module_alloc(unsigned long size)
2857 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2858 {
2859 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2860 + return NULL;
2861 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2862 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2863 + GFP_KERNEL, prot, -1,
2864 __builtin_return_address(0));
2865 }
2866 +
2867 +void *module_alloc(unsigned long size)
2868 +{
2869 +
2870 +#ifdef CONFIG_PAX_KERNEXEC
2871 + return __module_alloc(size, PAGE_KERNEL);
2872 +#else
2873 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2874 +#endif
2875 +
2876 +}
2877 +
2878 +#ifdef CONFIG_PAX_KERNEXEC
2879 +void module_free_exec(struct module *mod, void *module_region)
2880 +{
2881 + module_free(mod, module_region);
2882 +}
2883 +
2884 +void *module_alloc_exec(unsigned long size)
2885 +{
2886 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2887 +}
2888 +#endif
2889 #endif
2890
2891 int
2892 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2893 index 07314af..c46655c 100644
2894 --- a/arch/arm/kernel/patch.c
2895 +++ b/arch/arm/kernel/patch.c
2896 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2897 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2898 int size;
2899
2900 + pax_open_kernel();
2901 if (thumb2 && __opcode_is_thumb16(insn)) {
2902 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2903 size = sizeof(u16);
2904 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2905 *(u32 *)addr = insn;
2906 size = sizeof(u32);
2907 }
2908 + pax_close_kernel();
2909
2910 flush_icache_range((uintptr_t)(addr),
2911 (uintptr_t)(addr) + size);
2912 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2913 index 5f66206..dce492f 100644
2914 --- a/arch/arm/kernel/perf_event_cpu.c
2915 +++ b/arch/arm/kernel/perf_event_cpu.c
2916 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2917 return NOTIFY_OK;
2918 }
2919
2920 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2921 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2922 .notifier_call = cpu_pmu_notify,
2923 };
2924
2925 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2926 index c6dec5f..e0fddd1 100644
2927 --- a/arch/arm/kernel/process.c
2928 +++ b/arch/arm/kernel/process.c
2929 @@ -28,7 +28,6 @@
2930 #include <linux/tick.h>
2931 #include <linux/utsname.h>
2932 #include <linux/uaccess.h>
2933 -#include <linux/random.h>
2934 #include <linux/hw_breakpoint.h>
2935 #include <linux/cpuidle.h>
2936 #include <linux/leds.h>
2937 @@ -256,9 +255,10 @@ void machine_power_off(void)
2938 machine_shutdown();
2939 if (pm_power_off)
2940 pm_power_off();
2941 + BUG();
2942 }
2943
2944 -void machine_restart(char *cmd)
2945 +__noreturn void machine_restart(char *cmd)
2946 {
2947 machine_shutdown();
2948
2949 @@ -283,8 +283,8 @@ void __show_regs(struct pt_regs *regs)
2950 init_utsname()->release,
2951 (int)strcspn(init_utsname()->version, " "),
2952 init_utsname()->version);
2953 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2954 - print_symbol("LR is at %s\n", regs->ARM_lr);
2955 + printk("PC is at %pA\n", instruction_pointer(regs));
2956 + printk("LR is at %pA\n", regs->ARM_lr);
2957 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2958 "sp : %08lx ip : %08lx fp : %08lx\n",
2959 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2960 @@ -452,12 +452,6 @@ unsigned long get_wchan(struct task_struct *p)
2961 return 0;
2962 }
2963
2964 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2965 -{
2966 - unsigned long range_end = mm->brk + 0x02000000;
2967 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2968 -}
2969 -
2970 #ifdef CONFIG_MMU
2971 /*
2972 * The vectors page is always readable from user space for the
2973 @@ -470,9 +464,8 @@ static int __init gate_vma_init(void)
2974 {
2975 gate_vma.vm_start = 0xffff0000;
2976 gate_vma.vm_end = 0xffff0000 + PAGE_SIZE;
2977 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2978 - gate_vma.vm_flags = VM_READ | VM_EXEC |
2979 - VM_MAYREAD | VM_MAYEXEC;
2980 + gate_vma.vm_flags = VM_NONE;
2981 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2982 return 0;
2983 }
2984 arch_initcall(gate_vma_init);
2985 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2986 index 03deeff..741ce88 100644
2987 --- a/arch/arm/kernel/ptrace.c
2988 +++ b/arch/arm/kernel/ptrace.c
2989 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2990 return current_thread_info()->syscall;
2991 }
2992
2993 +#ifdef CONFIG_GRKERNSEC_SETXID
2994 +extern void gr_delayed_cred_worker(void);
2995 +#endif
2996 +
2997 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2998 {
2999 current_thread_info()->syscall = scno;
3000
3001 +#ifdef CONFIG_GRKERNSEC_SETXID
3002 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3003 + gr_delayed_cred_worker();
3004 +#endif
3005 +
3006 /* Do the secure computing check first; failures should be fast. */
3007 if (secure_computing(scno) == -1)
3008 return -1;
3009 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3010 index 3f6cbb2..39305c7 100644
3011 --- a/arch/arm/kernel/setup.c
3012 +++ b/arch/arm/kernel/setup.c
3013 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3014 unsigned int elf_hwcap __read_mostly;
3015 EXPORT_SYMBOL(elf_hwcap);
3016
3017 +pteval_t __supported_pte_mask __read_only;
3018 +pmdval_t __supported_pmd_mask __read_only;
3019
3020 #ifdef MULTI_CPU
3021 -struct processor processor __read_mostly;
3022 +struct processor processor;
3023 #endif
3024 #ifdef MULTI_TLB
3025 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3026 +struct cpu_tlb_fns cpu_tlb __read_only;
3027 #endif
3028 #ifdef MULTI_USER
3029 -struct cpu_user_fns cpu_user __read_mostly;
3030 +struct cpu_user_fns cpu_user __read_only;
3031 #endif
3032 #ifdef MULTI_CACHE
3033 -struct cpu_cache_fns cpu_cache __read_mostly;
3034 +struct cpu_cache_fns cpu_cache __read_only;
3035 #endif
3036 #ifdef CONFIG_OUTER_CACHE
3037 -struct outer_cache_fns outer_cache __read_mostly;
3038 +struct outer_cache_fns outer_cache __read_only;
3039 EXPORT_SYMBOL(outer_cache);
3040 #endif
3041
3042 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3043 asm("mrc p15, 0, %0, c0, c1, 4"
3044 : "=r" (mmfr0));
3045 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3046 - (mmfr0 & 0x000000f0) >= 0x00000030)
3047 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3048 cpu_arch = CPU_ARCH_ARMv7;
3049 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3050 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3051 + __supported_pte_mask |= L_PTE_PXN;
3052 + __supported_pmd_mask |= PMD_PXNTABLE;
3053 + }
3054 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3055 (mmfr0 & 0x000000f0) == 0x00000020)
3056 cpu_arch = CPU_ARCH_ARMv6;
3057 else
3058 @@ -462,7 +468,7 @@ static void __init setup_processor(void)
3059 __cpu_architecture = __get_cpu_architecture();
3060
3061 #ifdef MULTI_CPU
3062 - processor = *list->proc;
3063 + memcpy((void *)&processor, list->proc, sizeof processor);
3064 #endif
3065 #ifdef MULTI_TLB
3066 cpu_tlb = *list->tlb;
3067 @@ -524,7 +530,7 @@ int __init arm_add_memory(phys_addr_t start, phys_addr_t size)
3068 size -= start & ~PAGE_MASK;
3069 bank->start = PAGE_ALIGN(start);
3070
3071 -#ifndef CONFIG_LPAE
3072 +#ifndef CONFIG_ARM_LPAE
3073 if (bank->start + size < bank->start) {
3074 printk(KERN_CRIT "Truncating memory at 0x%08llx to fit in "
3075 "32-bit physical address space\n", (long long)start);
3076 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3077 index 56f72d2..6924200 100644
3078 --- a/arch/arm/kernel/signal.c
3079 +++ b/arch/arm/kernel/signal.c
3080 @@ -433,22 +433,14 @@ setup_return(struct pt_regs *regs, struct k_sigaction *ka,
3081 __put_user(sigreturn_codes[idx+1], rc+1))
3082 return 1;
3083
3084 - if (cpsr & MODE32_BIT) {
3085 - /*
3086 - * 32-bit code can use the new high-page
3087 - * signal return code support.
3088 - */
3089 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3090 - } else {
3091 - /*
3092 - * Ensure that the instruction cache sees
3093 - * the return code written onto the stack.
3094 - */
3095 - flush_icache_range((unsigned long)rc,
3096 - (unsigned long)(rc + 2));
3097 + /*
3098 + * Ensure that the instruction cache sees
3099 + * the return code written onto the stack.
3100 + */
3101 + flush_icache_range((unsigned long)rc,
3102 + (unsigned long)(rc + 2));
3103
3104 - retcode = ((unsigned long)rc) + thumb;
3105 - }
3106 + retcode = ((unsigned long)rc) + thumb;
3107 }
3108
3109 regs->ARM_r0 = usig;
3110 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3111 index 58af91c..343ce99 100644
3112 --- a/arch/arm/kernel/smp.c
3113 +++ b/arch/arm/kernel/smp.c
3114 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3115
3116 static DECLARE_COMPLETION(cpu_running);
3117
3118 -static struct smp_operations smp_ops;
3119 +static struct smp_operations smp_ops __read_only;
3120
3121 void __init smp_set_ops(struct smp_operations *ops)
3122 {
3123 diff --git a/arch/arm/kernel/smp_tlb.c b/arch/arm/kernel/smp_tlb.c
3124 index 02c5d2c..e5695ad 100644
3125 --- a/arch/arm/kernel/smp_tlb.c
3126 +++ b/arch/arm/kernel/smp_tlb.c
3127 @@ -12,6 +12,7 @@
3128
3129 #include <asm/smp_plat.h>
3130 #include <asm/tlbflush.h>
3131 +#include <asm/mmu_context.h>
3132
3133 /**********************************************************************/
3134
3135 @@ -64,12 +65,72 @@ static inline void ipi_flush_tlb_kernel_range(void *arg)
3136 local_flush_tlb_kernel_range(ta->ta_start, ta->ta_end);
3137 }
3138
3139 +#ifdef CONFIG_ARM_ERRATA_798181
3140 +static int erratum_a15_798181(void)
3141 +{
3142 + unsigned int midr = read_cpuid_id();
3143 +
3144 + /* Cortex-A15 r0p0..r3p2 affected */
3145 + if ((midr & 0xff0ffff0) != 0x410fc0f0 || midr > 0x413fc0f2)
3146 + return 0;
3147 + return 1;
3148 +}
3149 +#else
3150 +static int erratum_a15_798181(void)
3151 +{
3152 + return 0;
3153 +}
3154 +#endif
3155 +
3156 +static void ipi_flush_tlb_a15_erratum(void *arg)
3157 +{
3158 + dmb();
3159 +}
3160 +
3161 +static void broadcast_tlb_a15_erratum(void)
3162 +{
3163 + if (!erratum_a15_798181())
3164 + return;
3165 +
3166 + dummy_flush_tlb_a15_erratum();
3167 + smp_call_function_many(cpu_online_mask, ipi_flush_tlb_a15_erratum,
3168 + NULL, 1);
3169 +}
3170 +
3171 +static void broadcast_tlb_mm_a15_erratum(struct mm_struct *mm)
3172 +{
3173 + int cpu;
3174 + cpumask_t mask = { CPU_BITS_NONE };
3175 +
3176 + if (!erratum_a15_798181())
3177 + return;
3178 +
3179 + dummy_flush_tlb_a15_erratum();
3180 + for_each_online_cpu(cpu) {
3181 + if (cpu == smp_processor_id())
3182 + continue;
3183 + /*
3184 + * We only need to send an IPI if the other CPUs are running
3185 + * the same ASID as the one being invalidated. There is no
3186 + * need for locking around the active_asids check since the
3187 + * switch_mm() function has at least one dmb() (as required by
3188 + * this workaround) in case a context switch happens on
3189 + * another CPU after the condition below.
3190 + */
3191 + if (atomic64_read(&mm->context.id) ==
3192 + atomic64_read(&per_cpu(active_asids, cpu)))
3193 + cpumask_set_cpu(cpu, &mask);
3194 + }
3195 + smp_call_function_many(&mask, ipi_flush_tlb_a15_erratum, NULL, 1);
3196 +}
3197 +
3198 void flush_tlb_all(void)
3199 {
3200 if (tlb_ops_need_broadcast())
3201 on_each_cpu(ipi_flush_tlb_all, NULL, 1);
3202 else
3203 local_flush_tlb_all();
3204 + broadcast_tlb_a15_erratum();
3205 }
3206
3207 void flush_tlb_mm(struct mm_struct *mm)
3208 @@ -78,6 +139,7 @@ void flush_tlb_mm(struct mm_struct *mm)
3209 on_each_cpu_mask(mm_cpumask(mm), ipi_flush_tlb_mm, mm, 1);
3210 else
3211 local_flush_tlb_mm(mm);
3212 + broadcast_tlb_mm_a15_erratum(mm);
3213 }
3214
3215 void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3216 @@ -90,6 +152,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long uaddr)
3217 &ta, 1);
3218 } else
3219 local_flush_tlb_page(vma, uaddr);
3220 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3221 }
3222
3223 void flush_tlb_kernel_page(unsigned long kaddr)
3224 @@ -100,6 +163,7 @@ void flush_tlb_kernel_page(unsigned long kaddr)
3225 on_each_cpu(ipi_flush_tlb_kernel_page, &ta, 1);
3226 } else
3227 local_flush_tlb_kernel_page(kaddr);
3228 + broadcast_tlb_a15_erratum();
3229 }
3230
3231 void flush_tlb_range(struct vm_area_struct *vma,
3232 @@ -114,6 +178,7 @@ void flush_tlb_range(struct vm_area_struct *vma,
3233 &ta, 1);
3234 } else
3235 local_flush_tlb_range(vma, start, end);
3236 + broadcast_tlb_mm_a15_erratum(vma->vm_mm);
3237 }
3238
3239 void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3240 @@ -125,5 +190,6 @@ void flush_tlb_kernel_range(unsigned long start, unsigned long end)
3241 on_each_cpu(ipi_flush_tlb_kernel_range, &ta, 1);
3242 } else
3243 local_flush_tlb_kernel_range(start, end);
3244 + broadcast_tlb_a15_erratum();
3245 }
3246
3247 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3248 index b0179b8..829510e 100644
3249 --- a/arch/arm/kernel/traps.c
3250 +++ b/arch/arm/kernel/traps.c
3251 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3252 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3253 {
3254 #ifdef CONFIG_KALLSYMS
3255 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3256 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3257 #else
3258 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3259 #endif
3260 @@ -266,6 +266,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3261 static int die_owner = -1;
3262 static unsigned int die_nest_count;
3263
3264 +extern void gr_handle_kernel_exploit(void);
3265 +
3266 static unsigned long oops_begin(void)
3267 {
3268 int cpu;
3269 @@ -308,6 +310,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3270 panic("Fatal exception in interrupt");
3271 if (panic_on_oops)
3272 panic("Fatal exception");
3273 +
3274 + gr_handle_kernel_exploit();
3275 +
3276 if (signr)
3277 do_exit(signr);
3278 }
3279 @@ -601,7 +606,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3280 * The user helper at 0xffff0fe0 must be used instead.
3281 * (see entry-armv.S for details)
3282 */
3283 + pax_open_kernel();
3284 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3285 + pax_close_kernel();
3286 }
3287 return 0;
3288
3289 @@ -841,13 +848,10 @@ void __init early_trap_init(void *vectors_base)
3290 */
3291 kuser_get_tls_init(vectors);
3292
3293 - /*
3294 - * Copy signal return handlers into the vector page, and
3295 - * set sigreturn to be a pointer to these.
3296 - */
3297 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3298 - sigreturn_codes, sizeof(sigreturn_codes));
3299 -
3300 flush_icache_range(vectors, vectors + PAGE_SIZE);
3301 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3302 +
3303 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3304 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3305 +#endif
3306 +
3307 }
3308 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3309 index 11c1785..c67d54c 100644
3310 --- a/arch/arm/kernel/vmlinux.lds.S
3311 +++ b/arch/arm/kernel/vmlinux.lds.S
3312 @@ -8,7 +8,11 @@
3313 #include <asm/thread_info.h>
3314 #include <asm/memory.h>
3315 #include <asm/page.h>
3316 -
3317 +
3318 +#ifdef CONFIG_PAX_KERNEXEC
3319 +#include <asm/pgtable.h>
3320 +#endif
3321 +
3322 #define PROC_INFO \
3323 . = ALIGN(4); \
3324 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3325 @@ -90,6 +94,11 @@ SECTIONS
3326 _text = .;
3327 HEAD_TEXT
3328 }
3329 +
3330 +#ifdef CONFIG_PAX_KERNEXEC
3331 + . = ALIGN(1<<SECTION_SHIFT);
3332 +#endif
3333 +
3334 .text : { /* Real text segment */
3335 _stext = .; /* Text and read-only data */
3336 __exception_text_start = .;
3337 @@ -144,6 +153,10 @@ SECTIONS
3338
3339 _etext = .; /* End of text and rodata section */
3340
3341 +#ifdef CONFIG_PAX_KERNEXEC
3342 + . = ALIGN(1<<SECTION_SHIFT);
3343 +#endif
3344 +
3345 #ifndef CONFIG_XIP_KERNEL
3346 . = ALIGN(PAGE_SIZE);
3347 __init_begin = .;
3348 @@ -203,6 +216,11 @@ SECTIONS
3349 . = PAGE_OFFSET + TEXT_OFFSET;
3350 #else
3351 __init_end = .;
3352 +
3353 +#ifdef CONFIG_PAX_KERNEXEC
3354 + . = ALIGN(1<<SECTION_SHIFT);
3355 +#endif
3356 +
3357 . = ALIGN(THREAD_SIZE);
3358 __data_loc = .;
3359 #endif
3360 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3361 index 14a0d98..7771a7d 100644
3362 --- a/arch/arm/lib/clear_user.S
3363 +++ b/arch/arm/lib/clear_user.S
3364 @@ -12,14 +12,14 @@
3365
3366 .text
3367
3368 -/* Prototype: int __clear_user(void *addr, size_t sz)
3369 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3370 * Purpose : clear some user memory
3371 * Params : addr - user memory address to clear
3372 * : sz - number of bytes to clear
3373 * Returns : number of bytes NOT cleared
3374 */
3375 ENTRY(__clear_user_std)
3376 -WEAK(__clear_user)
3377 +WEAK(___clear_user)
3378 stmfd sp!, {r1, lr}
3379 mov r2, #0
3380 cmp r1, #4
3381 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3382 USER( strnebt r2, [r0])
3383 mov r0, #0
3384 ldmfd sp!, {r1, pc}
3385 -ENDPROC(__clear_user)
3386 +ENDPROC(___clear_user)
3387 ENDPROC(__clear_user_std)
3388
3389 .pushsection .fixup,"ax"
3390 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3391 index 66a477a..bee61d3 100644
3392 --- a/arch/arm/lib/copy_from_user.S
3393 +++ b/arch/arm/lib/copy_from_user.S
3394 @@ -16,7 +16,7 @@
3395 /*
3396 * Prototype:
3397 *
3398 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3399 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3400 *
3401 * Purpose:
3402 *
3403 @@ -84,11 +84,11 @@
3404
3405 .text
3406
3407 -ENTRY(__copy_from_user)
3408 +ENTRY(___copy_from_user)
3409
3410 #include "copy_template.S"
3411
3412 -ENDPROC(__copy_from_user)
3413 +ENDPROC(___copy_from_user)
3414
3415 .pushsection .fixup,"ax"
3416 .align 0
3417 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3418 index 6ee2f67..d1cce76 100644
3419 --- a/arch/arm/lib/copy_page.S
3420 +++ b/arch/arm/lib/copy_page.S
3421 @@ -10,6 +10,7 @@
3422 * ASM optimised string functions
3423 */
3424 #include <linux/linkage.h>
3425 +#include <linux/const.h>
3426 #include <asm/assembler.h>
3427 #include <asm/asm-offsets.h>
3428 #include <asm/cache.h>
3429 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3430 index d066df6..df28194 100644
3431 --- a/arch/arm/lib/copy_to_user.S
3432 +++ b/arch/arm/lib/copy_to_user.S
3433 @@ -16,7 +16,7 @@
3434 /*
3435 * Prototype:
3436 *
3437 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3438 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3439 *
3440 * Purpose:
3441 *
3442 @@ -88,11 +88,11 @@
3443 .text
3444
3445 ENTRY(__copy_to_user_std)
3446 -WEAK(__copy_to_user)
3447 +WEAK(___copy_to_user)
3448
3449 #include "copy_template.S"
3450
3451 -ENDPROC(__copy_to_user)
3452 +ENDPROC(___copy_to_user)
3453 ENDPROC(__copy_to_user_std)
3454
3455 .pushsection .fixup,"ax"
3456 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3457 index 7d08b43..f7ca7ea 100644
3458 --- a/arch/arm/lib/csumpartialcopyuser.S
3459 +++ b/arch/arm/lib/csumpartialcopyuser.S
3460 @@ -57,8 +57,8 @@
3461 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3462 */
3463
3464 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3465 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3466 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3467 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3468
3469 #include "csumpartialcopygeneric.S"
3470
3471 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3472 index 6b93f6a..1aa92d0 100644
3473 --- a/arch/arm/lib/delay.c
3474 +++ b/arch/arm/lib/delay.c
3475 @@ -28,12 +28,15 @@
3476 /*
3477 * Default to the loop-based delay implementation.
3478 */
3479 -struct arm_delay_ops arm_delay_ops = {
3480 +static struct arm_delay_ops arm_loop_delay_ops = {
3481 .delay = __loop_delay,
3482 .const_udelay = __loop_const_udelay,
3483 .udelay = __loop_udelay,
3484 + .const_clock = false,
3485 };
3486
3487 +struct arm_delay_ops *arm_delay_ops __read_only = &arm_loop_delay_ops;
3488 +
3489 static const struct delay_timer *delay_timer;
3490 static bool delay_calibrated;
3491
3492 @@ -67,6 +70,13 @@ static void __timer_udelay(unsigned long usecs)
3493 __timer_const_udelay(usecs * UDELAY_MULT);
3494 }
3495
3496 +static struct arm_delay_ops arm_timer_delay_ops = {
3497 + .delay = __timer_delay,
3498 + .const_udelay = __timer_const_udelay,
3499 + .udelay = __timer_udelay,
3500 + .const_clock = true,
3501 +};
3502 +
3503 void __init register_current_timer_delay(const struct delay_timer *timer)
3504 {
3505 if (!delay_calibrated) {
3506 @@ -74,10 +84,7 @@ void __init register_current_timer_delay(const struct delay_timer *timer)
3507 delay_timer = timer;
3508 lpj_fine = timer->freq / HZ;
3509 loops_per_jiffy = lpj_fine;
3510 - arm_delay_ops.delay = __timer_delay;
3511 - arm_delay_ops.const_udelay = __timer_const_udelay;
3512 - arm_delay_ops.udelay = __timer_udelay;
3513 - arm_delay_ops.const_clock = true;
3514 + arm_delay_ops = &arm_timer_delay_ops;
3515 delay_calibrated = true;
3516 } else {
3517 pr_info("Ignoring duplicate/late registration of read_current_timer delay\n");
3518 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3519 index 025f742..8432b08 100644
3520 --- a/arch/arm/lib/uaccess_with_memcpy.c
3521 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3522 @@ -104,7 +104,7 @@ out:
3523 }
3524
3525 unsigned long
3526 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3527 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3528 {
3529 /*
3530 * This test is stubbed out of the main function above to keep
3531 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3532 index bac21a5..b67ef8e 100644
3533 --- a/arch/arm/mach-kirkwood/common.c
3534 +++ b/arch/arm/mach-kirkwood/common.c
3535 @@ -150,7 +150,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3536 clk_gate_ops.disable(hw);
3537 }
3538
3539 -static struct clk_ops clk_gate_fn_ops;
3540 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3541 +{
3542 + return clk_gate_ops.is_enabled(hw);
3543 +}
3544 +
3545 +static struct clk_ops clk_gate_fn_ops = {
3546 + .enable = clk_gate_fn_enable,
3547 + .disable = clk_gate_fn_disable,
3548 + .is_enabled = clk_gate_fn_is_enabled,
3549 +};
3550
3551 static struct clk __init *clk_register_gate_fn(struct device *dev,
3552 const char *name,
3553 @@ -184,14 +193,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3554 gate_fn->fn_en = fn_en;
3555 gate_fn->fn_dis = fn_dis;
3556
3557 - /* ops is the gate ops, but with our enable/disable functions */
3558 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3559 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3560 - clk_gate_fn_ops = clk_gate_ops;
3561 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3562 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3563 - }
3564 -
3565 clk = clk_register(dev, &gate_fn->gate.hw);
3566
3567 if (IS_ERR(clk))
3568 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3569 index 0abb30f..54064da 100644
3570 --- a/arch/arm/mach-omap2/board-n8x0.c
3571 +++ b/arch/arm/mach-omap2/board-n8x0.c
3572 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3573 }
3574 #endif
3575
3576 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3577 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3578 .late_init = n8x0_menelaus_late_init,
3579 };
3580
3581 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3582 index 8033cb7..2f7cb62 100644
3583 --- a/arch/arm/mach-omap2/gpmc.c
3584 +++ b/arch/arm/mach-omap2/gpmc.c
3585 @@ -139,7 +139,6 @@ struct omap3_gpmc_regs {
3586 };
3587
3588 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3589 -static struct irq_chip gpmc_irq_chip;
3590 static unsigned gpmc_irq_start;
3591
3592 static struct resource gpmc_mem_root;
3593 @@ -700,6 +699,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3594
3595 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3596
3597 +static struct irq_chip gpmc_irq_chip = {
3598 + .name = "gpmc",
3599 + .irq_startup = gpmc_irq_noop_ret,
3600 + .irq_enable = gpmc_irq_enable,
3601 + .irq_disable = gpmc_irq_disable,
3602 + .irq_shutdown = gpmc_irq_noop,
3603 + .irq_ack = gpmc_irq_noop,
3604 + .irq_mask = gpmc_irq_noop,
3605 + .irq_unmask = gpmc_irq_noop,
3606 +
3607 +};
3608 +
3609 static int gpmc_setup_irq(void)
3610 {
3611 int i;
3612 @@ -714,15 +725,6 @@ static int gpmc_setup_irq(void)
3613 return gpmc_irq_start;
3614 }
3615
3616 - gpmc_irq_chip.name = "gpmc";
3617 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3618 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3619 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3620 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3621 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3622 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3623 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3624 -
3625 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3626 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3627
3628 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3629 index 5d3b4f4..ddba3c0 100644
3630 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3631 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3632 @@ -340,7 +340,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3633 return NOTIFY_OK;
3634 }
3635
3636 -static struct notifier_block __refdata irq_hotplug_notifier = {
3637 +static struct notifier_block irq_hotplug_notifier = {
3638 .notifier_call = irq_cpu_hotplug_notify,
3639 };
3640
3641 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3642 index e065daa..7b1ad9b 100644
3643 --- a/arch/arm/mach-omap2/omap_device.c
3644 +++ b/arch/arm/mach-omap2/omap_device.c
3645 @@ -686,7 +686,7 @@ void omap_device_delete(struct omap_device *od)
3646 * passes along the return value of omap_device_build_ss().
3647 */
3648 struct platform_device __init *omap_device_build(const char *pdev_name, int pdev_id,
3649 - struct omap_hwmod *oh, void *pdata,
3650 + struct omap_hwmod *oh, const void *pdata,
3651 int pdata_len,
3652 struct omap_device_pm_latency *pm_lats,
3653 int pm_lats_cnt, int is_early_device)
3654 @@ -720,7 +720,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name, int pdev
3655 */
3656 struct platform_device __init *omap_device_build_ss(const char *pdev_name, int pdev_id,
3657 struct omap_hwmod **ohs, int oh_cnt,
3658 - void *pdata, int pdata_len,
3659 + const void *pdata, int pdata_len,
3660 struct omap_device_pm_latency *pm_lats,
3661 int pm_lats_cnt, int is_early_device)
3662 {
3663 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3664 index 0933c59..42b8e2d 100644
3665 --- a/arch/arm/mach-omap2/omap_device.h
3666 +++ b/arch/arm/mach-omap2/omap_device.h
3667 @@ -91,14 +91,14 @@ int omap_device_shutdown(struct platform_device *pdev);
3668 /* Core code interface */
3669
3670 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3671 - struct omap_hwmod *oh, void *pdata,
3672 + struct omap_hwmod *oh, const void *pdata,
3673 int pdata_len,
3674 struct omap_device_pm_latency *pm_lats,
3675 int pm_lats_cnt, int is_early_device);
3676
3677 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3678 struct omap_hwmod **oh, int oh_cnt,
3679 - void *pdata, int pdata_len,
3680 + const void *pdata, int pdata_len,
3681 struct omap_device_pm_latency *pm_lats,
3682 int pm_lats_cnt, int is_early_device);
3683
3684 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3685 index 4653efb..8c60bf7 100644
3686 --- a/arch/arm/mach-omap2/omap_hwmod.c
3687 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3688 @@ -189,10 +189,10 @@ struct omap_hwmod_soc_ops {
3689 int (*init_clkdm)(struct omap_hwmod *oh);
3690 void (*update_context_lost)(struct omap_hwmod *oh);
3691 int (*get_context_lost)(struct omap_hwmod *oh);
3692 -};
3693 +} __no_const;
3694
3695 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3696 -static struct omap_hwmod_soc_ops soc_ops;
3697 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3698
3699 /* omap_hwmod_list contains all registered struct omap_hwmods */
3700 static LIST_HEAD(omap_hwmod_list);
3701 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3702 index 7c2b4ed..b2ea51f 100644
3703 --- a/arch/arm/mach-omap2/wd_timer.c
3704 +++ b/arch/arm/mach-omap2/wd_timer.c
3705 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3706 struct omap_hwmod *oh;
3707 char *oh_name = "wd_timer2";
3708 char *dev_name = "omap_wdt";
3709 - struct omap_wd_timer_platform_data pdata;
3710 + static struct omap_wd_timer_platform_data pdata = {
3711 + .read_reset_sources = prm_read_reset_sources
3712 + };
3713
3714 if (!cpu_class_is_omap2() || of_have_populated_dt())
3715 return 0;
3716 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3717 return -EINVAL;
3718 }
3719
3720 - pdata.read_reset_sources = prm_read_reset_sources;
3721 -
3722 pdev = omap_device_build(dev_name, id, oh, &pdata,
3723 sizeof(struct omap_wd_timer_platform_data),
3724 NULL, 0, 0);
3725 diff --git a/arch/arm/mach-ux500/include/mach/setup.h b/arch/arm/mach-ux500/include/mach/setup.h
3726 index 6be4c4d..32ac32a 100644
3727 --- a/arch/arm/mach-ux500/include/mach/setup.h
3728 +++ b/arch/arm/mach-ux500/include/mach/setup.h
3729 @@ -38,13 +38,6 @@ extern struct sys_timer ux500_timer;
3730 .type = MT_DEVICE, \
3731 }
3732
3733 -#define __MEM_DEV_DESC(x, sz) { \
3734 - .virtual = IO_ADDRESS(x), \
3735 - .pfn = __phys_to_pfn(x), \
3736 - .length = sz, \
3737 - .type = MT_MEMORY, \
3738 -}
3739 -
3740 extern struct smp_operations ux500_smp_ops;
3741 extern void ux500_cpu_die(unsigned int cpu);
3742
3743 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3744 index 3fd629d..8b1aca9 100644
3745 --- a/arch/arm/mm/Kconfig
3746 +++ b/arch/arm/mm/Kconfig
3747 @@ -425,7 +425,7 @@ config CPU_32v5
3748
3749 config CPU_32v6
3750 bool
3751 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3752 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC
3753 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3754
3755 config CPU_32v6K
3756 @@ -577,6 +577,7 @@ config CPU_CP15_MPU
3757
3758 config CPU_USE_DOMAINS
3759 bool
3760 + depends on !ARM_LPAE && !PAX_KERNEXEC
3761 help
3762 This option enables or disables the use of domain switching
3763 via the set_fs() function.
3764 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3765 index db26e2e..ee44569 100644
3766 --- a/arch/arm/mm/alignment.c
3767 +++ b/arch/arm/mm/alignment.c
3768 @@ -211,10 +211,12 @@ union offset_union {
3769 #define __get16_unaligned_check(ins,val,addr) \
3770 do { \
3771 unsigned int err = 0, v, a = addr; \
3772 + pax_open_userland(); \
3773 __get8_unaligned_check(ins,v,a,err); \
3774 val = v << ((BE) ? 8 : 0); \
3775 __get8_unaligned_check(ins,v,a,err); \
3776 val |= v << ((BE) ? 0 : 8); \
3777 + pax_close_userland(); \
3778 if (err) \
3779 goto fault; \
3780 } while (0)
3781 @@ -228,6 +230,7 @@ union offset_union {
3782 #define __get32_unaligned_check(ins,val,addr) \
3783 do { \
3784 unsigned int err = 0, v, a = addr; \
3785 + pax_open_userland(); \
3786 __get8_unaligned_check(ins,v,a,err); \
3787 val = v << ((BE) ? 24 : 0); \
3788 __get8_unaligned_check(ins,v,a,err); \
3789 @@ -236,6 +239,7 @@ union offset_union {
3790 val |= v << ((BE) ? 8 : 16); \
3791 __get8_unaligned_check(ins,v,a,err); \
3792 val |= v << ((BE) ? 0 : 24); \
3793 + pax_close_userland(); \
3794 if (err) \
3795 goto fault; \
3796 } while (0)
3797 @@ -249,6 +253,7 @@ union offset_union {
3798 #define __put16_unaligned_check(ins,val,addr) \
3799 do { \
3800 unsigned int err = 0, v = val, a = addr; \
3801 + pax_open_userland(); \
3802 __asm__( FIRST_BYTE_16 \
3803 ARM( "1: "ins" %1, [%2], #1\n" ) \
3804 THUMB( "1: "ins" %1, [%2]\n" ) \
3805 @@ -268,6 +273,7 @@ union offset_union {
3806 " .popsection\n" \
3807 : "=r" (err), "=&r" (v), "=&r" (a) \
3808 : "0" (err), "1" (v), "2" (a)); \
3809 + pax_close_userland(); \
3810 if (err) \
3811 goto fault; \
3812 } while (0)
3813 @@ -281,6 +287,7 @@ union offset_union {
3814 #define __put32_unaligned_check(ins,val,addr) \
3815 do { \
3816 unsigned int err = 0, v = val, a = addr; \
3817 + pax_open_userland(); \
3818 __asm__( FIRST_BYTE_32 \
3819 ARM( "1: "ins" %1, [%2], #1\n" ) \
3820 THUMB( "1: "ins" %1, [%2]\n" ) \
3821 @@ -310,6 +317,7 @@ union offset_union {
3822 " .popsection\n" \
3823 : "=r" (err), "=&r" (v), "=&r" (a) \
3824 : "0" (err), "1" (v), "2" (a)); \
3825 + pax_close_userland(); \
3826 if (err) \
3827 goto fault; \
3828 } while (0)
3829 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3830 index d07df17..59d5493 100644
3831 --- a/arch/arm/mm/context.c
3832 +++ b/arch/arm/mm/context.c
3833 @@ -45,7 +45,7 @@ static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3834 static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3835 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3836
3837 -static DEFINE_PER_CPU(atomic64_t, active_asids);
3838 +DEFINE_PER_CPU(atomic64_t, active_asids);
3839 static DEFINE_PER_CPU(u64, reserved_asids);
3840 static cpumask_t tlb_flush_pending;
3841
3842 @@ -209,8 +209,10 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3843 atomic64_set(&mm->context.id, asid);
3844 }
3845
3846 - if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending))
3847 + if (cpumask_test_and_clear_cpu(cpu, &tlb_flush_pending)) {
3848 local_flush_tlb_all();
3849 + dummy_flush_tlb_a15_erratum();
3850 + }
3851
3852 atomic64_set(&per_cpu(active_asids, cpu), asid);
3853 cpumask_set_cpu(cpu, mm_cpumask(mm));
3854 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3855 index 5dbf13f..1a60561 100644
3856 --- a/arch/arm/mm/fault.c
3857 +++ b/arch/arm/mm/fault.c
3858 @@ -25,6 +25,7 @@
3859 #include <asm/system_misc.h>
3860 #include <asm/system_info.h>
3861 #include <asm/tlbflush.h>
3862 +#include <asm/sections.h>
3863
3864 #include "fault.h"
3865
3866 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3867 if (fixup_exception(regs))
3868 return;
3869
3870 +#ifdef CONFIG_PAX_KERNEXEC
3871 + if ((fsr & FSR_WRITE) &&
3872 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3873 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3874 + {
3875 + if (current->signal->curr_ip)
3876 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3877 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3878 + else
3879 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3880 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3881 + }
3882 +#endif
3883 +
3884 /*
3885 * No handler, we'll have to terminate things with extreme prejudice.
3886 */
3887 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3888 }
3889 #endif
3890
3891 +#ifdef CONFIG_PAX_PAGEEXEC
3892 + if (fsr & FSR_LNX_PF) {
3893 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3894 + do_group_exit(SIGKILL);
3895 + }
3896 +#endif
3897 +
3898 tsk->thread.address = addr;
3899 tsk->thread.error_code = fsr;
3900 tsk->thread.trap_no = 14;
3901 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3902 }
3903 #endif /* CONFIG_MMU */
3904
3905 +#ifdef CONFIG_PAX_PAGEEXEC
3906 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3907 +{
3908 + long i;
3909 +
3910 + printk(KERN_ERR "PAX: bytes at PC: ");
3911 + for (i = 0; i < 20; i++) {
3912 + unsigned char c;
3913 + if (get_user(c, (__force unsigned char __user *)pc+i))
3914 + printk(KERN_CONT "?? ");
3915 + else
3916 + printk(KERN_CONT "%02x ", c);
3917 + }
3918 + printk("\n");
3919 +
3920 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3921 + for (i = -1; i < 20; i++) {
3922 + unsigned long c;
3923 + if (get_user(c, (__force unsigned long __user *)sp+i))
3924 + printk(KERN_CONT "???????? ");
3925 + else
3926 + printk(KERN_CONT "%08lx ", c);
3927 + }
3928 + printk("\n");
3929 +}
3930 +#endif
3931 +
3932 /*
3933 * First Level Translation Fault Handler
3934 *
3935 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3936 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3937 struct siginfo info;
3938
3939 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3940 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3941 + if (current->signal->curr_ip)
3942 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3943 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3944 + else
3945 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3946 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3947 + goto die;
3948 + }
3949 +#endif
3950 +
3951 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3952 return;
3953
3954 +die:
3955 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3956 inf->name, fsr, addr);
3957
3958 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3959 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3960 struct siginfo info;
3961
3962 + if (user_mode(regs)) {
3963 + if (addr == 0xffff0fe0UL) {
3964 + /*
3965 + * PaX: __kuser_get_tls emulation
3966 + */
3967 + regs->ARM_r0 = current_thread_info()->tp_value;
3968 + regs->ARM_pc = regs->ARM_lr;
3969 + return;
3970 + }
3971 + }
3972 +
3973 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3974 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3975 + if (current->signal->curr_ip)
3976 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3977 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3978 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3979 + else
3980 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3981 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3982 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3983 + goto die;
3984 + }
3985 +#endif
3986 +
3987 +#ifdef CONFIG_PAX_REFCOUNT
3988 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3989 + unsigned int bkpt;
3990 +
3991 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3992 + current->thread.error_code = ifsr;
3993 + current->thread.trap_no = 0;
3994 + pax_report_refcount_overflow(regs);
3995 + fixup_exception(regs);
3996 + return;
3997 + }
3998 + }
3999 +#endif
4000 +
4001 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4002 return;
4003
4004 +die:
4005 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4006 inf->name, ifsr, addr);
4007
4008 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4009 index cf08bdf..772656c 100644
4010 --- a/arch/arm/mm/fault.h
4011 +++ b/arch/arm/mm/fault.h
4012 @@ -3,6 +3,7 @@
4013
4014 /*
4015 * Fault status register encodings. We steal bit 31 for our own purposes.
4016 + * Set when the FSR value is from an instruction fault.
4017 */
4018 #define FSR_LNX_PF (1 << 31)
4019 #define FSR_WRITE (1 << 11)
4020 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4021 }
4022 #endif
4023
4024 +/* valid for LPAE and !LPAE */
4025 +static inline int is_xn_fault(unsigned int fsr)
4026 +{
4027 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4028 +}
4029 +
4030 +static inline int is_domain_fault(unsigned int fsr)
4031 +{
4032 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4033 +}
4034 +
4035 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4036 unsigned long search_exception_table(unsigned long addr);
4037
4038 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4039 index ad722f1..763fdd3 100644
4040 --- a/arch/arm/mm/init.c
4041 +++ b/arch/arm/mm/init.c
4042 @@ -30,6 +30,8 @@
4043 #include <asm/setup.h>
4044 #include <asm/tlb.h>
4045 #include <asm/fixmap.h>
4046 +#include <asm/system_info.h>
4047 +#include <asm/cp15.h>
4048
4049 #include <asm/mach/arch.h>
4050 #include <asm/mach/map.h>
4051 @@ -736,7 +738,46 @@ void free_initmem(void)
4052 {
4053 #ifdef CONFIG_HAVE_TCM
4054 extern char __tcm_start, __tcm_end;
4055 +#endif
4056
4057 +#ifdef CONFIG_PAX_KERNEXEC
4058 + unsigned long addr;
4059 + pgd_t *pgd;
4060 + pud_t *pud;
4061 + pmd_t *pmd;
4062 + int cpu_arch = cpu_architecture();
4063 + unsigned int cr = get_cr();
4064 +
4065 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4066 + /* make pages tables, etc before .text NX */
4067 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4068 + pgd = pgd_offset_k(addr);
4069 + pud = pud_offset(pgd, addr);
4070 + pmd = pmd_offset(pud, addr);
4071 + __section_update(pmd, addr, PMD_SECT_XN);
4072 + }
4073 + /* make init NX */
4074 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4075 + pgd = pgd_offset_k(addr);
4076 + pud = pud_offset(pgd, addr);
4077 + pmd = pmd_offset(pud, addr);
4078 + __section_update(pmd, addr, PMD_SECT_XN);
4079 + }
4080 + /* make kernel code/rodata RX */
4081 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4082 + pgd = pgd_offset_k(addr);
4083 + pud = pud_offset(pgd, addr);
4084 + pmd = pmd_offset(pud, addr);
4085 +#ifdef CONFIG_ARM_LPAE
4086 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4087 +#else
4088 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4089 +#endif
4090 + }
4091 + }
4092 +#endif
4093 +
4094 +#ifdef CONFIG_HAVE_TCM
4095 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4096 totalram_pages += free_area(__phys_to_pfn(__pa(&__tcm_start)),
4097 __phys_to_pfn(__pa(&__tcm_end)),
4098 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4099 index 88fd86c..7a224ce 100644
4100 --- a/arch/arm/mm/ioremap.c
4101 +++ b/arch/arm/mm/ioremap.c
4102 @@ -335,9 +335,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4103 unsigned int mtype;
4104
4105 if (cached)
4106 - mtype = MT_MEMORY;
4107 + mtype = MT_MEMORY_RX;
4108 else
4109 - mtype = MT_MEMORY_NONCACHED;
4110 + mtype = MT_MEMORY_NONCACHED_RX;
4111
4112 return __arm_ioremap_caller(phys_addr, size, mtype,
4113 __builtin_return_address(0));
4114 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4115 index 10062ce..aa96dd7 100644
4116 --- a/arch/arm/mm/mmap.c
4117 +++ b/arch/arm/mm/mmap.c
4118 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4119 struct vm_area_struct *vma;
4120 int do_align = 0;
4121 int aliasing = cache_is_vipt_aliasing();
4122 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4123 struct vm_unmapped_area_info info;
4124
4125 /*
4126 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4127 if (len > TASK_SIZE)
4128 return -ENOMEM;
4129
4130 +#ifdef CONFIG_PAX_RANDMMAP
4131 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4132 +#endif
4133 +
4134 if (addr) {
4135 if (do_align)
4136 addr = COLOUR_ALIGN(addr, pgoff);
4137 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 addr = PAGE_ALIGN(addr);
4139
4140 vma = find_vma(mm, addr);
4141 - if (TASK_SIZE - len >= addr &&
4142 - (!vma || addr + len <= vma->vm_start))
4143 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4144 return addr;
4145 }
4146
4147 @@ -112,6 +116,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4148 unsigned long addr = addr0;
4149 int do_align = 0;
4150 int aliasing = cache_is_vipt_aliasing();
4151 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4152 struct vm_unmapped_area_info info;
4153
4154 /*
4155 @@ -132,6 +137,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4156 return addr;
4157 }
4158
4159 +#ifdef CONFIG_PAX_RANDMMAP
4160 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4161 +#endif
4162 +
4163 /* requesting a specific address */
4164 if (addr) {
4165 if (do_align)
4166 @@ -139,8 +148,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 else
4168 addr = PAGE_ALIGN(addr);
4169 vma = find_vma(mm, addr);
4170 - if (TASK_SIZE - len >= addr &&
4171 - (!vma || addr + len <= vma->vm_start))
4172 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4173 return addr;
4174 }
4175
4176 @@ -162,6 +170,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4177 VM_BUG_ON(addr != -ENOMEM);
4178 info.flags = 0;
4179 info.low_limit = mm->mmap_base;
4180 +
4181 +#ifdef CONFIG_PAX_RANDMMAP
4182 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4183 + info.low_limit += mm->delta_mmap;
4184 +#endif
4185 +
4186 info.high_limit = TASK_SIZE;
4187 addr = vm_unmapped_area(&info);
4188 }
4189 @@ -173,6 +187,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4190 {
4191 unsigned long random_factor = 0UL;
4192
4193 +#ifdef CONFIG_PAX_RANDMMAP
4194 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4195 +#endif
4196 +
4197 /* 8 bits of randomness in 20 address space bits */
4198 if ((current->flags & PF_RANDOMIZE) &&
4199 !(current->personality & ADDR_NO_RANDOMIZE))
4200 @@ -180,10 +198,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4201
4202 if (mmap_is_legacy()) {
4203 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4204 +
4205 +#ifdef CONFIG_PAX_RANDMMAP
4206 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4207 + mm->mmap_base += mm->delta_mmap;
4208 +#endif
4209 +
4210 mm->get_unmapped_area = arch_get_unmapped_area;
4211 mm->unmap_area = arch_unmap_area;
4212 } else {
4213 mm->mmap_base = mmap_base(random_factor);
4214 +
4215 +#ifdef CONFIG_PAX_RANDMMAP
4216 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4217 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4218 +#endif
4219 +
4220 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4221 mm->unmap_area = arch_unmap_area_topdown;
4222 }
4223 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4224 index ce328c7..35b88dc 100644
4225 --- a/arch/arm/mm/mmu.c
4226 +++ b/arch/arm/mm/mmu.c
4227 @@ -35,6 +35,23 @@
4228
4229 #include "mm.h"
4230
4231 +
4232 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4233 +void modify_domain(unsigned int dom, unsigned int type)
4234 +{
4235 + struct thread_info *thread = current_thread_info();
4236 + unsigned int domain = thread->cpu_domain;
4237 + /*
4238 + * DOMAIN_MANAGER might be defined to some other value,
4239 + * use the arch-defined constant
4240 + */
4241 + domain &= ~domain_val(dom, 3);
4242 + thread->cpu_domain = domain | domain_val(dom, type);
4243 + set_domain(thread->cpu_domain);
4244 +}
4245 +EXPORT_SYMBOL(modify_domain);
4246 +#endif
4247 +
4248 /*
4249 * empty_zero_page is a special page that is used for
4250 * zero-initialized data and COW.
4251 @@ -195,10 +212,18 @@ void adjust_cr(unsigned long mask, unsigned long set)
4252 }
4253 #endif
4254
4255 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4256 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4257 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4258
4259 -static struct mem_type mem_types[] = {
4260 +#ifdef CONFIG_PAX_KERNEXEC
4261 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4262 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4263 +#else
4264 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4265 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4266 +#endif
4267 +
4268 +static struct mem_type mem_types[] __read_only = {
4269 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4270 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4271 L_PTE_SHARED,
4272 @@ -227,16 +252,16 @@ static struct mem_type mem_types[] = {
4273 [MT_UNCACHED] = {
4274 .prot_pte = PROT_PTE_DEVICE,
4275 .prot_l1 = PMD_TYPE_TABLE,
4276 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4277 + .prot_sect = PROT_SECT_DEVICE,
4278 .domain = DOMAIN_IO,
4279 },
4280 [MT_CACHECLEAN] = {
4281 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4282 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4283 .domain = DOMAIN_KERNEL,
4284 },
4285 #ifndef CONFIG_ARM_LPAE
4286 [MT_MINICLEAN] = {
4287 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4288 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4289 .domain = DOMAIN_KERNEL,
4290 },
4291 #endif
4292 @@ -244,36 +269,54 @@ static struct mem_type mem_types[] = {
4293 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4294 L_PTE_RDONLY,
4295 .prot_l1 = PMD_TYPE_TABLE,
4296 - .domain = DOMAIN_USER,
4297 + .domain = DOMAIN_VECTORS,
4298 },
4299 [MT_HIGH_VECTORS] = {
4300 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4301 - L_PTE_USER | L_PTE_RDONLY,
4302 + L_PTE_RDONLY,
4303 .prot_l1 = PMD_TYPE_TABLE,
4304 - .domain = DOMAIN_USER,
4305 + .domain = DOMAIN_VECTORS,
4306 },
4307 - [MT_MEMORY] = {
4308 + [MT_MEMORY_RWX] = {
4309 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4310 .prot_l1 = PMD_TYPE_TABLE,
4311 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4312 .domain = DOMAIN_KERNEL,
4313 },
4314 + [MT_MEMORY_RW] = {
4315 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4316 + .prot_l1 = PMD_TYPE_TABLE,
4317 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4318 + .domain = DOMAIN_KERNEL,
4319 + },
4320 + [MT_MEMORY_RX] = {
4321 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4322 + .prot_l1 = PMD_TYPE_TABLE,
4323 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4324 + .domain = DOMAIN_KERNEL,
4325 + },
4326 [MT_ROM] = {
4327 - .prot_sect = PMD_TYPE_SECT,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4329 .domain = DOMAIN_KERNEL,
4330 },
4331 - [MT_MEMORY_NONCACHED] = {
4332 + [MT_MEMORY_NONCACHED_RW] = {
4333 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4334 L_PTE_MT_BUFFERABLE,
4335 .prot_l1 = PMD_TYPE_TABLE,
4336 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4337 .domain = DOMAIN_KERNEL,
4338 },
4339 + [MT_MEMORY_NONCACHED_RX] = {
4340 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4341 + L_PTE_MT_BUFFERABLE,
4342 + .prot_l1 = PMD_TYPE_TABLE,
4343 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4344 + .domain = DOMAIN_KERNEL,
4345 + },
4346 [MT_MEMORY_DTCM] = {
4347 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4348 - L_PTE_XN,
4349 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4350 .prot_l1 = PMD_TYPE_TABLE,
4351 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4352 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4353 .domain = DOMAIN_KERNEL,
4354 },
4355 [MT_MEMORY_ITCM] = {
4356 @@ -283,10 +326,10 @@ static struct mem_type mem_types[] = {
4357 },
4358 [MT_MEMORY_SO] = {
4359 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4360 - L_PTE_MT_UNCACHED | L_PTE_XN,
4361 + L_PTE_MT_UNCACHED,
4362 .prot_l1 = PMD_TYPE_TABLE,
4363 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4364 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4365 + PMD_SECT_UNCACHED,
4366 .domain = DOMAIN_KERNEL,
4367 },
4368 [MT_MEMORY_DMA_READY] = {
4369 @@ -371,9 +414,35 @@ static void __init build_mem_type_table(void)
4370 * to prevent speculative instruction fetches.
4371 */
4372 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4373 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4374 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4375 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4376 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4377 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4378 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4379 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4380 +
4381 + /* Mark other regions on ARMv6+ as execute-never */
4382 +
4383 +#ifdef CONFIG_PAX_KERNEXEC
4384 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4385 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4386 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4387 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4388 +#ifndef CONFIG_ARM_LPAE
4389 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4391 +#endif
4392 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4393 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4394 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4395 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4396 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4397 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4398 +#endif
4399 +
4400 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4402 }
4403 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4404 /*
4405 @@ -432,6 +501,9 @@ static void __init build_mem_type_table(void)
4406 * from SVC mode and no access from userspace.
4407 */
4408 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4409 +#ifdef CONFIG_PAX_KERNEXEC
4410 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4411 +#endif
4412 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4413 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4414 #endif
4415 @@ -448,11 +520,17 @@ static void __init build_mem_type_table(void)
4416 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4417 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4418 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4419 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4420 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4421 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4422 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4423 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4424 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4425 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4426 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4427 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4428 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4429 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4430 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4431 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4434 }
4435 }
4436
4437 @@ -463,15 +541,20 @@ static void __init build_mem_type_table(void)
4438 if (cpu_arch >= CPU_ARCH_ARMv6) {
4439 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4440 /* Non-cacheable Normal is XCB = 001 */
4441 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4443 + PMD_SECT_BUFFERED;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4445 PMD_SECT_BUFFERED;
4446 } else {
4447 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4448 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4449 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4450 + PMD_SECT_TEX(1);
4451 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4452 PMD_SECT_TEX(1);
4453 }
4454 } else {
4455 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4456 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4457 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4458 }
4459
4460 #ifdef CONFIG_ARM_LPAE
4461 @@ -487,6 +570,8 @@ static void __init build_mem_type_table(void)
4462 vecs_pgprot |= PTE_EXT_AF;
4463 #endif
4464
4465 + user_pgprot |= __supported_pte_mask;
4466 +
4467 for (i = 0; i < 16; i++) {
4468 pteval_t v = pgprot_val(protection_map[i]);
4469 protection_map[i] = __pgprot(v | user_pgprot);
4470 @@ -501,10 +586,15 @@ static void __init build_mem_type_table(void)
4471
4472 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4473 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4474 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4475 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4476 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4477 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4478 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4479 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4480 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4481 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4482 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4483 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4484 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4485 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4486 mem_types[MT_ROM].prot_sect |= cp->pmd;
4487
4488 switch (cp->pmd) {
4489 @@ -1105,18 +1195,15 @@ void __init arm_mm_memblock_reserve(void)
4490 * called function. This means you can't use any function or debugging
4491 * method which may touch any device, otherwise the kernel _will_ crash.
4492 */
4493 +
4494 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4495 +
4496 static void __init devicemaps_init(struct machine_desc *mdesc)
4497 {
4498 struct map_desc map;
4499 unsigned long addr;
4500 - void *vectors;
4501
4502 - /*
4503 - * Allocate the vector page early.
4504 - */
4505 - vectors = early_alloc(PAGE_SIZE);
4506 -
4507 - early_trap_init(vectors);
4508 + early_trap_init(&vectors);
4509
4510 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4511 pmd_clear(pmd_off_k(addr));
4512 @@ -1156,7 +1243,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4513 * location (0xffff0000). If we aren't using high-vectors, also
4514 * create a mapping at the low-vectors virtual address.
4515 */
4516 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4517 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4518 map.virtual = 0xffff0000;
4519 map.length = PAGE_SIZE;
4520 map.type = MT_HIGH_VECTORS;
4521 @@ -1214,8 +1301,39 @@ static void __init map_lowmem(void)
4522 map.pfn = __phys_to_pfn(start);
4523 map.virtual = __phys_to_virt(start);
4524 map.length = end - start;
4525 - map.type = MT_MEMORY;
4526
4527 +#ifdef CONFIG_PAX_KERNEXEC
4528 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4529 + struct map_desc kernel;
4530 + struct map_desc initmap;
4531 +
4532 + /* when freeing initmem we will make this RW */
4533 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4534 + initmap.virtual = (unsigned long)__init_begin;
4535 + initmap.length = _sdata - __init_begin;
4536 + initmap.type = MT_MEMORY_RWX;
4537 + create_mapping(&initmap);
4538 +
4539 + /* when freeing initmem we will make this RX */
4540 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4541 + kernel.virtual = (unsigned long)_stext;
4542 + kernel.length = __init_begin - _stext;
4543 + kernel.type = MT_MEMORY_RWX;
4544 + create_mapping(&kernel);
4545 +
4546 + if (map.virtual < (unsigned long)_stext) {
4547 + map.length = (unsigned long)_stext - map.virtual;
4548 + map.type = MT_MEMORY_RWX;
4549 + create_mapping(&map);
4550 + }
4551 +
4552 + map.pfn = __phys_to_pfn(__pa(_sdata));
4553 + map.virtual = (unsigned long)_sdata;
4554 + map.length = end - __pa(_sdata);
4555 + }
4556 +#endif
4557 +
4558 + map.type = MT_MEMORY_RW;
4559 create_mapping(&map);
4560 }
4561 }
4562 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4563 index 6d98c13..3cfb174 100644
4564 --- a/arch/arm/mm/proc-v7-2level.S
4565 +++ b/arch/arm/mm/proc-v7-2level.S
4566 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4567 tst r1, #L_PTE_XN
4568 orrne r3, r3, #PTE_EXT_XN
4569
4570 + tst r1, #L_PTE_PXN
4571 + orrne r3, r3, #PTE_EXT_PXN
4572 +
4573 tst r1, #L_PTE_YOUNG
4574 tstne r1, #L_PTE_VALID
4575 #ifndef CONFIG_CPU_USE_DOMAINS
4576 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4577 index a5bc92d..0bb4730 100644
4578 --- a/arch/arm/plat-omap/sram.c
4579 +++ b/arch/arm/plat-omap/sram.c
4580 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4581 * Looks like we need to preserve some bootloader code at the
4582 * beginning of SRAM for jumping to flash for reboot to work...
4583 */
4584 + pax_open_kernel();
4585 memset_io(omap_sram_base + omap_sram_skip, 0,
4586 omap_sram_size - omap_sram_skip);
4587 + pax_close_kernel();
4588 }
4589 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 index f5144cd..71f6d1f 100644
4591 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4592 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4593 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4594 int (*started)(unsigned ch);
4595 int (*flush)(unsigned ch);
4596 int (*stop)(unsigned ch);
4597 -};
4598 +} __no_const;
4599
4600 extern void *samsung_dmadev_get_ops(void);
4601 extern void *s3c_dma_get_ops(void);
4602 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4603 index 0c3ba9f..95722b3 100644
4604 --- a/arch/arm64/kernel/debug-monitors.c
4605 +++ b/arch/arm64/kernel/debug-monitors.c
4606 @@ -151,7 +151,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4607 return NOTIFY_OK;
4608 }
4609
4610 -static struct notifier_block __cpuinitdata os_lock_nb = {
4611 +static struct notifier_block os_lock_nb = {
4612 .notifier_call = os_lock_notify,
4613 };
4614
4615 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4616 index 5ab825c..96aaec8 100644
4617 --- a/arch/arm64/kernel/hw_breakpoint.c
4618 +++ b/arch/arm64/kernel/hw_breakpoint.c
4619 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4620 return NOTIFY_OK;
4621 }
4622
4623 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4624 +static struct notifier_block hw_breakpoint_reset_nb = {
4625 .notifier_call = hw_breakpoint_reset_notify,
4626 };
4627
4628 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4629 index c3a58a1..78fbf54 100644
4630 --- a/arch/avr32/include/asm/cache.h
4631 +++ b/arch/avr32/include/asm/cache.h
4632 @@ -1,8 +1,10 @@
4633 #ifndef __ASM_AVR32_CACHE_H
4634 #define __ASM_AVR32_CACHE_H
4635
4636 +#include <linux/const.h>
4637 +
4638 #define L1_CACHE_SHIFT 5
4639 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4640 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4641
4642 /*
4643 * Memory returned by kmalloc() may be used for DMA, so we must make
4644 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4645 index e2c3287..6c4f98c 100644
4646 --- a/arch/avr32/include/asm/elf.h
4647 +++ b/arch/avr32/include/asm/elf.h
4648 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4649 the loader. We need to make sure that it is out of the way of the program
4650 that it will "exec", and that there is sufficient room for the brk. */
4651
4652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4654
4655 +#ifdef CONFIG_PAX_ASLR
4656 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4657 +
4658 +#define PAX_DELTA_MMAP_LEN 15
4659 +#define PAX_DELTA_STACK_LEN 15
4660 +#endif
4661
4662 /* This yields a mask that user programs can use to figure out what
4663 instruction set this CPU supports. This could be done in user space,
4664 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4665 index 479330b..53717a8 100644
4666 --- a/arch/avr32/include/asm/kmap_types.h
4667 +++ b/arch/avr32/include/asm/kmap_types.h
4668 @@ -2,9 +2,9 @@
4669 #define __ASM_AVR32_KMAP_TYPES_H
4670
4671 #ifdef CONFIG_DEBUG_HIGHMEM
4672 -# define KM_TYPE_NR 29
4673 +# define KM_TYPE_NR 30
4674 #else
4675 -# define KM_TYPE_NR 14
4676 +# define KM_TYPE_NR 15
4677 #endif
4678
4679 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4680 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4681 index b2f2d2d..d1c85cb 100644
4682 --- a/arch/avr32/mm/fault.c
4683 +++ b/arch/avr32/mm/fault.c
4684 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4685
4686 int exception_trace = 1;
4687
4688 +#ifdef CONFIG_PAX_PAGEEXEC
4689 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4690 +{
4691 + unsigned long i;
4692 +
4693 + printk(KERN_ERR "PAX: bytes at PC: ");
4694 + for (i = 0; i < 20; i++) {
4695 + unsigned char c;
4696 + if (get_user(c, (unsigned char *)pc+i))
4697 + printk(KERN_CONT "???????? ");
4698 + else
4699 + printk(KERN_CONT "%02x ", c);
4700 + }
4701 + printk("\n");
4702 +}
4703 +#endif
4704 +
4705 /*
4706 * This routine handles page faults. It determines the address and the
4707 * problem, and then passes it off to one of the appropriate routines.
4708 @@ -174,6 +191,16 @@ bad_area:
4709 up_read(&mm->mmap_sem);
4710
4711 if (user_mode(regs)) {
4712 +
4713 +#ifdef CONFIG_PAX_PAGEEXEC
4714 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4715 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4716 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4717 + do_group_exit(SIGKILL);
4718 + }
4719 + }
4720 +#endif
4721 +
4722 if (exception_trace && printk_ratelimit())
4723 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4724 "sp %08lx ecr %lu\n",
4725 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4726 index 568885a..f8008df 100644
4727 --- a/arch/blackfin/include/asm/cache.h
4728 +++ b/arch/blackfin/include/asm/cache.h
4729 @@ -7,6 +7,7 @@
4730 #ifndef __ARCH_BLACKFIN_CACHE_H
4731 #define __ARCH_BLACKFIN_CACHE_H
4732
4733 +#include <linux/const.h>
4734 #include <linux/linkage.h> /* for asmlinkage */
4735
4736 /*
4737 @@ -14,7 +15,7 @@
4738 * Blackfin loads 32 bytes for cache
4739 */
4740 #define L1_CACHE_SHIFT 5
4741 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4742 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4743 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4744
4745 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4746 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4747 index aea2718..3639a60 100644
4748 --- a/arch/cris/include/arch-v10/arch/cache.h
4749 +++ b/arch/cris/include/arch-v10/arch/cache.h
4750 @@ -1,8 +1,9 @@
4751 #ifndef _ASM_ARCH_CACHE_H
4752 #define _ASM_ARCH_CACHE_H
4753
4754 +#include <linux/const.h>
4755 /* Etrax 100LX have 32-byte cache-lines. */
4756 -#define L1_CACHE_BYTES 32
4757 #define L1_CACHE_SHIFT 5
4758 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4759
4760 #endif /* _ASM_ARCH_CACHE_H */
4761 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4762 index 7caf25d..ee65ac5 100644
4763 --- a/arch/cris/include/arch-v32/arch/cache.h
4764 +++ b/arch/cris/include/arch-v32/arch/cache.h
4765 @@ -1,11 +1,12 @@
4766 #ifndef _ASM_CRIS_ARCH_CACHE_H
4767 #define _ASM_CRIS_ARCH_CACHE_H
4768
4769 +#include <linux/const.h>
4770 #include <arch/hwregs/dma.h>
4771
4772 /* A cache-line is 32 bytes. */
4773 -#define L1_CACHE_BYTES 32
4774 #define L1_CACHE_SHIFT 5
4775 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4776
4777 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4778
4779 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4780 index b86329d..6709906 100644
4781 --- a/arch/frv/include/asm/atomic.h
4782 +++ b/arch/frv/include/asm/atomic.h
4783 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4784 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4785 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4786
4787 +#define atomic64_read_unchecked(v) atomic64_read(v)
4788 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4789 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4790 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4791 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4792 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4793 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4794 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4795 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4796 +
4797 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4798 {
4799 int c, old;
4800 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4801 index 2797163..c2a401d 100644
4802 --- a/arch/frv/include/asm/cache.h
4803 +++ b/arch/frv/include/asm/cache.h
4804 @@ -12,10 +12,11 @@
4805 #ifndef __ASM_CACHE_H
4806 #define __ASM_CACHE_H
4807
4808 +#include <linux/const.h>
4809
4810 /* bytes per L1 cache line */
4811 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4812 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4813 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4814
4815 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4816 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4817 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4818 index 43901f2..0d8b865 100644
4819 --- a/arch/frv/include/asm/kmap_types.h
4820 +++ b/arch/frv/include/asm/kmap_types.h
4821 @@ -2,6 +2,6 @@
4822 #ifndef _ASM_KMAP_TYPES_H
4823 #define _ASM_KMAP_TYPES_H
4824
4825 -#define KM_TYPE_NR 17
4826 +#define KM_TYPE_NR 18
4827
4828 #endif
4829 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4830 index 385fd30..3aaf4fe 100644
4831 --- a/arch/frv/mm/elf-fdpic.c
4832 +++ b/arch/frv/mm/elf-fdpic.c
4833 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4834 {
4835 struct vm_area_struct *vma;
4836 unsigned long limit;
4837 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4838
4839 if (len > TASK_SIZE)
4840 return -ENOMEM;
4841 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4842 if (addr) {
4843 addr = PAGE_ALIGN(addr);
4844 vma = find_vma(current->mm, addr);
4845 - if (TASK_SIZE - len >= addr &&
4846 - (!vma || addr + len <= vma->vm_start))
4847 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4848 goto success;
4849 }
4850
4851 @@ -89,7 +89,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4852 for (; vma; vma = vma->vm_next) {
4853 if (addr > limit)
4854 break;
4855 - if (addr + len <= vma->vm_start)
4856 + if (check_heap_stack_gap(vma, addr, len, offset))
4857 goto success;
4858 addr = vma->vm_end;
4859 }
4860 @@ -104,7 +104,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4861 for (; vma; vma = vma->vm_next) {
4862 if (addr > limit)
4863 break;
4864 - if (addr + len <= vma->vm_start)
4865 + if (check_heap_stack_gap(vma, addr, len, offset))
4866 goto success;
4867 addr = vma->vm_end;
4868 }
4869 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4870 index f4ca594..adc72fd6 100644
4871 --- a/arch/hexagon/include/asm/cache.h
4872 +++ b/arch/hexagon/include/asm/cache.h
4873 @@ -21,9 +21,11 @@
4874 #ifndef __ASM_CACHE_H
4875 #define __ASM_CACHE_H
4876
4877 +#include <linux/const.h>
4878 +
4879 /* Bytes per L1 cache line */
4880 -#define L1_CACHE_SHIFT (5)
4881 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4882 +#define L1_CACHE_SHIFT 5
4883 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4884
4885 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4886 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4887 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4888 index 6e6fe18..a6ae668 100644
4889 --- a/arch/ia64/include/asm/atomic.h
4890 +++ b/arch/ia64/include/asm/atomic.h
4891 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4892 #define atomic64_inc(v) atomic64_add(1, (v))
4893 #define atomic64_dec(v) atomic64_sub(1, (v))
4894
4895 +#define atomic64_read_unchecked(v) atomic64_read(v)
4896 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4897 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4898 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4899 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4900 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4901 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4902 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4903 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4904 +
4905 /* Atomic operations are already serializing */
4906 #define smp_mb__before_atomic_dec() barrier()
4907 #define smp_mb__after_atomic_dec() barrier()
4908 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4909 index 988254a..e1ee885 100644
4910 --- a/arch/ia64/include/asm/cache.h
4911 +++ b/arch/ia64/include/asm/cache.h
4912 @@ -1,6 +1,7 @@
4913 #ifndef _ASM_IA64_CACHE_H
4914 #define _ASM_IA64_CACHE_H
4915
4916 +#include <linux/const.h>
4917
4918 /*
4919 * Copyright (C) 1998-2000 Hewlett-Packard Co
4920 @@ -9,7 +10,7 @@
4921
4922 /* Bytes per L1 (data) cache line. */
4923 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4924 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4925 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4926
4927 #ifdef CONFIG_SMP
4928 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4929 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4930 index b5298eb..67c6e62 100644
4931 --- a/arch/ia64/include/asm/elf.h
4932 +++ b/arch/ia64/include/asm/elf.h
4933 @@ -42,6 +42,13 @@
4934 */
4935 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4936
4937 +#ifdef CONFIG_PAX_ASLR
4938 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4939 +
4940 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4941 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4942 +#endif
4943 +
4944 #define PT_IA_64_UNWIND 0x70000001
4945
4946 /* IA-64 relocations: */
4947 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4948 index 96a8d92..617a1cf 100644
4949 --- a/arch/ia64/include/asm/pgalloc.h
4950 +++ b/arch/ia64/include/asm/pgalloc.h
4951 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4952 pgd_val(*pgd_entry) = __pa(pud);
4953 }
4954
4955 +static inline void
4956 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4957 +{
4958 + pgd_populate(mm, pgd_entry, pud);
4959 +}
4960 +
4961 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4962 {
4963 return quicklist_alloc(0, GFP_KERNEL, NULL);
4964 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4965 pud_val(*pud_entry) = __pa(pmd);
4966 }
4967
4968 +static inline void
4969 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4970 +{
4971 + pud_populate(mm, pud_entry, pmd);
4972 +}
4973 +
4974 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4975 {
4976 return quicklist_alloc(0, GFP_KERNEL, NULL);
4977 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4978 index 815810c..d60bd4c 100644
4979 --- a/arch/ia64/include/asm/pgtable.h
4980 +++ b/arch/ia64/include/asm/pgtable.h
4981 @@ -12,7 +12,7 @@
4982 * David Mosberger-Tang <davidm@hpl.hp.com>
4983 */
4984
4985 -
4986 +#include <linux/const.h>
4987 #include <asm/mman.h>
4988 #include <asm/page.h>
4989 #include <asm/processor.h>
4990 @@ -142,6 +142,17 @@
4991 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4992 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4993 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4994 +
4995 +#ifdef CONFIG_PAX_PAGEEXEC
4996 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4997 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4998 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4999 +#else
5000 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5001 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5002 +# define PAGE_COPY_NOEXEC PAGE_COPY
5003 +#endif
5004 +
5005 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
5006 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
5007 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
5008 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
5009 index 54ff557..70c88b7 100644
5010 --- a/arch/ia64/include/asm/spinlock.h
5011 +++ b/arch/ia64/include/asm/spinlock.h
5012 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
5013 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
5014
5015 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
5016 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
5017 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
5018 }
5019
5020 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
5021 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
5022 index 449c8c0..18965fb 100644
5023 --- a/arch/ia64/include/asm/uaccess.h
5024 +++ b/arch/ia64/include/asm/uaccess.h
5025 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
5026 static inline unsigned long
5027 __copy_to_user (void __user *to, const void *from, unsigned long count)
5028 {
5029 + if (count > INT_MAX)
5030 + return count;
5031 +
5032 + if (!__builtin_constant_p(count))
5033 + check_object_size(from, count, true);
5034 +
5035 return __copy_user(to, (__force void __user *) from, count);
5036 }
5037
5038 static inline unsigned long
5039 __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 {
5041 + if (count > INT_MAX)
5042 + return count;
5043 +
5044 + if (!__builtin_constant_p(count))
5045 + check_object_size(to, count, false);
5046 +
5047 return __copy_user((__force void __user *) to, from, count);
5048 }
5049
5050 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5051 ({ \
5052 void __user *__cu_to = (to); \
5053 const void *__cu_from = (from); \
5054 - long __cu_len = (n); \
5055 + unsigned long __cu_len = (n); \
5056 \
5057 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5058 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5059 + if (!__builtin_constant_p(n)) \
5060 + check_object_size(__cu_from, __cu_len, true); \
5061 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5062 + } \
5063 __cu_len; \
5064 })
5065
5066 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5067 ({ \
5068 void *__cu_to = (to); \
5069 const void __user *__cu_from = (from); \
5070 - long __cu_len = (n); \
5071 + unsigned long __cu_len = (n); \
5072 \
5073 __chk_user_ptr(__cu_from); \
5074 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5075 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5076 + if (!__builtin_constant_p(n)) \
5077 + check_object_size(__cu_to, __cu_len, false); \
5078 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5079 + } \
5080 __cu_len; \
5081 })
5082
5083 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
5084 index 2d67317..07d8bfa 100644
5085 --- a/arch/ia64/kernel/err_inject.c
5086 +++ b/arch/ia64/kernel/err_inject.c
5087 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
5088 return NOTIFY_OK;
5089 }
5090
5091 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
5092 +static struct notifier_block err_inject_cpu_notifier =
5093 {
5094 .notifier_call = err_inject_cpu_callback,
5095 };
5096 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
5097 index 65bf9cd..794f06b 100644
5098 --- a/arch/ia64/kernel/mca.c
5099 +++ b/arch/ia64/kernel/mca.c
5100 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
5101 return NOTIFY_OK;
5102 }
5103
5104 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
5105 +static struct notifier_block mca_cpu_notifier = {
5106 .notifier_call = mca_cpu_callback
5107 };
5108
5109 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5110 index 24603be..948052d 100644
5111 --- a/arch/ia64/kernel/module.c
5112 +++ b/arch/ia64/kernel/module.c
5113 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5114 void
5115 module_free (struct module *mod, void *module_region)
5116 {
5117 - if (mod && mod->arch.init_unw_table &&
5118 - module_region == mod->module_init) {
5119 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5120 unw_remove_unwind_table(mod->arch.init_unw_table);
5121 mod->arch.init_unw_table = NULL;
5122 }
5123 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5124 }
5125
5126 static inline int
5127 +in_init_rx (const struct module *mod, uint64_t addr)
5128 +{
5129 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5130 +}
5131 +
5132 +static inline int
5133 +in_init_rw (const struct module *mod, uint64_t addr)
5134 +{
5135 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5136 +}
5137 +
5138 +static inline int
5139 in_init (const struct module *mod, uint64_t addr)
5140 {
5141 - return addr - (uint64_t) mod->module_init < mod->init_size;
5142 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5143 +}
5144 +
5145 +static inline int
5146 +in_core_rx (const struct module *mod, uint64_t addr)
5147 +{
5148 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5149 +}
5150 +
5151 +static inline int
5152 +in_core_rw (const struct module *mod, uint64_t addr)
5153 +{
5154 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5155 }
5156
5157 static inline int
5158 in_core (const struct module *mod, uint64_t addr)
5159 {
5160 - return addr - (uint64_t) mod->module_core < mod->core_size;
5161 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5162 }
5163
5164 static inline int
5165 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5166 break;
5167
5168 case RV_BDREL:
5169 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5170 + if (in_init_rx(mod, val))
5171 + val -= (uint64_t) mod->module_init_rx;
5172 + else if (in_init_rw(mod, val))
5173 + val -= (uint64_t) mod->module_init_rw;
5174 + else if (in_core_rx(mod, val))
5175 + val -= (uint64_t) mod->module_core_rx;
5176 + else if (in_core_rw(mod, val))
5177 + val -= (uint64_t) mod->module_core_rw;
5178 break;
5179
5180 case RV_LTV:
5181 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5182 * addresses have been selected...
5183 */
5184 uint64_t gp;
5185 - if (mod->core_size > MAX_LTOFF)
5186 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5187 /*
5188 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5189 * at the end of the module.
5190 */
5191 - gp = mod->core_size - MAX_LTOFF / 2;
5192 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5193 else
5194 - gp = mod->core_size / 2;
5195 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5196 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5197 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5198 mod->arch.gp = gp;
5199 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5200 }
5201 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5202 index 77597e5..189dd62f 100644
5203 --- a/arch/ia64/kernel/palinfo.c
5204 +++ b/arch/ia64/kernel/palinfo.c
5205 @@ -977,7 +977,7 @@ create_palinfo_proc_entries(unsigned int cpu)
5206 struct proc_dir_entry **pdir;
5207 struct proc_dir_entry *cpu_dir;
5208 int j;
5209 - char cpustr[sizeof(CPUSTR)];
5210 + char cpustr[3+4+1];
5211
5212
5213 /*
5214 @@ -1045,7 +1045,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5215 return NOTIFY_OK;
5216 }
5217
5218 -static struct notifier_block __refdata palinfo_cpu_notifier =
5219 +static struct notifier_block palinfo_cpu_notifier =
5220 {
5221 .notifier_call = palinfo_cpu_callback,
5222 .priority = 0,
5223 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5224 index 79802e5..1a89ec5 100644
5225 --- a/arch/ia64/kernel/salinfo.c
5226 +++ b/arch/ia64/kernel/salinfo.c
5227 @@ -616,7 +616,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5228 return NOTIFY_OK;
5229 }
5230
5231 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5232 +static struct notifier_block salinfo_cpu_notifier =
5233 {
5234 .notifier_call = salinfo_cpu_callback,
5235 .priority = 0,
5236 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5237 index d9439ef..d0cac6b 100644
5238 --- a/arch/ia64/kernel/sys_ia64.c
5239 +++ b/arch/ia64/kernel/sys_ia64.c
5240 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5241 unsigned long start_addr, align_mask = PAGE_SIZE - 1;
5242 struct mm_struct *mm = current->mm;
5243 struct vm_area_struct *vma;
5244 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5245
5246 if (len > RGN_MAP_LIMIT)
5247 return -ENOMEM;
5248 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5249 if (REGION_NUMBER(addr) == RGN_HPAGE)
5250 addr = 0;
5251 #endif
5252 +
5253 +#ifdef CONFIG_PAX_RANDMMAP
5254 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5255 + addr = mm->free_area_cache;
5256 + else
5257 +#endif
5258 +
5259 if (!addr)
5260 addr = mm->free_area_cache;
5261
5262 @@ -61,14 +69,14 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5263 for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
5264 /* At this point: (!vma || addr < vma->vm_end). */
5265 if (TASK_SIZE - len < addr || RGN_MAP_LIMIT - len < REGION_OFFSET(addr)) {
5266 - if (start_addr != TASK_UNMAPPED_BASE) {
5267 + if (start_addr != mm->mmap_base) {
5268 /* Start a new search --- just in case we missed some holes. */
5269 - addr = TASK_UNMAPPED_BASE;
5270 + addr = mm->mmap_base;
5271 goto full_search;
5272 }
5273 return -ENOMEM;
5274 }
5275 - if (!vma || addr + len <= vma->vm_start) {
5276 + if (check_heap_stack_gap(vma, addr, len, offset)) {
5277 /* Remember the address where we stopped this search: */
5278 mm->free_area_cache = addr + len;
5279 return addr;
5280 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5281 index dc00b2c..cce53c2 100644
5282 --- a/arch/ia64/kernel/topology.c
5283 +++ b/arch/ia64/kernel/topology.c
5284 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5285 return NOTIFY_OK;
5286 }
5287
5288 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5289 +static struct notifier_block cache_cpu_notifier =
5290 {
5291 .notifier_call = cache_cpu_callback
5292 };
5293 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5294 index 0ccb28f..8992469 100644
5295 --- a/arch/ia64/kernel/vmlinux.lds.S
5296 +++ b/arch/ia64/kernel/vmlinux.lds.S
5297 @@ -198,7 +198,7 @@ SECTIONS {
5298 /* Per-cpu data: */
5299 . = ALIGN(PERCPU_PAGE_SIZE);
5300 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5301 - __phys_per_cpu_start = __per_cpu_load;
5302 + __phys_per_cpu_start = per_cpu_load;
5303 /*
5304 * ensure percpu data fits
5305 * into percpu page size
5306 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5307 index 6cf0341..d352594 100644
5308 --- a/arch/ia64/mm/fault.c
5309 +++ b/arch/ia64/mm/fault.c
5310 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5311 return pte_present(pte);
5312 }
5313
5314 +#ifdef CONFIG_PAX_PAGEEXEC
5315 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5316 +{
5317 + unsigned long i;
5318 +
5319 + printk(KERN_ERR "PAX: bytes at PC: ");
5320 + for (i = 0; i < 8; i++) {
5321 + unsigned int c;
5322 + if (get_user(c, (unsigned int *)pc+i))
5323 + printk(KERN_CONT "???????? ");
5324 + else
5325 + printk(KERN_CONT "%08x ", c);
5326 + }
5327 + printk("\n");
5328 +}
5329 +#endif
5330 +
5331 # define VM_READ_BIT 0
5332 # define VM_WRITE_BIT 1
5333 # define VM_EXEC_BIT 2
5334 @@ -149,8 +166,21 @@ retry:
5335 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5336 goto bad_area;
5337
5338 - if ((vma->vm_flags & mask) != mask)
5339 + if ((vma->vm_flags & mask) != mask) {
5340 +
5341 +#ifdef CONFIG_PAX_PAGEEXEC
5342 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5343 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5344 + goto bad_area;
5345 +
5346 + up_read(&mm->mmap_sem);
5347 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5348 + do_group_exit(SIGKILL);
5349 + }
5350 +#endif
5351 +
5352 goto bad_area;
5353 + }
5354
5355 /*
5356 * If for any reason at all we couldn't handle the fault, make
5357 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5358 index 5ca674b..127c3cb 100644
5359 --- a/arch/ia64/mm/hugetlbpage.c
5360 +++ b/arch/ia64/mm/hugetlbpage.c
5361 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5362 unsigned long pgoff, unsigned long flags)
5363 {
5364 struct vm_area_struct *vmm;
5365 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5366
5367 if (len > RGN_MAP_LIMIT)
5368 return -ENOMEM;
5369 @@ -171,7 +172,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5370 /* At this point: (!vmm || addr < vmm->vm_end). */
5371 if (REGION_OFFSET(addr) + len > RGN_MAP_LIMIT)
5372 return -ENOMEM;
5373 - if (!vmm || (addr + len) <= vmm->vm_start)
5374 + if (check_heap_stack_gap(vmm, addr, len, offset))
5375 return addr;
5376 addr = ALIGN(vmm->vm_end, HPAGE_SIZE);
5377 }
5378 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5379 index b755ea9..b9a969e 100644
5380 --- a/arch/ia64/mm/init.c
5381 +++ b/arch/ia64/mm/init.c
5382 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5383 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5384 vma->vm_end = vma->vm_start + PAGE_SIZE;
5385 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5386 +
5387 +#ifdef CONFIG_PAX_PAGEEXEC
5388 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5389 + vma->vm_flags &= ~VM_EXEC;
5390 +
5391 +#ifdef CONFIG_PAX_MPROTECT
5392 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5393 + vma->vm_flags &= ~VM_MAYEXEC;
5394 +#endif
5395 +
5396 + }
5397 +#endif
5398 +
5399 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5400 down_write(&current->mm->mmap_sem);
5401 if (insert_vm_struct(current->mm, vma)) {
5402 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5403 index 40b3ee9..8c2c112 100644
5404 --- a/arch/m32r/include/asm/cache.h
5405 +++ b/arch/m32r/include/asm/cache.h
5406 @@ -1,8 +1,10 @@
5407 #ifndef _ASM_M32R_CACHE_H
5408 #define _ASM_M32R_CACHE_H
5409
5410 +#include <linux/const.h>
5411 +
5412 /* L1 cache line size */
5413 #define L1_CACHE_SHIFT 4
5414 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5415 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5416
5417 #endif /* _ASM_M32R_CACHE_H */
5418 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5419 index 82abd15..d95ae5d 100644
5420 --- a/arch/m32r/lib/usercopy.c
5421 +++ b/arch/m32r/lib/usercopy.c
5422 @@ -14,6 +14,9 @@
5423 unsigned long
5424 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5425 {
5426 + if ((long)n < 0)
5427 + return n;
5428 +
5429 prefetch(from);
5430 if (access_ok(VERIFY_WRITE, to, n))
5431 __copy_user(to,from,n);
5432 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5433 unsigned long
5434 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5435 {
5436 + if ((long)n < 0)
5437 + return n;
5438 +
5439 prefetchw(to);
5440 if (access_ok(VERIFY_READ, from, n))
5441 __copy_user_zeroing(to,from,n);
5442 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5443 index 0395c51..5f26031 100644
5444 --- a/arch/m68k/include/asm/cache.h
5445 +++ b/arch/m68k/include/asm/cache.h
5446 @@ -4,9 +4,11 @@
5447 #ifndef __ARCH_M68K_CACHE_H
5448 #define __ARCH_M68K_CACHE_H
5449
5450 +#include <linux/const.h>
5451 +
5452 /* bytes per L1 cache line */
5453 #define L1_CACHE_SHIFT 4
5454 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5455 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5456
5457 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5458
5459 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5460 index 4efe96a..60e8699 100644
5461 --- a/arch/microblaze/include/asm/cache.h
5462 +++ b/arch/microblaze/include/asm/cache.h
5463 @@ -13,11 +13,12 @@
5464 #ifndef _ASM_MICROBLAZE_CACHE_H
5465 #define _ASM_MICROBLAZE_CACHE_H
5466
5467 +#include <linux/const.h>
5468 #include <asm/registers.h>
5469
5470 #define L1_CACHE_SHIFT 5
5471 /* word-granular cache in microblaze */
5472 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5473 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5474
5475 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5476
5477 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5478 index 01cc6ba..bcb7a5d 100644
5479 --- a/arch/mips/include/asm/atomic.h
5480 +++ b/arch/mips/include/asm/atomic.h
5481 @@ -21,6 +21,10 @@
5482 #include <asm/cmpxchg.h>
5483 #include <asm/war.h>
5484
5485 +#ifdef CONFIG_GENERIC_ATOMIC64
5486 +#include <asm-generic/atomic64.h>
5487 +#endif
5488 +
5489 #define ATOMIC_INIT(i) { (i) }
5490
5491 /*
5492 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5493 */
5494 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5495
5496 +#define atomic64_read_unchecked(v) atomic64_read(v)
5497 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5498 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5499 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5500 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5501 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5502 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5503 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5504 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5505 +
5506 #endif /* CONFIG_64BIT */
5507
5508 /*
5509 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5510 index b4db69f..8f3b093 100644
5511 --- a/arch/mips/include/asm/cache.h
5512 +++ b/arch/mips/include/asm/cache.h
5513 @@ -9,10 +9,11 @@
5514 #ifndef _ASM_CACHE_H
5515 #define _ASM_CACHE_H
5516
5517 +#include <linux/const.h>
5518 #include <kmalloc.h>
5519
5520 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5521 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5522 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5523
5524 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5526 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5527 index 455c0ac..ad65fbe 100644
5528 --- a/arch/mips/include/asm/elf.h
5529 +++ b/arch/mips/include/asm/elf.h
5530 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5531 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5532 #endif
5533
5534 +#ifdef CONFIG_PAX_ASLR
5535 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5536 +
5537 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5538 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5539 +#endif
5540 +
5541 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5542 struct linux_binprm;
5543 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5544 int uses_interp);
5545
5546 -struct mm_struct;
5547 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5548 -#define arch_randomize_brk arch_randomize_brk
5549 -
5550 #endif /* _ASM_ELF_H */
5551 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5552 index c1f6afa..38cc6e9 100644
5553 --- a/arch/mips/include/asm/exec.h
5554 +++ b/arch/mips/include/asm/exec.h
5555 @@ -12,6 +12,6 @@
5556 #ifndef _ASM_EXEC_H
5557 #define _ASM_EXEC_H
5558
5559 -extern unsigned long arch_align_stack(unsigned long sp);
5560 +#define arch_align_stack(x) ((x) & ~0xfUL)
5561
5562 #endif /* _ASM_EXEC_H */
5563 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5564 index dbaec94..6a14935 100644
5565 --- a/arch/mips/include/asm/page.h
5566 +++ b/arch/mips/include/asm/page.h
5567 @@ -96,7 +96,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5568 #ifdef CONFIG_CPU_MIPS32
5569 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5570 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5571 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5572 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5573 #else
5574 typedef struct { unsigned long long pte; } pte_t;
5575 #define pte_val(x) ((x).pte)
5576 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5577 index 881d18b..cea38bc 100644
5578 --- a/arch/mips/include/asm/pgalloc.h
5579 +++ b/arch/mips/include/asm/pgalloc.h
5580 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5581 {
5582 set_pud(pud, __pud((unsigned long)pmd));
5583 }
5584 +
5585 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5586 +{
5587 + pud_populate(mm, pud, pmd);
5588 +}
5589 #endif
5590
5591 /*
5592 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5593 index b2050b9..d71bb1b 100644
5594 --- a/arch/mips/include/asm/thread_info.h
5595 +++ b/arch/mips/include/asm/thread_info.h
5596 @@ -111,6 +111,8 @@ register struct thread_info *__current_thread_info __asm__("$28");
5597 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5598 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5599 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5600 +/* li takes a 32bit immediate */
5601 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5602 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5603
5604 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5605 @@ -126,15 +128,18 @@ register struct thread_info *__current_thread_info __asm__("$28");
5606 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5607 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5608 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5609 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5610 +
5611 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5612
5613 /* work to do in syscall_trace_leave() */
5614 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5615 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5616
5617 /* work to do on interrupt/exception return */
5618 #define _TIF_WORK_MASK \
5619 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5620 /* work to do on any return to u-space */
5621 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5622 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5623
5624 #endif /* __KERNEL__ */
5625
5626 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5627 index 9fdd8bc..4bd7f1a 100644
5628 --- a/arch/mips/kernel/binfmt_elfn32.c
5629 +++ b/arch/mips/kernel/binfmt_elfn32.c
5630 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5631 #undef ELF_ET_DYN_BASE
5632 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5633
5634 +#ifdef CONFIG_PAX_ASLR
5635 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5636 +
5637 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5638 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5639 +#endif
5640 +
5641 #include <asm/processor.h>
5642 #include <linux/module.h>
5643 #include <linux/elfcore.h>
5644 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5645 index ff44823..97f8906 100644
5646 --- a/arch/mips/kernel/binfmt_elfo32.c
5647 +++ b/arch/mips/kernel/binfmt_elfo32.c
5648 @@ -52,6 +52,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5649 #undef ELF_ET_DYN_BASE
5650 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5651
5652 +#ifdef CONFIG_PAX_ASLR
5653 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5654 +
5655 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5656 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5657 +#endif
5658 +
5659 #include <asm/processor.h>
5660
5661 /*
5662 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5663 index a11c6f9..be5e164 100644
5664 --- a/arch/mips/kernel/process.c
5665 +++ b/arch/mips/kernel/process.c
5666 @@ -460,15 +460,3 @@ unsigned long get_wchan(struct task_struct *task)
5667 out:
5668 return pc;
5669 }
5670 -
5671 -/*
5672 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5673 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5674 - */
5675 -unsigned long arch_align_stack(unsigned long sp)
5676 -{
5677 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5678 - sp -= get_random_int() & ~PAGE_MASK;
5679 -
5680 - return sp & ALMASK;
5681 -}
5682 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5683 index 4812c6d..2069554 100644
5684 --- a/arch/mips/kernel/ptrace.c
5685 +++ b/arch/mips/kernel/ptrace.c
5686 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5687 return arch;
5688 }
5689
5690 +#ifdef CONFIG_GRKERNSEC_SETXID
5691 +extern void gr_delayed_cred_worker(void);
5692 +#endif
5693 +
5694 /*
5695 * Notification of system call entry/exit
5696 * - triggered by current->work.syscall_trace
5697 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5698 /* do the secure computing check first */
5699 secure_computing_strict(regs->regs[2]);
5700
5701 +#ifdef CONFIG_GRKERNSEC_SETXID
5702 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5703 + gr_delayed_cred_worker();
5704 +#endif
5705 +
5706 if (!(current->ptrace & PT_PTRACED))
5707 goto out;
5708
5709 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5710 index d20a4bc..7096ae5 100644
5711 --- a/arch/mips/kernel/scall32-o32.S
5712 +++ b/arch/mips/kernel/scall32-o32.S
5713 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5714
5715 stack_done:
5716 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5717 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5718 + li t1, _TIF_SYSCALL_WORK
5719 and t0, t1
5720 bnez t0, syscall_trace_entry # -> yes
5721
5722 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5723 index b64f642..0fe6eab 100644
5724 --- a/arch/mips/kernel/scall64-64.S
5725 +++ b/arch/mips/kernel/scall64-64.S
5726 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5727
5728 sd a3, PT_R26(sp) # save a3 for syscall restarting
5729
5730 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5731 + li t1, _TIF_SYSCALL_WORK
5732 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5733 and t0, t1, t0
5734 bnez t0, syscall_trace_entry
5735 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5736 index c29ac19..c592d05 100644
5737 --- a/arch/mips/kernel/scall64-n32.S
5738 +++ b/arch/mips/kernel/scall64-n32.S
5739 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5740
5741 sd a3, PT_R26(sp) # save a3 for syscall restarting
5742
5743 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5744 + li t1, _TIF_SYSCALL_WORK
5745 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5746 and t0, t1, t0
5747 bnez t0, n32_syscall_trace_entry
5748 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5749 index cf3e75e..72e93fe 100644
5750 --- a/arch/mips/kernel/scall64-o32.S
5751 +++ b/arch/mips/kernel/scall64-o32.S
5752 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5753 PTR 4b, bad_stack
5754 .previous
5755
5756 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5757 + li t1, _TIF_SYSCALL_WORK
5758 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5759 and t0, t1, t0
5760 bnez t0, trace_a_syscall
5761 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5762 index ddcec1e..c7f983e 100644
5763 --- a/arch/mips/mm/fault.c
5764 +++ b/arch/mips/mm/fault.c
5765 @@ -27,6 +27,23 @@
5766 #include <asm/highmem.h> /* For VMALLOC_END */
5767 #include <linux/kdebug.h>
5768
5769 +#ifdef CONFIG_PAX_PAGEEXEC
5770 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5771 +{
5772 + unsigned long i;
5773 +
5774 + printk(KERN_ERR "PAX: bytes at PC: ");
5775 + for (i = 0; i < 5; i++) {
5776 + unsigned int c;
5777 + if (get_user(c, (unsigned int *)pc+i))
5778 + printk(KERN_CONT "???????? ");
5779 + else
5780 + printk(KERN_CONT "%08x ", c);
5781 + }
5782 + printk("\n");
5783 +}
5784 +#endif
5785 +
5786 /*
5787 * This routine handles page faults. It determines the address,
5788 * and the problem, and then passes it off to one of the appropriate
5789 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5790 index 7e5fe27..479a219 100644
5791 --- a/arch/mips/mm/mmap.c
5792 +++ b/arch/mips/mm/mmap.c
5793 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5794 struct vm_area_struct *vma;
5795 unsigned long addr = addr0;
5796 int do_color_align;
5797 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5798 struct vm_unmapped_area_info info;
5799
5800 if (unlikely(len > TASK_SIZE))
5801 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5802 do_color_align = 1;
5803
5804 /* requesting a specific address */
5805 +
5806 +#ifdef CONFIG_PAX_RANDMMAP
5807 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5808 +#endif
5809 +
5810 if (addr) {
5811 if (do_color_align)
5812 addr = COLOUR_ALIGN(addr, pgoff);
5813 @@ -91,8 +97,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5814 addr = PAGE_ALIGN(addr);
5815
5816 vma = find_vma(mm, addr);
5817 - if (TASK_SIZE - len >= addr &&
5818 - (!vma || addr + len <= vma->vm_start))
5819 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5820 return addr;
5821 }
5822
5823 @@ -146,6 +151,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5824 {
5825 unsigned long random_factor = 0UL;
5826
5827 +#ifdef CONFIG_PAX_RANDMMAP
5828 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5829 +#endif
5830 +
5831 if (current->flags & PF_RANDOMIZE) {
5832 random_factor = get_random_int();
5833 random_factor = random_factor << PAGE_SHIFT;
5834 @@ -157,42 +166,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5835
5836 if (mmap_is_legacy()) {
5837 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5838 +
5839 +#ifdef CONFIG_PAX_RANDMMAP
5840 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5841 + mm->mmap_base += mm->delta_mmap;
5842 +#endif
5843 +
5844 mm->get_unmapped_area = arch_get_unmapped_area;
5845 mm->unmap_area = arch_unmap_area;
5846 } else {
5847 mm->mmap_base = mmap_base(random_factor);
5848 +
5849 +#ifdef CONFIG_PAX_RANDMMAP
5850 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5851 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5852 +#endif
5853 +
5854 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5855 mm->unmap_area = arch_unmap_area_topdown;
5856 }
5857 }
5858
5859 -static inline unsigned long brk_rnd(void)
5860 -{
5861 - unsigned long rnd = get_random_int();
5862 -
5863 - rnd = rnd << PAGE_SHIFT;
5864 - /* 8MB for 32bit, 256MB for 64bit */
5865 - if (TASK_IS_32BIT_ADDR)
5866 - rnd = rnd & 0x7ffffful;
5867 - else
5868 - rnd = rnd & 0xffffffful;
5869 -
5870 - return rnd;
5871 -}
5872 -
5873 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5874 -{
5875 - unsigned long base = mm->brk;
5876 - unsigned long ret;
5877 -
5878 - ret = PAGE_ALIGN(base + brk_rnd());
5879 -
5880 - if (ret < mm->brk)
5881 - return mm->brk;
5882 -
5883 - return ret;
5884 -}
5885 -
5886 int __virt_addr_valid(const volatile void *kaddr)
5887 {
5888 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5889 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5890 index 967d144..db12197 100644
5891 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5892 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5893 @@ -11,12 +11,14 @@
5894 #ifndef _ASM_PROC_CACHE_H
5895 #define _ASM_PROC_CACHE_H
5896
5897 +#include <linux/const.h>
5898 +
5899 /* L1 cache */
5900
5901 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5902 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5903 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5904 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5905 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5906 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5907
5908 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5909 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5910 index bcb5df2..84fabd2 100644
5911 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5912 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5913 @@ -16,13 +16,15 @@
5914 #ifndef _ASM_PROC_CACHE_H
5915 #define _ASM_PROC_CACHE_H
5916
5917 +#include <linux/const.h>
5918 +
5919 /*
5920 * L1 cache
5921 */
5922 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5923 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5924 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5925 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5926 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5927 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5928
5929 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5930 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5931 index 4ce7a01..449202a 100644
5932 --- a/arch/openrisc/include/asm/cache.h
5933 +++ b/arch/openrisc/include/asm/cache.h
5934 @@ -19,11 +19,13 @@
5935 #ifndef __ASM_OPENRISC_CACHE_H
5936 #define __ASM_OPENRISC_CACHE_H
5937
5938 +#include <linux/const.h>
5939 +
5940 /* FIXME: How can we replace these with values from the CPU...
5941 * they shouldn't be hard-coded!
5942 */
5943
5944 -#define L1_CACHE_BYTES 16
5945 #define L1_CACHE_SHIFT 4
5946 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5947
5948 #endif /* __ASM_OPENRISC_CACHE_H */
5949 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5950 index af9cf30..2aae9b2 100644
5951 --- a/arch/parisc/include/asm/atomic.h
5952 +++ b/arch/parisc/include/asm/atomic.h
5953 @@ -229,6 +229,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5954
5955 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
5956
5957 +#define atomic64_read_unchecked(v) atomic64_read(v)
5958 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5959 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5960 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5961 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5962 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5963 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5964 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5965 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5966 +
5967 #endif /* !CONFIG_64BIT */
5968
5969
5970 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5971 index 47f11c7..3420df2 100644
5972 --- a/arch/parisc/include/asm/cache.h
5973 +++ b/arch/parisc/include/asm/cache.h
5974 @@ -5,6 +5,7 @@
5975 #ifndef __ARCH_PARISC_CACHE_H
5976 #define __ARCH_PARISC_CACHE_H
5977
5978 +#include <linux/const.h>
5979
5980 /*
5981 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5982 @@ -15,13 +16,13 @@
5983 * just ruin performance.
5984 */
5985 #ifdef CONFIG_PA20
5986 -#define L1_CACHE_BYTES 64
5987 #define L1_CACHE_SHIFT 6
5988 #else
5989 -#define L1_CACHE_BYTES 32
5990 #define L1_CACHE_SHIFT 5
5991 #endif
5992
5993 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5994 +
5995 #ifndef __ASSEMBLY__
5996
5997 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5998 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5999 index 19f6cb1..6c78cf2 100644
6000 --- a/arch/parisc/include/asm/elf.h
6001 +++ b/arch/parisc/include/asm/elf.h
6002 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
6003
6004 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
6005
6006 +#ifdef CONFIG_PAX_ASLR
6007 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
6008 +
6009 +#define PAX_DELTA_MMAP_LEN 16
6010 +#define PAX_DELTA_STACK_LEN 16
6011 +#endif
6012 +
6013 /* This yields a mask that user programs can use to figure out what
6014 instruction set this CPU supports. This could be done in user space,
6015 but it's not easy, and we've already done it here. */
6016 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6017 index fc987a1..6e068ef 100644
6018 --- a/arch/parisc/include/asm/pgalloc.h
6019 +++ b/arch/parisc/include/asm/pgalloc.h
6020 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6021 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6022 }
6023
6024 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6025 +{
6026 + pgd_populate(mm, pgd, pmd);
6027 +}
6028 +
6029 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6030 {
6031 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6032 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6033 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6034 #define pmd_free(mm, x) do { } while (0)
6035 #define pgd_populate(mm, pmd, pte) BUG()
6036 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6037
6038 #endif
6039
6040 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6041 index 7df49fa..38b62bf 100644
6042 --- a/arch/parisc/include/asm/pgtable.h
6043 +++ b/arch/parisc/include/asm/pgtable.h
6044 @@ -218,6 +218,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6045 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6046 #define PAGE_COPY PAGE_EXECREAD
6047 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6048 +
6049 +#ifdef CONFIG_PAX_PAGEEXEC
6050 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6051 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6052 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6053 +#else
6054 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6055 +# define PAGE_COPY_NOEXEC PAGE_COPY
6056 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6057 +#endif
6058 +
6059 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6060 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6061 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6062 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6063 index 4ba2c93..f5e3974 100644
6064 --- a/arch/parisc/include/asm/uaccess.h
6065 +++ b/arch/parisc/include/asm/uaccess.h
6066 @@ -251,10 +251,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6067 const void __user *from,
6068 unsigned long n)
6069 {
6070 - int sz = __compiletime_object_size(to);
6071 + size_t sz = __compiletime_object_size(to);
6072 int ret = -EFAULT;
6073
6074 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6075 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6076 ret = __copy_from_user(to, from, n);
6077 else
6078 copy_from_user_overflow();
6079 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6080 index 2a625fb..9908930 100644
6081 --- a/arch/parisc/kernel/module.c
6082 +++ b/arch/parisc/kernel/module.c
6083 @@ -98,16 +98,38 @@
6084
6085 /* three functions to determine where in the module core
6086 * or init pieces the location is */
6087 +static inline int in_init_rx(struct module *me, void *loc)
6088 +{
6089 + return (loc >= me->module_init_rx &&
6090 + loc < (me->module_init_rx + me->init_size_rx));
6091 +}
6092 +
6093 +static inline int in_init_rw(struct module *me, void *loc)
6094 +{
6095 + return (loc >= me->module_init_rw &&
6096 + loc < (me->module_init_rw + me->init_size_rw));
6097 +}
6098 +
6099 static inline int in_init(struct module *me, void *loc)
6100 {
6101 - return (loc >= me->module_init &&
6102 - loc <= (me->module_init + me->init_size));
6103 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6104 +}
6105 +
6106 +static inline int in_core_rx(struct module *me, void *loc)
6107 +{
6108 + return (loc >= me->module_core_rx &&
6109 + loc < (me->module_core_rx + me->core_size_rx));
6110 +}
6111 +
6112 +static inline int in_core_rw(struct module *me, void *loc)
6113 +{
6114 + return (loc >= me->module_core_rw &&
6115 + loc < (me->module_core_rw + me->core_size_rw));
6116 }
6117
6118 static inline int in_core(struct module *me, void *loc)
6119 {
6120 - return (loc >= me->module_core &&
6121 - loc <= (me->module_core + me->core_size));
6122 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6123 }
6124
6125 static inline int in_local(struct module *me, void *loc)
6126 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6127 }
6128
6129 /* align things a bit */
6130 - me->core_size = ALIGN(me->core_size, 16);
6131 - me->arch.got_offset = me->core_size;
6132 - me->core_size += gots * sizeof(struct got_entry);
6133 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6134 + me->arch.got_offset = me->core_size_rw;
6135 + me->core_size_rw += gots * sizeof(struct got_entry);
6136
6137 - me->core_size = ALIGN(me->core_size, 16);
6138 - me->arch.fdesc_offset = me->core_size;
6139 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6140 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6141 + me->arch.fdesc_offset = me->core_size_rw;
6142 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6143
6144 me->arch.got_max = gots;
6145 me->arch.fdesc_max = fdescs;
6146 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6147
6148 BUG_ON(value == 0);
6149
6150 - got = me->module_core + me->arch.got_offset;
6151 + got = me->module_core_rw + me->arch.got_offset;
6152 for (i = 0; got[i].addr; i++)
6153 if (got[i].addr == value)
6154 goto out;
6155 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6156 #ifdef CONFIG_64BIT
6157 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6158 {
6159 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6160 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6161
6162 if (!value) {
6163 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6164 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6165
6166 /* Create new one */
6167 fdesc->addr = value;
6168 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6169 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6170 return (Elf_Addr)fdesc;
6171 }
6172 #endif /* CONFIG_64BIT */
6173 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6174
6175 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6176 end = table + sechdrs[me->arch.unwind_section].sh_size;
6177 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6178 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6179
6180 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6181 me->arch.unwind_section, table, end, gp);
6182 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6183 index f76c108..92bad82 100644
6184 --- a/arch/parisc/kernel/sys_parisc.c
6185 +++ b/arch/parisc/kernel/sys_parisc.c
6186 @@ -33,9 +33,11 @@
6187 #include <linux/utsname.h>
6188 #include <linux/personality.h>
6189
6190 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6191 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6192 + unsigned long flags)
6193 {
6194 struct vm_area_struct *vma;
6195 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6196
6197 addr = PAGE_ALIGN(addr);
6198
6199 @@ -43,7 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6200 /* At this point: (!vma || addr < vma->vm_end). */
6201 if (TASK_SIZE - len < addr)
6202 return -ENOMEM;
6203 - if (!vma || addr + len <= vma->vm_start)
6204 + if (check_heap_stack_gap(vma, addr, len, offset))
6205 return addr;
6206 addr = vma->vm_end;
6207 }
6208 @@ -67,11 +69,12 @@ static int get_offset(struct address_space *mapping)
6209 return offset & 0x3FF000;
6210 }
6211
6212 -static unsigned long get_shared_area(struct address_space *mapping,
6213 - unsigned long addr, unsigned long len, unsigned long pgoff)
6214 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6215 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6216 {
6217 struct vm_area_struct *vma;
6218 int offset = mapping ? get_offset(mapping) : 0;
6219 + unsigned long rand_offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6220
6221 offset = (offset + (pgoff << PAGE_SHIFT)) & 0x3FF000;
6222
6223 @@ -81,7 +84,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6224 /* At this point: (!vma || addr < vma->vm_end). */
6225 if (TASK_SIZE - len < addr)
6226 return -ENOMEM;
6227 - if (!vma || addr + len <= vma->vm_start)
6228 + if (check_heap_stack_gap(vma, addr, len, rand_offset))
6229 return addr;
6230 addr = DCACHE_ALIGN(vma->vm_end - offset) + offset;
6231 if (addr < vma->vm_end) /* handle wraparound */
6232 @@ -100,14 +103,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6233 if (flags & MAP_FIXED)
6234 return addr;
6235 if (!addr)
6236 - addr = TASK_UNMAPPED_BASE;
6237 + addr = current->mm->mmap_base;
6238
6239 if (filp) {
6240 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6241 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6242 } else if(flags & MAP_SHARED) {
6243 - addr = get_shared_area(NULL, addr, len, pgoff);
6244 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6245 } else {
6246 - addr = get_unshared_area(addr, len);
6247 + addr = get_unshared_area(filp, addr, len, flags);
6248 }
6249 return addr;
6250 }
6251 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6252 index 45ba99f..8e22c33 100644
6253 --- a/arch/parisc/kernel/traps.c
6254 +++ b/arch/parisc/kernel/traps.c
6255 @@ -732,9 +732,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6256
6257 down_read(&current->mm->mmap_sem);
6258 vma = find_vma(current->mm,regs->iaoq[0]);
6259 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6260 - && (vma->vm_flags & VM_EXEC)) {
6261 -
6262 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6263 fault_address = regs->iaoq[0];
6264 fault_space = regs->iasq[0];
6265
6266 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6267 index 18162ce..94de376 100644
6268 --- a/arch/parisc/mm/fault.c
6269 +++ b/arch/parisc/mm/fault.c
6270 @@ -15,6 +15,7 @@
6271 #include <linux/sched.h>
6272 #include <linux/interrupt.h>
6273 #include <linux/module.h>
6274 +#include <linux/unistd.h>
6275
6276 #include <asm/uaccess.h>
6277 #include <asm/traps.h>
6278 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6279 static unsigned long
6280 parisc_acctyp(unsigned long code, unsigned int inst)
6281 {
6282 - if (code == 6 || code == 16)
6283 + if (code == 6 || code == 7 || code == 16)
6284 return VM_EXEC;
6285
6286 switch (inst & 0xf0000000) {
6287 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6288 }
6289 #endif
6290
6291 +#ifdef CONFIG_PAX_PAGEEXEC
6292 +/*
6293 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6294 + *
6295 + * returns 1 when task should be killed
6296 + * 2 when rt_sigreturn trampoline was detected
6297 + * 3 when unpatched PLT trampoline was detected
6298 + */
6299 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6300 +{
6301 +
6302 +#ifdef CONFIG_PAX_EMUPLT
6303 + int err;
6304 +
6305 + do { /* PaX: unpatched PLT emulation */
6306 + unsigned int bl, depwi;
6307 +
6308 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6309 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6310 +
6311 + if (err)
6312 + break;
6313 +
6314 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6315 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6316 +
6317 + err = get_user(ldw, (unsigned int *)addr);
6318 + err |= get_user(bv, (unsigned int *)(addr+4));
6319 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6320 +
6321 + if (err)
6322 + break;
6323 +
6324 + if (ldw == 0x0E801096U &&
6325 + bv == 0xEAC0C000U &&
6326 + ldw2 == 0x0E881095U)
6327 + {
6328 + unsigned int resolver, map;
6329 +
6330 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6331 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6332 + if (err)
6333 + break;
6334 +
6335 + regs->gr[20] = instruction_pointer(regs)+8;
6336 + regs->gr[21] = map;
6337 + regs->gr[22] = resolver;
6338 + regs->iaoq[0] = resolver | 3UL;
6339 + regs->iaoq[1] = regs->iaoq[0] + 4;
6340 + return 3;
6341 + }
6342 + }
6343 + } while (0);
6344 +#endif
6345 +
6346 +#ifdef CONFIG_PAX_EMUTRAMP
6347 +
6348 +#ifndef CONFIG_PAX_EMUSIGRT
6349 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6350 + return 1;
6351 +#endif
6352 +
6353 + do { /* PaX: rt_sigreturn emulation */
6354 + unsigned int ldi1, ldi2, bel, nop;
6355 +
6356 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6357 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6358 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6359 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6360 +
6361 + if (err)
6362 + break;
6363 +
6364 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6365 + ldi2 == 0x3414015AU &&
6366 + bel == 0xE4008200U &&
6367 + nop == 0x08000240U)
6368 + {
6369 + regs->gr[25] = (ldi1 & 2) >> 1;
6370 + regs->gr[20] = __NR_rt_sigreturn;
6371 + regs->gr[31] = regs->iaoq[1] + 16;
6372 + regs->sr[0] = regs->iasq[1];
6373 + regs->iaoq[0] = 0x100UL;
6374 + regs->iaoq[1] = regs->iaoq[0] + 4;
6375 + regs->iasq[0] = regs->sr[2];
6376 + regs->iasq[1] = regs->sr[2];
6377 + return 2;
6378 + }
6379 + } while (0);
6380 +#endif
6381 +
6382 + return 1;
6383 +}
6384 +
6385 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6386 +{
6387 + unsigned long i;
6388 +
6389 + printk(KERN_ERR "PAX: bytes at PC: ");
6390 + for (i = 0; i < 5; i++) {
6391 + unsigned int c;
6392 + if (get_user(c, (unsigned int *)pc+i))
6393 + printk(KERN_CONT "???????? ");
6394 + else
6395 + printk(KERN_CONT "%08x ", c);
6396 + }
6397 + printk("\n");
6398 +}
6399 +#endif
6400 +
6401 int fixup_exception(struct pt_regs *regs)
6402 {
6403 const struct exception_table_entry *fix;
6404 @@ -192,8 +303,33 @@ good_area:
6405
6406 acc_type = parisc_acctyp(code,regs->iir);
6407
6408 - if ((vma->vm_flags & acc_type) != acc_type)
6409 + if ((vma->vm_flags & acc_type) != acc_type) {
6410 +
6411 +#ifdef CONFIG_PAX_PAGEEXEC
6412 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6413 + (address & ~3UL) == instruction_pointer(regs))
6414 + {
6415 + up_read(&mm->mmap_sem);
6416 + switch (pax_handle_fetch_fault(regs)) {
6417 +
6418 +#ifdef CONFIG_PAX_EMUPLT
6419 + case 3:
6420 + return;
6421 +#endif
6422 +
6423 +#ifdef CONFIG_PAX_EMUTRAMP
6424 + case 2:
6425 + return;
6426 +#endif
6427 +
6428 + }
6429 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6430 + do_group_exit(SIGKILL);
6431 + }
6432 +#endif
6433 +
6434 goto bad_area;
6435 + }
6436
6437 /*
6438 * If for any reason at all we couldn't handle the fault, make
6439 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6440 index e3b1d41..8e81edf 100644
6441 --- a/arch/powerpc/include/asm/atomic.h
6442 +++ b/arch/powerpc/include/asm/atomic.h
6443 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6444 return t1;
6445 }
6446
6447 +#define atomic64_read_unchecked(v) atomic64_read(v)
6448 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6449 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6450 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6451 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6452 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6453 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6454 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6455 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6456 +
6457 #endif /* __powerpc64__ */
6458
6459 #endif /* __KERNEL__ */
6460 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6461 index 9e495c9..b6878e5 100644
6462 --- a/arch/powerpc/include/asm/cache.h
6463 +++ b/arch/powerpc/include/asm/cache.h
6464 @@ -3,6 +3,7 @@
6465
6466 #ifdef __KERNEL__
6467
6468 +#include <linux/const.h>
6469
6470 /* bytes per L1 cache line */
6471 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6472 @@ -22,7 +23,7 @@
6473 #define L1_CACHE_SHIFT 7
6474 #endif
6475
6476 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6477 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6478
6479 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6480
6481 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6482 index 6abf0a1..459d0f1 100644
6483 --- a/arch/powerpc/include/asm/elf.h
6484 +++ b/arch/powerpc/include/asm/elf.h
6485 @@ -28,8 +28,19 @@
6486 the loader. We need to make sure that it is out of the way of the program
6487 that it will "exec", and that there is sufficient room for the brk. */
6488
6489 -extern unsigned long randomize_et_dyn(unsigned long base);
6490 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6491 +#define ELF_ET_DYN_BASE (0x20000000)
6492 +
6493 +#ifdef CONFIG_PAX_ASLR
6494 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6495 +
6496 +#ifdef __powerpc64__
6497 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6498 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6499 +#else
6500 +#define PAX_DELTA_MMAP_LEN 15
6501 +#define PAX_DELTA_STACK_LEN 15
6502 +#endif
6503 +#endif
6504
6505 /*
6506 * Our registers are always unsigned longs, whether we're a 32 bit
6507 @@ -124,10 +135,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6508 (0x7ff >> (PAGE_SHIFT - 12)) : \
6509 (0x3ffff >> (PAGE_SHIFT - 12)))
6510
6511 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6512 -#define arch_randomize_brk arch_randomize_brk
6513 -
6514 -
6515 #ifdef CONFIG_SPU_BASE
6516 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6517 #define NT_SPU 1
6518 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6519 index 8196e9c..d83a9f3 100644
6520 --- a/arch/powerpc/include/asm/exec.h
6521 +++ b/arch/powerpc/include/asm/exec.h
6522 @@ -4,6 +4,6 @@
6523 #ifndef _ASM_POWERPC_EXEC_H
6524 #define _ASM_POWERPC_EXEC_H
6525
6526 -extern unsigned long arch_align_stack(unsigned long sp);
6527 +#define arch_align_stack(x) ((x) & ~0xfUL)
6528
6529 #endif /* _ASM_POWERPC_EXEC_H */
6530 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6531 index 5acabbd..7ea14fa 100644
6532 --- a/arch/powerpc/include/asm/kmap_types.h
6533 +++ b/arch/powerpc/include/asm/kmap_types.h
6534 @@ -10,7 +10,7 @@
6535 * 2 of the License, or (at your option) any later version.
6536 */
6537
6538 -#define KM_TYPE_NR 16
6539 +#define KM_TYPE_NR 17
6540
6541 #endif /* __KERNEL__ */
6542 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6543 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6544 index 8565c25..2865190 100644
6545 --- a/arch/powerpc/include/asm/mman.h
6546 +++ b/arch/powerpc/include/asm/mman.h
6547 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6548 }
6549 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6550
6551 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6552 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6553 {
6554 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6555 }
6556 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6557 index f072e97..b436dee 100644
6558 --- a/arch/powerpc/include/asm/page.h
6559 +++ b/arch/powerpc/include/asm/page.h
6560 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6561 * and needs to be executable. This means the whole heap ends
6562 * up being executable.
6563 */
6564 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6565 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6566 +#define VM_DATA_DEFAULT_FLAGS32 \
6567 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6568 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6569
6570 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6571 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6572 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6573 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6574 #endif
6575
6576 +#define ktla_ktva(addr) (addr)
6577 +#define ktva_ktla(addr) (addr)
6578 +
6579 /*
6580 * Use the top bit of the higher-level page table entries to indicate whether
6581 * the entries we point to contain hugepages. This works because we know that
6582 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6583 index cd915d6..c10cee8 100644
6584 --- a/arch/powerpc/include/asm/page_64.h
6585 +++ b/arch/powerpc/include/asm/page_64.h
6586 @@ -154,15 +154,18 @@ do { \
6587 * stack by default, so in the absence of a PT_GNU_STACK program header
6588 * we turn execute permission off.
6589 */
6590 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6591 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6592 +#define VM_STACK_DEFAULT_FLAGS32 \
6593 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6594 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6595
6596 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6597 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6598
6599 +#ifndef CONFIG_PAX_PAGEEXEC
6600 #define VM_STACK_DEFAULT_FLAGS \
6601 (is_32bit_task() ? \
6602 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6603 +#endif
6604
6605 #include <asm-generic/getorder.h>
6606
6607 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6608 index 292725c..f87ae14 100644
6609 --- a/arch/powerpc/include/asm/pgalloc-64.h
6610 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6611 @@ -50,6 +50,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6612 #ifndef CONFIG_PPC_64K_PAGES
6613
6614 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6615 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6616
6617 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6618 {
6619 @@ -67,6 +68,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6620 pud_set(pud, (unsigned long)pmd);
6621 }
6622
6623 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6624 +{
6625 + pud_populate(mm, pud, pmd);
6626 +}
6627 +
6628 #define pmd_populate(mm, pmd, pte_page) \
6629 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6630 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6631 @@ -76,6 +82,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6632 #else /* CONFIG_PPC_64K_PAGES */
6633
6634 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6635 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6636
6637 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6638 pte_t *pte)
6639 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6640 index a9cbd3b..3b67efa 100644
6641 --- a/arch/powerpc/include/asm/pgtable.h
6642 +++ b/arch/powerpc/include/asm/pgtable.h
6643 @@ -2,6 +2,7 @@
6644 #define _ASM_POWERPC_PGTABLE_H
6645 #ifdef __KERNEL__
6646
6647 +#include <linux/const.h>
6648 #ifndef __ASSEMBLY__
6649 #include <asm/processor.h> /* For TASK_SIZE */
6650 #include <asm/mmu.h>
6651 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6652 index 4aad413..85d86bf 100644
6653 --- a/arch/powerpc/include/asm/pte-hash32.h
6654 +++ b/arch/powerpc/include/asm/pte-hash32.h
6655 @@ -21,6 +21,7 @@
6656 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6657 #define _PAGE_USER 0x004 /* usermode access allowed */
6658 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6659 +#define _PAGE_EXEC _PAGE_GUARDED
6660 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6661 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6662 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6663 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6664 index 3d5c9dc..62f8414 100644
6665 --- a/arch/powerpc/include/asm/reg.h
6666 +++ b/arch/powerpc/include/asm/reg.h
6667 @@ -215,6 +215,7 @@
6668 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6669 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6670 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6671 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6672 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6673 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6674 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6675 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6676 index 195ce2a..ab5c614 100644
6677 --- a/arch/powerpc/include/asm/smp.h
6678 +++ b/arch/powerpc/include/asm/smp.h
6679 @@ -50,7 +50,7 @@ struct smp_ops_t {
6680 int (*cpu_disable)(void);
6681 void (*cpu_die)(unsigned int nr);
6682 int (*cpu_bootable)(unsigned int nr);
6683 -};
6684 +} __no_const;
6685
6686 extern void smp_send_debugger_break(void);
6687 extern void start_secondary_resume(void);
6688 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6689 index 406b7b9..af63426 100644
6690 --- a/arch/powerpc/include/asm/thread_info.h
6691 +++ b/arch/powerpc/include/asm/thread_info.h
6692 @@ -97,7 +97,6 @@ static inline struct thread_info *current_thread_info(void)
6693 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6694 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6695 #define TIF_SINGLESTEP 8 /* singlestepping active */
6696 -#define TIF_MEMDIE 9 /* is terminating due to OOM killer */
6697 #define TIF_SECCOMP 10 /* secure computing */
6698 #define TIF_RESTOREALL 11 /* Restore all regs (implies NOERROR) */
6699 #define TIF_NOERROR 12 /* Force successful syscall return */
6700 @@ -106,6 +105,9 @@ static inline struct thread_info *current_thread_info(void)
6701 #define TIF_SYSCALL_TRACEPOINT 15 /* syscall tracepoint instrumentation */
6702 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6703 for stack store? */
6704 +#define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6705 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6706 +#define TIF_GRSEC_SETXID 9 /* update credentials on syscall entry/exit */
6707
6708 /* as above, but as bit values */
6709 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6710 @@ -124,8 +126,10 @@ static inline struct thread_info *current_thread_info(void)
6711 #define _TIF_UPROBE (1<<TIF_UPROBE)
6712 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6713 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6714 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6715 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6716 - _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT)
6717 + _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6718 + _TIF_GRSEC_SETXID)
6719
6720 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6721 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6722 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6723 index 4db4959..aba5c41 100644
6724 --- a/arch/powerpc/include/asm/uaccess.h
6725 +++ b/arch/powerpc/include/asm/uaccess.h
6726 @@ -318,52 +318,6 @@ do { \
6727 extern unsigned long __copy_tofrom_user(void __user *to,
6728 const void __user *from, unsigned long size);
6729
6730 -#ifndef __powerpc64__
6731 -
6732 -static inline unsigned long copy_from_user(void *to,
6733 - const void __user *from, unsigned long n)
6734 -{
6735 - unsigned long over;
6736 -
6737 - if (access_ok(VERIFY_READ, from, n))
6738 - return __copy_tofrom_user((__force void __user *)to, from, n);
6739 - if ((unsigned long)from < TASK_SIZE) {
6740 - over = (unsigned long)from + n - TASK_SIZE;
6741 - return __copy_tofrom_user((__force void __user *)to, from,
6742 - n - over) + over;
6743 - }
6744 - return n;
6745 -}
6746 -
6747 -static inline unsigned long copy_to_user(void __user *to,
6748 - const void *from, unsigned long n)
6749 -{
6750 - unsigned long over;
6751 -
6752 - if (access_ok(VERIFY_WRITE, to, n))
6753 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6754 - if ((unsigned long)to < TASK_SIZE) {
6755 - over = (unsigned long)to + n - TASK_SIZE;
6756 - return __copy_tofrom_user(to, (__force void __user *)from,
6757 - n - over) + over;
6758 - }
6759 - return n;
6760 -}
6761 -
6762 -#else /* __powerpc64__ */
6763 -
6764 -#define __copy_in_user(to, from, size) \
6765 - __copy_tofrom_user((to), (from), (size))
6766 -
6767 -extern unsigned long copy_from_user(void *to, const void __user *from,
6768 - unsigned long n);
6769 -extern unsigned long copy_to_user(void __user *to, const void *from,
6770 - unsigned long n);
6771 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6772 - unsigned long n);
6773 -
6774 -#endif /* __powerpc64__ */
6775 -
6776 static inline unsigned long __copy_from_user_inatomic(void *to,
6777 const void __user *from, unsigned long n)
6778 {
6779 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6780 if (ret == 0)
6781 return 0;
6782 }
6783 +
6784 + if (!__builtin_constant_p(n))
6785 + check_object_size(to, n, false);
6786 +
6787 return __copy_tofrom_user((__force void __user *)to, from, n);
6788 }
6789
6790 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6791 if (ret == 0)
6792 return 0;
6793 }
6794 +
6795 + if (!__builtin_constant_p(n))
6796 + check_object_size(from, n, true);
6797 +
6798 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6799 }
6800
6801 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6802 return __copy_to_user_inatomic(to, from, size);
6803 }
6804
6805 +#ifndef __powerpc64__
6806 +
6807 +static inline unsigned long __must_check copy_from_user(void *to,
6808 + const void __user *from, unsigned long n)
6809 +{
6810 + unsigned long over;
6811 +
6812 + if ((long)n < 0)
6813 + return n;
6814 +
6815 + if (access_ok(VERIFY_READ, from, n)) {
6816 + if (!__builtin_constant_p(n))
6817 + check_object_size(to, n, false);
6818 + return __copy_tofrom_user((__force void __user *)to, from, n);
6819 + }
6820 + if ((unsigned long)from < TASK_SIZE) {
6821 + over = (unsigned long)from + n - TASK_SIZE;
6822 + if (!__builtin_constant_p(n - over))
6823 + check_object_size(to, n - over, false);
6824 + return __copy_tofrom_user((__force void __user *)to, from,
6825 + n - over) + over;
6826 + }
6827 + return n;
6828 +}
6829 +
6830 +static inline unsigned long __must_check copy_to_user(void __user *to,
6831 + const void *from, unsigned long n)
6832 +{
6833 + unsigned long over;
6834 +
6835 + if ((long)n < 0)
6836 + return n;
6837 +
6838 + if (access_ok(VERIFY_WRITE, to, n)) {
6839 + if (!__builtin_constant_p(n))
6840 + check_object_size(from, n, true);
6841 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6842 + }
6843 + if ((unsigned long)to < TASK_SIZE) {
6844 + over = (unsigned long)to + n - TASK_SIZE;
6845 + if (!__builtin_constant_p(n))
6846 + check_object_size(from, n - over, true);
6847 + return __copy_tofrom_user(to, (__force void __user *)from,
6848 + n - over) + over;
6849 + }
6850 + return n;
6851 +}
6852 +
6853 +#else /* __powerpc64__ */
6854 +
6855 +#define __copy_in_user(to, from, size) \
6856 + __copy_tofrom_user((to), (from), (size))
6857 +
6858 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6859 +{
6860 + if ((long)n < 0 || n > INT_MAX)
6861 + return n;
6862 +
6863 + if (!__builtin_constant_p(n))
6864 + check_object_size(to, n, false);
6865 +
6866 + if (likely(access_ok(VERIFY_READ, from, n)))
6867 + n = __copy_from_user(to, from, n);
6868 + else
6869 + memset(to, 0, n);
6870 + return n;
6871 +}
6872 +
6873 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6874 +{
6875 + if ((long)n < 0 || n > INT_MAX)
6876 + return n;
6877 +
6878 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6879 + if (!__builtin_constant_p(n))
6880 + check_object_size(from, n, true);
6881 + n = __copy_to_user(to, from, n);
6882 + }
6883 + return n;
6884 +}
6885 +
6886 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6887 + unsigned long n);
6888 +
6889 +#endif /* __powerpc64__ */
6890 +
6891 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6892
6893 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6894 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6895 index 4684e33..acc4d19e 100644
6896 --- a/arch/powerpc/kernel/exceptions-64e.S
6897 +++ b/arch/powerpc/kernel/exceptions-64e.S
6898 @@ -715,6 +715,7 @@ storage_fault_common:
6899 std r14,_DAR(r1)
6900 std r15,_DSISR(r1)
6901 addi r3,r1,STACK_FRAME_OVERHEAD
6902 + bl .save_nvgprs
6903 mr r4,r14
6904 mr r5,r15
6905 ld r14,PACA_EXGEN+EX_R14(r13)
6906 @@ -723,8 +724,7 @@ storage_fault_common:
6907 cmpdi r3,0
6908 bne- 1f
6909 b .ret_from_except_lite
6910 -1: bl .save_nvgprs
6911 - mr r5,r3
6912 +1: mr r5,r3
6913 addi r3,r1,STACK_FRAME_OVERHEAD
6914 ld r4,_DAR(r1)
6915 bl .bad_page_fault
6916 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6917 index 3684cbd..bc89eab 100644
6918 --- a/arch/powerpc/kernel/exceptions-64s.S
6919 +++ b/arch/powerpc/kernel/exceptions-64s.S
6920 @@ -1206,10 +1206,10 @@ handle_page_fault:
6921 11: ld r4,_DAR(r1)
6922 ld r5,_DSISR(r1)
6923 addi r3,r1,STACK_FRAME_OVERHEAD
6924 + bl .save_nvgprs
6925 bl .do_page_fault
6926 cmpdi r3,0
6927 beq+ 12f
6928 - bl .save_nvgprs
6929 mr r5,r3
6930 addi r3,r1,STACK_FRAME_OVERHEAD
6931 lwz r4,_DAR(r1)
6932 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6933 index 2e3200c..72095ce 100644
6934 --- a/arch/powerpc/kernel/module_32.c
6935 +++ b/arch/powerpc/kernel/module_32.c
6936 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6937 me->arch.core_plt_section = i;
6938 }
6939 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6940 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6941 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6942 return -ENOEXEC;
6943 }
6944
6945 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6946
6947 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6948 /* Init, or core PLT? */
6949 - if (location >= mod->module_core
6950 - && location < mod->module_core + mod->core_size)
6951 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6952 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6953 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6954 - else
6955 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6956 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6957 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6958 + else {
6959 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6960 + return ~0UL;
6961 + }
6962
6963 /* Find this entry, or if that fails, the next avail. entry */
6964 while (entry->jump[0]) {
6965 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6966 index 8143067..21ae55b 100644
6967 --- a/arch/powerpc/kernel/process.c
6968 +++ b/arch/powerpc/kernel/process.c
6969 @@ -680,8 +680,8 @@ void show_regs(struct pt_regs * regs)
6970 * Lookup NIP late so we have the best change of getting the
6971 * above info out without failing
6972 */
6973 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6974 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6975 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6976 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6977 #endif
6978 show_stack(current, (unsigned long *) regs->gpr[1]);
6979 if (!user_mode(regs))
6980 @@ -1129,10 +1129,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6981 newsp = stack[0];
6982 ip = stack[STACK_FRAME_LR_SAVE];
6983 if (!firstframe || ip != lr) {
6984 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6985 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6986 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6987 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6988 - printk(" (%pS)",
6989 + printk(" (%pA)",
6990 (void *)current->ret_stack[curr_frame].ret);
6991 curr_frame--;
6992 }
6993 @@ -1152,7 +1152,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6994 struct pt_regs *regs = (struct pt_regs *)
6995 (sp + STACK_FRAME_OVERHEAD);
6996 lr = regs->link;
6997 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6998 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6999 regs->trap, (void *)regs->nip, (void *)lr);
7000 firstframe = 1;
7001 }
7002 @@ -1194,58 +1194,3 @@ void __ppc64_runlatch_off(void)
7003 mtspr(SPRN_CTRLT, ctrl);
7004 }
7005 #endif /* CONFIG_PPC64 */
7006 -
7007 -unsigned long arch_align_stack(unsigned long sp)
7008 -{
7009 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7010 - sp -= get_random_int() & ~PAGE_MASK;
7011 - return sp & ~0xf;
7012 -}
7013 -
7014 -static inline unsigned long brk_rnd(void)
7015 -{
7016 - unsigned long rnd = 0;
7017 -
7018 - /* 8MB for 32bit, 1GB for 64bit */
7019 - if (is_32bit_task())
7020 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7021 - else
7022 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7023 -
7024 - return rnd << PAGE_SHIFT;
7025 -}
7026 -
7027 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7028 -{
7029 - unsigned long base = mm->brk;
7030 - unsigned long ret;
7031 -
7032 -#ifdef CONFIG_PPC_STD_MMU_64
7033 - /*
7034 - * If we are using 1TB segments and we are allowed to randomise
7035 - * the heap, we can put it above 1TB so it is backed by a 1TB
7036 - * segment. Otherwise the heap will be in the bottom 1TB
7037 - * which always uses 256MB segments and this may result in a
7038 - * performance penalty.
7039 - */
7040 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7041 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7042 -#endif
7043 -
7044 - ret = PAGE_ALIGN(base + brk_rnd());
7045 -
7046 - if (ret < mm->brk)
7047 - return mm->brk;
7048 -
7049 - return ret;
7050 -}
7051 -
7052 -unsigned long randomize_et_dyn(unsigned long base)
7053 -{
7054 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7055 -
7056 - if (ret < base)
7057 - return base;
7058 -
7059 - return ret;
7060 -}
7061 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7062 index c497000..8fde506 100644
7063 --- a/arch/powerpc/kernel/ptrace.c
7064 +++ b/arch/powerpc/kernel/ptrace.c
7065 @@ -1737,6 +1737,10 @@ long arch_ptrace(struct task_struct *child, long request,
7066 return ret;
7067 }
7068
7069 +#ifdef CONFIG_GRKERNSEC_SETXID
7070 +extern void gr_delayed_cred_worker(void);
7071 +#endif
7072 +
7073 /*
7074 * We must return the syscall number to actually look up in the table.
7075 * This can be -1L to skip running any syscall at all.
7076 @@ -1747,6 +1751,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7077
7078 secure_computing_strict(regs->gpr[0]);
7079
7080 +#ifdef CONFIG_GRKERNSEC_SETXID
7081 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7082 + gr_delayed_cred_worker();
7083 +#endif
7084 +
7085 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7086 tracehook_report_syscall_entry(regs))
7087 /*
7088 @@ -1781,6 +1790,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7089 {
7090 int step;
7091
7092 +#ifdef CONFIG_GRKERNSEC_SETXID
7093 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7094 + gr_delayed_cred_worker();
7095 +#endif
7096 +
7097 audit_syscall_exit(regs);
7098
7099 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7100 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7101 index 804e323..79181c1 100644
7102 --- a/arch/powerpc/kernel/signal_32.c
7103 +++ b/arch/powerpc/kernel/signal_32.c
7104 @@ -851,7 +851,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7105 /* Save user registers on the stack */
7106 frame = &rt_sf->uc.uc_mcontext;
7107 addr = frame;
7108 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7109 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7110 if (save_user_regs(regs, frame, 0, 1))
7111 goto badframe;
7112 regs->link = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7113 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7114 index 1ca045d..139c3f7 100644
7115 --- a/arch/powerpc/kernel/signal_64.c
7116 +++ b/arch/powerpc/kernel/signal_64.c
7117 @@ -430,7 +430,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7118 current->thread.fpscr.val = 0;
7119
7120 /* Set up to return from userspace. */
7121 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7122 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7123 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7124 } else {
7125 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7126 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7127 index 3ce1f86..c30e629 100644
7128 --- a/arch/powerpc/kernel/sysfs.c
7129 +++ b/arch/powerpc/kernel/sysfs.c
7130 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7131 return NOTIFY_OK;
7132 }
7133
7134 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7135 +static struct notifier_block sysfs_cpu_nb = {
7136 .notifier_call = sysfs_cpu_notify,
7137 };
7138
7139 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7140 index 3251840..3f7c77a 100644
7141 --- a/arch/powerpc/kernel/traps.c
7142 +++ b/arch/powerpc/kernel/traps.c
7143 @@ -133,6 +133,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7144 return flags;
7145 }
7146
7147 +extern void gr_handle_kernel_exploit(void);
7148 +
7149 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7150 int signr)
7151 {
7152 @@ -182,6 +184,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7153 panic("Fatal exception in interrupt");
7154 if (panic_on_oops)
7155 panic("Fatal exception");
7156 +
7157 + gr_handle_kernel_exploit();
7158 +
7159 do_exit(signr);
7160 }
7161
7162 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7163 index 1b2076f..835e4be 100644
7164 --- a/arch/powerpc/kernel/vdso.c
7165 +++ b/arch/powerpc/kernel/vdso.c
7166 @@ -34,6 +34,7 @@
7167 #include <asm/firmware.h>
7168 #include <asm/vdso.h>
7169 #include <asm/vdso_datapage.h>
7170 +#include <asm/mman.h>
7171
7172 #include "setup.h"
7173
7174 @@ -218,7 +219,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7175 vdso_base = VDSO32_MBASE;
7176 #endif
7177
7178 - current->mm->context.vdso_base = 0;
7179 + current->mm->context.vdso_base = ~0UL;
7180
7181 /* vDSO has a problem and was disabled, just don't "enable" it for the
7182 * process
7183 @@ -238,7 +239,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7184 vdso_base = get_unmapped_area(NULL, vdso_base,
7185 (vdso_pages << PAGE_SHIFT) +
7186 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7187 - 0, 0);
7188 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7189 if (IS_ERR_VALUE(vdso_base)) {
7190 rc = vdso_base;
7191 goto fail_mmapsem;
7192 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7193 index 5eea6f3..5d10396 100644
7194 --- a/arch/powerpc/lib/usercopy_64.c
7195 +++ b/arch/powerpc/lib/usercopy_64.c
7196 @@ -9,22 +9,6 @@
7197 #include <linux/module.h>
7198 #include <asm/uaccess.h>
7199
7200 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7201 -{
7202 - if (likely(access_ok(VERIFY_READ, from, n)))
7203 - n = __copy_from_user(to, from, n);
7204 - else
7205 - memset(to, 0, n);
7206 - return n;
7207 -}
7208 -
7209 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7210 -{
7211 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7212 - n = __copy_to_user(to, from, n);
7213 - return n;
7214 -}
7215 -
7216 unsigned long copy_in_user(void __user *to, const void __user *from,
7217 unsigned long n)
7218 {
7219 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7220 return n;
7221 }
7222
7223 -EXPORT_SYMBOL(copy_from_user);
7224 -EXPORT_SYMBOL(copy_to_user);
7225 EXPORT_SYMBOL(copy_in_user);
7226
7227 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7228 index 3a8489a..6a63b3b 100644
7229 --- a/arch/powerpc/mm/fault.c
7230 +++ b/arch/powerpc/mm/fault.c
7231 @@ -32,6 +32,10 @@
7232 #include <linux/perf_event.h>
7233 #include <linux/magic.h>
7234 #include <linux/ratelimit.h>
7235 +#include <linux/slab.h>
7236 +#include <linux/pagemap.h>
7237 +#include <linux/compiler.h>
7238 +#include <linux/unistd.h>
7239
7240 #include <asm/firmware.h>
7241 #include <asm/page.h>
7242 @@ -68,6 +72,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7243 }
7244 #endif
7245
7246 +#ifdef CONFIG_PAX_PAGEEXEC
7247 +/*
7248 + * PaX: decide what to do with offenders (regs->nip = fault address)
7249 + *
7250 + * returns 1 when task should be killed
7251 + */
7252 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7253 +{
7254 + return 1;
7255 +}
7256 +
7257 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7258 +{
7259 + unsigned long i;
7260 +
7261 + printk(KERN_ERR "PAX: bytes at PC: ");
7262 + for (i = 0; i < 5; i++) {
7263 + unsigned int c;
7264 + if (get_user(c, (unsigned int __user *)pc+i))
7265 + printk(KERN_CONT "???????? ");
7266 + else
7267 + printk(KERN_CONT "%08x ", c);
7268 + }
7269 + printk("\n");
7270 +}
7271 +#endif
7272 +
7273 /*
7274 * Check whether the instruction at regs->nip is a store using
7275 * an update addressing form which will update r1.
7276 @@ -213,7 +244,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7277 * indicate errors in DSISR but can validly be set in SRR1.
7278 */
7279 if (trap == 0x400)
7280 - error_code &= 0x48200000;
7281 + error_code &= 0x58200000;
7282 else
7283 is_write = error_code & DSISR_ISSTORE;
7284 #else
7285 @@ -364,7 +395,7 @@ good_area:
7286 * "undefined". Of those that can be set, this is the only
7287 * one which seems bad.
7288 */
7289 - if (error_code & 0x10000000)
7290 + if (error_code & DSISR_GUARDED)
7291 /* Guarded storage error. */
7292 goto bad_area;
7293 #endif /* CONFIG_8xx */
7294 @@ -379,7 +410,7 @@ good_area:
7295 * processors use the same I/D cache coherency mechanism
7296 * as embedded.
7297 */
7298 - if (error_code & DSISR_PROTFAULT)
7299 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7300 goto bad_area;
7301 #endif /* CONFIG_PPC_STD_MMU */
7302
7303 @@ -462,6 +493,23 @@ bad_area:
7304 bad_area_nosemaphore:
7305 /* User mode accesses cause a SIGSEGV */
7306 if (user_mode(regs)) {
7307 +
7308 +#ifdef CONFIG_PAX_PAGEEXEC
7309 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7310 +#ifdef CONFIG_PPC_STD_MMU
7311 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7312 +#else
7313 + if (is_exec && regs->nip == address) {
7314 +#endif
7315 + switch (pax_handle_fetch_fault(regs)) {
7316 + }
7317 +
7318 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7319 + do_group_exit(SIGKILL);
7320 + }
7321 + }
7322 +#endif
7323 +
7324 _exception(SIGSEGV, regs, code, address);
7325 return 0;
7326 }
7327 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7328 index 67a42ed..cd463e0 100644
7329 --- a/arch/powerpc/mm/mmap_64.c
7330 +++ b/arch/powerpc/mm/mmap_64.c
7331 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7332 {
7333 unsigned long rnd = 0;
7334
7335 +#ifdef CONFIG_PAX_RANDMMAP
7336 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7337 +#endif
7338 +
7339 if (current->flags & PF_RANDOMIZE) {
7340 /* 8MB for 32bit, 1GB for 64bit */
7341 if (is_32bit_task())
7342 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7343 */
7344 if (mmap_is_legacy()) {
7345 mm->mmap_base = TASK_UNMAPPED_BASE;
7346 +
7347 +#ifdef CONFIG_PAX_RANDMMAP
7348 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7349 + mm->mmap_base += mm->delta_mmap;
7350 +#endif
7351 +
7352 mm->get_unmapped_area = arch_get_unmapped_area;
7353 mm->unmap_area = arch_unmap_area;
7354 } else {
7355 mm->mmap_base = mmap_base();
7356 +
7357 +#ifdef CONFIG_PAX_RANDMMAP
7358 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7359 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7360 +#endif
7361 +
7362 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7363 mm->unmap_area = arch_unmap_area_topdown;
7364 }
7365 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7366 index e779642..e5bb889 100644
7367 --- a/arch/powerpc/mm/mmu_context_nohash.c
7368 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7369 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7370 return NOTIFY_OK;
7371 }
7372
7373 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7374 +static struct notifier_block mmu_context_cpu_nb = {
7375 .notifier_call = mmu_context_cpu_notify,
7376 };
7377
7378 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7379 index bba87ca..c346a33 100644
7380 --- a/arch/powerpc/mm/numa.c
7381 +++ b/arch/powerpc/mm/numa.c
7382 @@ -932,7 +932,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7383 return ret;
7384 }
7385
7386 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7387 +static struct notifier_block ppc64_numa_nb = {
7388 .notifier_call = cpu_numa_callback,
7389 .priority = 1 /* Must run before sched domains notifier. */
7390 };
7391 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7392 index cf9dada..241529f 100644
7393 --- a/arch/powerpc/mm/slice.c
7394 +++ b/arch/powerpc/mm/slice.c
7395 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7396 if ((mm->task_size - len) < addr)
7397 return 0;
7398 vma = find_vma(mm, addr);
7399 - return (!vma || (addr + len) <= vma->vm_start);
7400 + return check_heap_stack_gap(vma, addr, len, 0);
7401 }
7402
7403 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7404 @@ -272,7 +272,7 @@ full_search:
7405 addr = _ALIGN_UP(addr + 1, 1ul << SLICE_HIGH_SHIFT);
7406 continue;
7407 }
7408 - if (!vma || addr + len <= vma->vm_start) {
7409 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7410 /*
7411 * Remember the place where we stopped the search:
7412 */
7413 @@ -329,10 +329,14 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7414 }
7415 }
7416
7417 - addr = mm->mmap_base;
7418 - while (addr > len) {
7419 + if (mm->mmap_base < len)
7420 + addr = -ENOMEM;
7421 + else
7422 + addr = mm->mmap_base - len;
7423 +
7424 + while (!IS_ERR_VALUE(addr)) {
7425 /* Go down by chunk size */
7426 - addr = _ALIGN_DOWN(addr - len, 1ul << pshift);
7427 + addr = _ALIGN_DOWN(addr, 1ul << pshift);
7428
7429 /* Check for hit with different page size */
7430 mask = slice_range_to_mask(addr, len);
7431 @@ -352,7 +356,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7432 * return with success:
7433 */
7434 vma = find_vma(mm, addr);
7435 - if (!vma || (addr + len) <= vma->vm_start) {
7436 + if (check_heap_stack_gap(vma, addr, len, 0)) {
7437 /* remember the address as a hint for next time */
7438 if (use_cache)
7439 mm->free_area_cache = addr;
7440 @@ -364,7 +368,7 @@ static unsigned long slice_find_area_topdown(struct mm_struct *mm,
7441 mm->cached_hole_size = vma->vm_start - addr;
7442
7443 /* try just below the current vma->vm_start */
7444 - addr = vma->vm_start;
7445 + addr = skip_heap_stack_gap(vma, len, 0);
7446 }
7447
7448 /*
7449 @@ -442,6 +446,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7450 if (fixed && addr > (mm->task_size - len))
7451 return -EINVAL;
7452
7453 +#ifdef CONFIG_PAX_RANDMMAP
7454 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7455 + addr = 0;
7456 +#endif
7457 +
7458 /* If hint, make sure it matches our alignment restrictions */
7459 if (!fixed && addr) {
7460 addr = _ALIGN_UP(addr, 1ul << pshift);
7461 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7462 index 0cfece4..2f1a0e5 100644
7463 --- a/arch/powerpc/platforms/cell/spufs/file.c
7464 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7465 @@ -281,9 +281,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7466 return VM_FAULT_NOPAGE;
7467 }
7468
7469 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7470 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7471 unsigned long address,
7472 - void *buf, int len, int write)
7473 + void *buf, size_t len, int write)
7474 {
7475 struct spu_context *ctx = vma->vm_file->private_data;
7476 unsigned long offset = address - vma->vm_start;
7477 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7478 index bdb738a..49c9f95 100644
7479 --- a/arch/powerpc/platforms/powermac/smp.c
7480 +++ b/arch/powerpc/platforms/powermac/smp.c
7481 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7482 return NOTIFY_OK;
7483 }
7484
7485 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7486 +static struct notifier_block smp_core99_cpu_nb = {
7487 .notifier_call = smp_core99_cpu_notify,
7488 };
7489 #endif /* CONFIG_HOTPLUG_CPU */
7490 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7491 index c797832..ce575c8 100644
7492 --- a/arch/s390/include/asm/atomic.h
7493 +++ b/arch/s390/include/asm/atomic.h
7494 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7495 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7496 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7497
7498 +#define atomic64_read_unchecked(v) atomic64_read(v)
7499 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7500 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7501 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7502 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7503 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7504 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7505 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7506 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7507 +
7508 #define smp_mb__before_atomic_dec() smp_mb()
7509 #define smp_mb__after_atomic_dec() smp_mb()
7510 #define smp_mb__before_atomic_inc() smp_mb()
7511 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7512 index 4d7ccac..d03d0ad 100644
7513 --- a/arch/s390/include/asm/cache.h
7514 +++ b/arch/s390/include/asm/cache.h
7515 @@ -9,8 +9,10 @@
7516 #ifndef __ARCH_S390_CACHE_H
7517 #define __ARCH_S390_CACHE_H
7518
7519 -#define L1_CACHE_BYTES 256
7520 +#include <linux/const.h>
7521 +
7522 #define L1_CACHE_SHIFT 8
7523 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7524 #define NET_SKB_PAD 32
7525
7526 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7527 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7528 index 178ff96..8c93bd1 100644
7529 --- a/arch/s390/include/asm/elf.h
7530 +++ b/arch/s390/include/asm/elf.h
7531 @@ -160,8 +160,14 @@ extern unsigned int vdso_enabled;
7532 the loader. We need to make sure that it is out of the way of the program
7533 that it will "exec", and that there is sufficient room for the brk. */
7534
7535 -extern unsigned long randomize_et_dyn(unsigned long base);
7536 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7537 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7538 +
7539 +#ifdef CONFIG_PAX_ASLR
7540 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7541 +
7542 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7543 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7544 +#endif
7545
7546 /* This yields a mask that user programs can use to figure out what
7547 instruction set this CPU supports. */
7548 @@ -210,9 +216,6 @@ struct linux_binprm;
7549 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7550 int arch_setup_additional_pages(struct linux_binprm *, int);
7551
7552 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7553 -#define arch_randomize_brk arch_randomize_brk
7554 -
7555 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7556
7557 #endif
7558 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7559 index c4a93d6..4d2a9b4 100644
7560 --- a/arch/s390/include/asm/exec.h
7561 +++ b/arch/s390/include/asm/exec.h
7562 @@ -7,6 +7,6 @@
7563 #ifndef __ASM_EXEC_H
7564 #define __ASM_EXEC_H
7565
7566 -extern unsigned long arch_align_stack(unsigned long sp);
7567 +#define arch_align_stack(x) ((x) & ~0xfUL)
7568
7569 #endif /* __ASM_EXEC_H */
7570 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7571 index 34268df..ea97318 100644
7572 --- a/arch/s390/include/asm/uaccess.h
7573 +++ b/arch/s390/include/asm/uaccess.h
7574 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7575 copy_to_user(void __user *to, const void *from, unsigned long n)
7576 {
7577 might_fault();
7578 +
7579 + if ((long)n < 0)
7580 + return n;
7581 +
7582 if (access_ok(VERIFY_WRITE, to, n))
7583 n = __copy_to_user(to, from, n);
7584 return n;
7585 @@ -277,6 +281,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7586 static inline unsigned long __must_check
7587 __copy_from_user(void *to, const void __user *from, unsigned long n)
7588 {
7589 + if ((long)n < 0)
7590 + return n;
7591 +
7592 if (__builtin_constant_p(n) && (n <= 256))
7593 return uaccess.copy_from_user_small(n, from, to);
7594 else
7595 @@ -308,10 +315,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7596 static inline unsigned long __must_check
7597 copy_from_user(void *to, const void __user *from, unsigned long n)
7598 {
7599 - unsigned int sz = __compiletime_object_size(to);
7600 + size_t sz = __compiletime_object_size(to);
7601
7602 might_fault();
7603 - if (unlikely(sz != -1 && sz < n)) {
7604 +
7605 + if ((long)n < 0)
7606 + return n;
7607 +
7608 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7609 copy_from_user_overflow();
7610 return n;
7611 }
7612 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7613 index 4610dea..cf0af21 100644
7614 --- a/arch/s390/kernel/module.c
7615 +++ b/arch/s390/kernel/module.c
7616 @@ -171,11 +171,11 @@ module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7617
7618 /* Increase core size by size of got & plt and set start
7619 offsets for got and plt. */
7620 - me->core_size = ALIGN(me->core_size, 4);
7621 - me->arch.got_offset = me->core_size;
7622 - me->core_size += me->arch.got_size;
7623 - me->arch.plt_offset = me->core_size;
7624 - me->core_size += me->arch.plt_size;
7625 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7626 + me->arch.got_offset = me->core_size_rw;
7627 + me->core_size_rw += me->arch.got_size;
7628 + me->arch.plt_offset = me->core_size_rx;
7629 + me->core_size_rx += me->arch.plt_size;
7630 return 0;
7631 }
7632
7633 @@ -252,7 +252,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7634 if (info->got_initialized == 0) {
7635 Elf_Addr *gotent;
7636
7637 - gotent = me->module_core + me->arch.got_offset +
7638 + gotent = me->module_core_rw + me->arch.got_offset +
7639 info->got_offset;
7640 *gotent = val;
7641 info->got_initialized = 1;
7642 @@ -276,7 +276,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7643 else if (r_type == R_390_GOTENT ||
7644 r_type == R_390_GOTPLTENT)
7645 *(unsigned int *) loc =
7646 - (val + (Elf_Addr) me->module_core - loc) >> 1;
7647 + (val + (Elf_Addr) me->module_core_rw - loc) >> 1;
7648 else if (r_type == R_390_GOT64 ||
7649 r_type == R_390_GOTPLT64)
7650 *(unsigned long *) loc = val;
7651 @@ -290,7 +290,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7652 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7653 if (info->plt_initialized == 0) {
7654 unsigned int *ip;
7655 - ip = me->module_core + me->arch.plt_offset +
7656 + ip = me->module_core_rx + me->arch.plt_offset +
7657 info->plt_offset;
7658 #ifndef CONFIG_64BIT
7659 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7660 @@ -315,7 +315,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7661 val - loc + 0xffffUL < 0x1ffffeUL) ||
7662 (r_type == R_390_PLT32DBL &&
7663 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7664 - val = (Elf_Addr) me->module_core +
7665 + val = (Elf_Addr) me->module_core_rx +
7666 me->arch.plt_offset +
7667 info->plt_offset;
7668 val += rela->r_addend - loc;
7669 @@ -337,7 +337,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7670 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7671 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7672 val = val + rela->r_addend -
7673 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7674 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7675 if (r_type == R_390_GOTOFF16)
7676 *(unsigned short *) loc = val;
7677 else if (r_type == R_390_GOTOFF32)
7678 @@ -347,7 +347,7 @@ apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7679 break;
7680 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7681 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7682 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7683 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7684 rela->r_addend - loc;
7685 if (r_type == R_390_GOTPC)
7686 *(unsigned int *) loc = val;
7687 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7688 index 536d645..4a5bd9e 100644
7689 --- a/arch/s390/kernel/process.c
7690 +++ b/arch/s390/kernel/process.c
7691 @@ -250,39 +250,3 @@ unsigned long get_wchan(struct task_struct *p)
7692 }
7693 return 0;
7694 }
7695 -
7696 -unsigned long arch_align_stack(unsigned long sp)
7697 -{
7698 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7699 - sp -= get_random_int() & ~PAGE_MASK;
7700 - return sp & ~0xf;
7701 -}
7702 -
7703 -static inline unsigned long brk_rnd(void)
7704 -{
7705 - /* 8MB for 32bit, 1GB for 64bit */
7706 - if (is_32bit_task())
7707 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7708 - else
7709 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7710 -}
7711 -
7712 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7713 -{
7714 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7715 -
7716 - if (ret < mm->brk)
7717 - return mm->brk;
7718 - return ret;
7719 -}
7720 -
7721 -unsigned long randomize_et_dyn(unsigned long base)
7722 -{
7723 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7724 -
7725 - if (!(current->flags & PF_RANDOMIZE))
7726 - return base;
7727 - if (ret < base)
7728 - return base;
7729 - return ret;
7730 -}
7731 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7732 index c59a5ef..3fae59c 100644
7733 --- a/arch/s390/mm/mmap.c
7734 +++ b/arch/s390/mm/mmap.c
7735 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7736 */
7737 if (mmap_is_legacy()) {
7738 mm->mmap_base = TASK_UNMAPPED_BASE;
7739 +
7740 +#ifdef CONFIG_PAX_RANDMMAP
7741 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7742 + mm->mmap_base += mm->delta_mmap;
7743 +#endif
7744 +
7745 mm->get_unmapped_area = arch_get_unmapped_area;
7746 mm->unmap_area = arch_unmap_area;
7747 } else {
7748 mm->mmap_base = mmap_base();
7749 +
7750 +#ifdef CONFIG_PAX_RANDMMAP
7751 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7752 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7753 +#endif
7754 +
7755 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7756 mm->unmap_area = arch_unmap_area_topdown;
7757 }
7758 @@ -172,10 +184,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7759 */
7760 if (mmap_is_legacy()) {
7761 mm->mmap_base = TASK_UNMAPPED_BASE;
7762 +
7763 +#ifdef CONFIG_PAX_RANDMMAP
7764 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7765 + mm->mmap_base += mm->delta_mmap;
7766 +#endif
7767 +
7768 mm->get_unmapped_area = s390_get_unmapped_area;
7769 mm->unmap_area = arch_unmap_area;
7770 } else {
7771 mm->mmap_base = mmap_base();
7772 +
7773 +#ifdef CONFIG_PAX_RANDMMAP
7774 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7775 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7776 +#endif
7777 +
7778 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7779 mm->unmap_area = arch_unmap_area_topdown;
7780 }
7781 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7782 index ae3d59f..f65f075 100644
7783 --- a/arch/score/include/asm/cache.h
7784 +++ b/arch/score/include/asm/cache.h
7785 @@ -1,7 +1,9 @@
7786 #ifndef _ASM_SCORE_CACHE_H
7787 #define _ASM_SCORE_CACHE_H
7788
7789 +#include <linux/const.h>
7790 +
7791 #define L1_CACHE_SHIFT 4
7792 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7793 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7794
7795 #endif /* _ASM_SCORE_CACHE_H */
7796 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7797 index f9f3cd5..58ff438 100644
7798 --- a/arch/score/include/asm/exec.h
7799 +++ b/arch/score/include/asm/exec.h
7800 @@ -1,6 +1,6 @@
7801 #ifndef _ASM_SCORE_EXEC_H
7802 #define _ASM_SCORE_EXEC_H
7803
7804 -extern unsigned long arch_align_stack(unsigned long sp);
7805 +#define arch_align_stack(x) (x)
7806
7807 #endif /* _ASM_SCORE_EXEC_H */
7808 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7809 index 7956846..5f37677 100644
7810 --- a/arch/score/kernel/process.c
7811 +++ b/arch/score/kernel/process.c
7812 @@ -134,8 +134,3 @@ unsigned long get_wchan(struct task_struct *task)
7813
7814 return task_pt_regs(task)->cp0_epc;
7815 }
7816 -
7817 -unsigned long arch_align_stack(unsigned long sp)
7818 -{
7819 - return sp;
7820 -}
7821 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7822 index ef9e555..331bd29 100644
7823 --- a/arch/sh/include/asm/cache.h
7824 +++ b/arch/sh/include/asm/cache.h
7825 @@ -9,10 +9,11 @@
7826 #define __ASM_SH_CACHE_H
7827 #ifdef __KERNEL__
7828
7829 +#include <linux/const.h>
7830 #include <linux/init.h>
7831 #include <cpu/cache.h>
7832
7833 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7834 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7835
7836 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7837
7838 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7839 index 03f2b55..b027032 100644
7840 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7841 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7842 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7843 return NOTIFY_OK;
7844 }
7845
7846 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7847 +static struct notifier_block shx3_cpu_notifier = {
7848 .notifier_call = shx3_cpu_callback,
7849 };
7850
7851 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7852 index 6777177..cb5e44f 100644
7853 --- a/arch/sh/mm/mmap.c
7854 +++ b/arch/sh/mm/mmap.c
7855 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7856 struct mm_struct *mm = current->mm;
7857 struct vm_area_struct *vma;
7858 int do_colour_align;
7859 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7860 struct vm_unmapped_area_info info;
7861
7862 if (flags & MAP_FIXED) {
7863 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7864 if (filp || (flags & MAP_SHARED))
7865 do_colour_align = 1;
7866
7867 +#ifdef CONFIG_PAX_RANDMMAP
7868 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7869 +#endif
7870 +
7871 if (addr) {
7872 if (do_colour_align)
7873 addr = COLOUR_ALIGN(addr, pgoff);
7874 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7875 addr = PAGE_ALIGN(addr);
7876
7877 vma = find_vma(mm, addr);
7878 - if (TASK_SIZE - len >= addr &&
7879 - (!vma || addr + len <= vma->vm_start))
7880 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7881 return addr;
7882 }
7883
7884 info.flags = 0;
7885 info.length = len;
7886 - info.low_limit = TASK_UNMAPPED_BASE;
7887 + info.low_limit = mm->mmap_base;
7888 info.high_limit = TASK_SIZE;
7889 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7890 info.align_offset = pgoff << PAGE_SHIFT;
7891 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7892 struct mm_struct *mm = current->mm;
7893 unsigned long addr = addr0;
7894 int do_colour_align;
7895 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7896 struct vm_unmapped_area_info info;
7897
7898 if (flags & MAP_FIXED) {
7899 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7900 if (filp || (flags & MAP_SHARED))
7901 do_colour_align = 1;
7902
7903 +#ifdef CONFIG_PAX_RANDMMAP
7904 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7905 +#endif
7906 +
7907 /* requesting a specific address */
7908 if (addr) {
7909 if (do_colour_align)
7910 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7911 addr = PAGE_ALIGN(addr);
7912
7913 vma = find_vma(mm, addr);
7914 - if (TASK_SIZE - len >= addr &&
7915 - (!vma || addr + len <= vma->vm_start))
7916 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7917 return addr;
7918 }
7919
7920 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7921 VM_BUG_ON(addr != -ENOMEM);
7922 info.flags = 0;
7923 info.low_limit = TASK_UNMAPPED_BASE;
7924 +
7925 +#ifdef CONFIG_PAX_RANDMMAP
7926 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7927 + info.low_limit += mm->delta_mmap;
7928 +#endif
7929 +
7930 info.high_limit = TASK_SIZE;
7931 addr = vm_unmapped_area(&info);
7932 }
7933 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7934 index be56a24..443328f 100644
7935 --- a/arch/sparc/include/asm/atomic_64.h
7936 +++ b/arch/sparc/include/asm/atomic_64.h
7937 @@ -14,18 +14,40 @@
7938 #define ATOMIC64_INIT(i) { (i) }
7939
7940 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7941 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7942 +{
7943 + return v->counter;
7944 +}
7945 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7946 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7947 +{
7948 + return v->counter;
7949 +}
7950
7951 #define atomic_set(v, i) (((v)->counter) = i)
7952 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7953 +{
7954 + v->counter = i;
7955 +}
7956 #define atomic64_set(v, i) (((v)->counter) = i)
7957 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7958 +{
7959 + v->counter = i;
7960 +}
7961
7962 extern void atomic_add(int, atomic_t *);
7963 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7964 extern void atomic64_add(long, atomic64_t *);
7965 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7966 extern void atomic_sub(int, atomic_t *);
7967 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7968 extern void atomic64_sub(long, atomic64_t *);
7969 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7970
7971 extern int atomic_add_ret(int, atomic_t *);
7972 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7973 extern long atomic64_add_ret(long, atomic64_t *);
7974 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7975 extern int atomic_sub_ret(int, atomic_t *);
7976 extern long atomic64_sub_ret(long, atomic64_t *);
7977
7978 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7979 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7980
7981 #define atomic_inc_return(v) atomic_add_ret(1, v)
7982 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7983 +{
7984 + return atomic_add_ret_unchecked(1, v);
7985 +}
7986 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7987 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7988 +{
7989 + return atomic64_add_ret_unchecked(1, v);
7990 +}
7991
7992 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7993 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7994
7995 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7996 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7997 +{
7998 + return atomic_add_ret_unchecked(i, v);
7999 +}
8000 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8001 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8002 +{
8003 + return atomic64_add_ret_unchecked(i, v);
8004 +}
8005
8006 /*
8007 * atomic_inc_and_test - increment and test
8008 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8009 * other cases.
8010 */
8011 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8012 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8013 +{
8014 + return atomic_inc_return_unchecked(v) == 0;
8015 +}
8016 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8017
8018 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
8019 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8020 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
8021
8022 #define atomic_inc(v) atomic_add(1, v)
8023 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
8024 +{
8025 + atomic_add_unchecked(1, v);
8026 +}
8027 #define atomic64_inc(v) atomic64_add(1, v)
8028 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
8029 +{
8030 + atomic64_add_unchecked(1, v);
8031 +}
8032
8033 #define atomic_dec(v) atomic_sub(1, v)
8034 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
8035 +{
8036 + atomic_sub_unchecked(1, v);
8037 +}
8038 #define atomic64_dec(v) atomic64_sub(1, v)
8039 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
8040 +{
8041 + atomic64_sub_unchecked(1, v);
8042 +}
8043
8044 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8045 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8046
8047 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8048 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8049 +{
8050 + return cmpxchg(&v->counter, old, new);
8051 +}
8052 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8053 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8054 +{
8055 + return xchg(&v->counter, new);
8056 +}
8057
8058 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8059 {
8060 - int c, old;
8061 + int c, old, new;
8062 c = atomic_read(v);
8063 for (;;) {
8064 - if (unlikely(c == (u)))
8065 + if (unlikely(c == u))
8066 break;
8067 - old = atomic_cmpxchg((v), c, c + (a));
8068 +
8069 + asm volatile("addcc %2, %0, %0\n"
8070 +
8071 +#ifdef CONFIG_PAX_REFCOUNT
8072 + "tvs %%icc, 6\n"
8073 +#endif
8074 +
8075 + : "=r" (new)
8076 + : "0" (c), "ir" (a)
8077 + : "cc");
8078 +
8079 + old = atomic_cmpxchg(v, c, new);
8080 if (likely(old == c))
8081 break;
8082 c = old;
8083 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8084 #define atomic64_cmpxchg(v, o, n) \
8085 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8086 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8087 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8088 +{
8089 + return xchg(&v->counter, new);
8090 +}
8091
8092 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8093 {
8094 - long c, old;
8095 + long c, old, new;
8096 c = atomic64_read(v);
8097 for (;;) {
8098 - if (unlikely(c == (u)))
8099 + if (unlikely(c == u))
8100 break;
8101 - old = atomic64_cmpxchg((v), c, c + (a));
8102 +
8103 + asm volatile("addcc %2, %0, %0\n"
8104 +
8105 +#ifdef CONFIG_PAX_REFCOUNT
8106 + "tvs %%xcc, 6\n"
8107 +#endif
8108 +
8109 + : "=r" (new)
8110 + : "0" (c), "ir" (a)
8111 + : "cc");
8112 +
8113 + old = atomic64_cmpxchg(v, c, new);
8114 if (likely(old == c))
8115 break;
8116 c = old;
8117 }
8118 - return c != (u);
8119 + return c != u;
8120 }
8121
8122 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8123 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8124 index 5bb6991..5c2132e 100644
8125 --- a/arch/sparc/include/asm/cache.h
8126 +++ b/arch/sparc/include/asm/cache.h
8127 @@ -7,10 +7,12 @@
8128 #ifndef _SPARC_CACHE_H
8129 #define _SPARC_CACHE_H
8130
8131 +#include <linux/const.h>
8132 +
8133 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8134
8135 #define L1_CACHE_SHIFT 5
8136 -#define L1_CACHE_BYTES 32
8137 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8138
8139 #ifdef CONFIG_SPARC32
8140 #define SMP_CACHE_BYTES_SHIFT 5
8141 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8142 index ac74a2c..a9e58af 100644
8143 --- a/arch/sparc/include/asm/elf_32.h
8144 +++ b/arch/sparc/include/asm/elf_32.h
8145 @@ -114,6 +114,13 @@ typedef struct {
8146
8147 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8148
8149 +#ifdef CONFIG_PAX_ASLR
8150 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8151 +
8152 +#define PAX_DELTA_MMAP_LEN 16
8153 +#define PAX_DELTA_STACK_LEN 16
8154 +#endif
8155 +
8156 /* This yields a mask that user programs can use to figure out what
8157 instruction set this cpu supports. This can NOT be done in userspace
8158 on Sparc. */
8159 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8160 index 370ca1e..d4f4a98 100644
8161 --- a/arch/sparc/include/asm/elf_64.h
8162 +++ b/arch/sparc/include/asm/elf_64.h
8163 @@ -189,6 +189,13 @@ typedef struct {
8164 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8165 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8166
8167 +#ifdef CONFIG_PAX_ASLR
8168 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8169 +
8170 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8171 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8172 +#endif
8173 +
8174 extern unsigned long sparc64_elf_hwcap;
8175 #define ELF_HWCAP sparc64_elf_hwcap
8176
8177 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8178 index 9b1c36d..209298b 100644
8179 --- a/arch/sparc/include/asm/pgalloc_32.h
8180 +++ b/arch/sparc/include/asm/pgalloc_32.h
8181 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8182 }
8183
8184 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8185 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8186
8187 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8188 unsigned long address)
8189 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8190 index bcfe063..b333142 100644
8191 --- a/arch/sparc/include/asm/pgalloc_64.h
8192 +++ b/arch/sparc/include/asm/pgalloc_64.h
8193 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8194 }
8195
8196 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8197 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8198
8199 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8200 {
8201 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8202 index 6fc1348..390c50a 100644
8203 --- a/arch/sparc/include/asm/pgtable_32.h
8204 +++ b/arch/sparc/include/asm/pgtable_32.h
8205 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8206 #define PAGE_SHARED SRMMU_PAGE_SHARED
8207 #define PAGE_COPY SRMMU_PAGE_COPY
8208 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8209 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8210 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8211 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8212 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8213
8214 /* Top-level page directory - dummy used by init-mm.
8215 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8216
8217 /* xwr */
8218 #define __P000 PAGE_NONE
8219 -#define __P001 PAGE_READONLY
8220 -#define __P010 PAGE_COPY
8221 -#define __P011 PAGE_COPY
8222 +#define __P001 PAGE_READONLY_NOEXEC
8223 +#define __P010 PAGE_COPY_NOEXEC
8224 +#define __P011 PAGE_COPY_NOEXEC
8225 #define __P100 PAGE_READONLY
8226 #define __P101 PAGE_READONLY
8227 #define __P110 PAGE_COPY
8228 #define __P111 PAGE_COPY
8229
8230 #define __S000 PAGE_NONE
8231 -#define __S001 PAGE_READONLY
8232 -#define __S010 PAGE_SHARED
8233 -#define __S011 PAGE_SHARED
8234 +#define __S001 PAGE_READONLY_NOEXEC
8235 +#define __S010 PAGE_SHARED_NOEXEC
8236 +#define __S011 PAGE_SHARED_NOEXEC
8237 #define __S100 PAGE_READONLY
8238 #define __S101 PAGE_READONLY
8239 #define __S110 PAGE_SHARED
8240 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8241 index 79da178..c2eede8 100644
8242 --- a/arch/sparc/include/asm/pgtsrmmu.h
8243 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8244 @@ -115,6 +115,11 @@
8245 SRMMU_EXEC | SRMMU_REF)
8246 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8247 SRMMU_EXEC | SRMMU_REF)
8248 +
8249 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8250 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8251 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8252 +
8253 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8254 SRMMU_DIRTY | SRMMU_REF)
8255
8256 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8257 index 9689176..63c18ea 100644
8258 --- a/arch/sparc/include/asm/spinlock_64.h
8259 +++ b/arch/sparc/include/asm/spinlock_64.h
8260 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8261
8262 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8263
8264 -static void inline arch_read_lock(arch_rwlock_t *lock)
8265 +static inline void arch_read_lock(arch_rwlock_t *lock)
8266 {
8267 unsigned long tmp1, tmp2;
8268
8269 __asm__ __volatile__ (
8270 "1: ldsw [%2], %0\n"
8271 " brlz,pn %0, 2f\n"
8272 -"4: add %0, 1, %1\n"
8273 +"4: addcc %0, 1, %1\n"
8274 +
8275 +#ifdef CONFIG_PAX_REFCOUNT
8276 +" tvs %%icc, 6\n"
8277 +#endif
8278 +
8279 " cas [%2], %0, %1\n"
8280 " cmp %0, %1\n"
8281 " bne,pn %%icc, 1b\n"
8282 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8283 " .previous"
8284 : "=&r" (tmp1), "=&r" (tmp2)
8285 : "r" (lock)
8286 - : "memory");
8287 + : "memory", "cc");
8288 }
8289
8290 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8291 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8292 {
8293 int tmp1, tmp2;
8294
8295 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8296 "1: ldsw [%2], %0\n"
8297 " brlz,a,pn %0, 2f\n"
8298 " mov 0, %0\n"
8299 -" add %0, 1, %1\n"
8300 +" addcc %0, 1, %1\n"
8301 +
8302 +#ifdef CONFIG_PAX_REFCOUNT
8303 +" tvs %%icc, 6\n"
8304 +#endif
8305 +
8306 " cas [%2], %0, %1\n"
8307 " cmp %0, %1\n"
8308 " bne,pn %%icc, 1b\n"
8309 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8310 return tmp1;
8311 }
8312
8313 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8314 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8315 {
8316 unsigned long tmp1, tmp2;
8317
8318 __asm__ __volatile__(
8319 "1: lduw [%2], %0\n"
8320 -" sub %0, 1, %1\n"
8321 +" subcc %0, 1, %1\n"
8322 +
8323 +#ifdef CONFIG_PAX_REFCOUNT
8324 +" tvs %%icc, 6\n"
8325 +#endif
8326 +
8327 " cas [%2], %0, %1\n"
8328 " cmp %0, %1\n"
8329 " bne,pn %%xcc, 1b\n"
8330 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8331 : "memory");
8332 }
8333
8334 -static void inline arch_write_lock(arch_rwlock_t *lock)
8335 +static inline void arch_write_lock(arch_rwlock_t *lock)
8336 {
8337 unsigned long mask, tmp1, tmp2;
8338
8339 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8340 : "memory");
8341 }
8342
8343 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8344 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8345 {
8346 __asm__ __volatile__(
8347 " stw %%g0, [%0]"
8348 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8349 : "memory");
8350 }
8351
8352 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8353 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8354 {
8355 unsigned long mask, tmp1, tmp2, result;
8356
8357 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8358 index 25849ae..924c54b 100644
8359 --- a/arch/sparc/include/asm/thread_info_32.h
8360 +++ b/arch/sparc/include/asm/thread_info_32.h
8361 @@ -49,6 +49,8 @@ struct thread_info {
8362 unsigned long w_saved;
8363
8364 struct restart_block restart_block;
8365 +
8366 + unsigned long lowest_stack;
8367 };
8368
8369 /*
8370 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8371 index 269bd92..e46a9b8 100644
8372 --- a/arch/sparc/include/asm/thread_info_64.h
8373 +++ b/arch/sparc/include/asm/thread_info_64.h
8374 @@ -63,6 +63,8 @@ struct thread_info {
8375 struct pt_regs *kern_una_regs;
8376 unsigned int kern_una_insn;
8377
8378 + unsigned long lowest_stack;
8379 +
8380 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8381 };
8382
8383 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8384 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8385 /* flag bit 6 is available */
8386 #define TIF_32BIT 7 /* 32-bit binary */
8387 -/* flag bit 8 is available */
8388 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8389 #define TIF_SECCOMP 9 /* secure computing */
8390 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8391 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8392 +
8393 /* NOTE: Thread flags >= 12 should be ones we have no interest
8394 * in using in assembly, else we can't use the mask as
8395 * an immediate value in instructions such as andcc.
8396 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8397 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8398 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8399 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8400 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8401
8402 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8403 _TIF_DO_NOTIFY_RESUME_MASK | \
8404 _TIF_NEED_RESCHED)
8405 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8406
8407 +#define _TIF_WORK_SYSCALL \
8408 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8409 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8410 +
8411 +
8412 /*
8413 * Thread-synchronous status.
8414 *
8415 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8416 index 0167d26..767bb0c 100644
8417 --- a/arch/sparc/include/asm/uaccess.h
8418 +++ b/arch/sparc/include/asm/uaccess.h
8419 @@ -1,5 +1,6 @@
8420 #ifndef ___ASM_SPARC_UACCESS_H
8421 #define ___ASM_SPARC_UACCESS_H
8422 +
8423 #if defined(__sparc__) && defined(__arch64__)
8424 #include <asm/uaccess_64.h>
8425 #else
8426 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8427 index 53a28dd..50c38c3 100644
8428 --- a/arch/sparc/include/asm/uaccess_32.h
8429 +++ b/arch/sparc/include/asm/uaccess_32.h
8430 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8431
8432 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8433 {
8434 - if (n && __access_ok((unsigned long) to, n))
8435 + if ((long)n < 0)
8436 + return n;
8437 +
8438 + if (n && __access_ok((unsigned long) to, n)) {
8439 + if (!__builtin_constant_p(n))
8440 + check_object_size(from, n, true);
8441 return __copy_user(to, (__force void __user *) from, n);
8442 - else
8443 + } else
8444 return n;
8445 }
8446
8447 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8448 {
8449 + if ((long)n < 0)
8450 + return n;
8451 +
8452 + if (!__builtin_constant_p(n))
8453 + check_object_size(from, n, true);
8454 +
8455 return __copy_user(to, (__force void __user *) from, n);
8456 }
8457
8458 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8459 {
8460 - if (n && __access_ok((unsigned long) from, n))
8461 + if ((long)n < 0)
8462 + return n;
8463 +
8464 + if (n && __access_ok((unsigned long) from, n)) {
8465 + if (!__builtin_constant_p(n))
8466 + check_object_size(to, n, false);
8467 return __copy_user((__force void __user *) to, from, n);
8468 - else
8469 + } else
8470 return n;
8471 }
8472
8473 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8474 {
8475 + if ((long)n < 0)
8476 + return n;
8477 +
8478 return __copy_user((__force void __user *) to, from, n);
8479 }
8480
8481 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8482 index e562d3c..191f176 100644
8483 --- a/arch/sparc/include/asm/uaccess_64.h
8484 +++ b/arch/sparc/include/asm/uaccess_64.h
8485 @@ -10,6 +10,7 @@
8486 #include <linux/compiler.h>
8487 #include <linux/string.h>
8488 #include <linux/thread_info.h>
8489 +#include <linux/kernel.h>
8490 #include <asm/asi.h>
8491 #include <asm/spitfire.h>
8492 #include <asm-generic/uaccess-unaligned.h>
8493 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8494 static inline unsigned long __must_check
8495 copy_from_user(void *to, const void __user *from, unsigned long size)
8496 {
8497 - unsigned long ret = ___copy_from_user(to, from, size);
8498 + unsigned long ret;
8499
8500 + if ((long)size < 0 || size > INT_MAX)
8501 + return size;
8502 +
8503 + if (!__builtin_constant_p(size))
8504 + check_object_size(to, size, false);
8505 +
8506 + ret = ___copy_from_user(to, from, size);
8507 if (unlikely(ret))
8508 ret = copy_from_user_fixup(to, from, size);
8509
8510 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8511 static inline unsigned long __must_check
8512 copy_to_user(void __user *to, const void *from, unsigned long size)
8513 {
8514 - unsigned long ret = ___copy_to_user(to, from, size);
8515 + unsigned long ret;
8516
8517 + if ((long)size < 0 || size > INT_MAX)
8518 + return size;
8519 +
8520 + if (!__builtin_constant_p(size))
8521 + check_object_size(from, size, true);
8522 +
8523 + ret = ___copy_to_user(to, from, size);
8524 if (unlikely(ret))
8525 ret = copy_to_user_fixup(to, from, size);
8526 return ret;
8527 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8528 index 6cf591b..b49e65a 100644
8529 --- a/arch/sparc/kernel/Makefile
8530 +++ b/arch/sparc/kernel/Makefile
8531 @@ -3,7 +3,7 @@
8532 #
8533
8534 asflags-y := -ansi
8535 -ccflags-y := -Werror
8536 +#ccflags-y := -Werror
8537
8538 extra-y := head_$(BITS).o
8539
8540 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8541 index be8e862..5b50b12 100644
8542 --- a/arch/sparc/kernel/process_32.c
8543 +++ b/arch/sparc/kernel/process_32.c
8544 @@ -126,14 +126,14 @@ void show_regs(struct pt_regs *r)
8545
8546 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8547 r->psr, r->pc, r->npc, r->y, print_tainted());
8548 - printk("PC: <%pS>\n", (void *) r->pc);
8549 + printk("PC: <%pA>\n", (void *) r->pc);
8550 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8551 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8552 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8553 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8554 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8555 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8556 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8557 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8558
8559 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8560 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8561 @@ -168,7 +168,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8562 rw = (struct reg_window32 *) fp;
8563 pc = rw->ins[7];
8564 printk("[%08lx : ", pc);
8565 - printk("%pS ] ", (void *) pc);
8566 + printk("%pA ] ", (void *) pc);
8567 fp = rw->ins[6];
8568 } while (++count < 16);
8569 printk("\n");
8570 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8571 index cdb80b2..5ca141d 100644
8572 --- a/arch/sparc/kernel/process_64.c
8573 +++ b/arch/sparc/kernel/process_64.c
8574 @@ -181,14 +181,14 @@ static void show_regwindow(struct pt_regs *regs)
8575 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8576 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8577 if (regs->tstate & TSTATE_PRIV)
8578 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8579 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8580 }
8581
8582 void show_regs(struct pt_regs *regs)
8583 {
8584 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8585 regs->tpc, regs->tnpc, regs->y, print_tainted());
8586 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8587 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8588 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8589 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8590 regs->u_regs[3]);
8591 @@ -201,7 +201,7 @@ void show_regs(struct pt_regs *regs)
8592 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8593 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8594 regs->u_regs[15]);
8595 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8596 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8597 show_regwindow(regs);
8598 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8599 }
8600 @@ -290,7 +290,7 @@ void arch_trigger_all_cpu_backtrace(void)
8601 ((tp && tp->task) ? tp->task->pid : -1));
8602
8603 if (gp->tstate & TSTATE_PRIV) {
8604 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8605 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8606 (void *) gp->tpc,
8607 (void *) gp->o7,
8608 (void *) gp->i7,
8609 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8610 index 1303021..c2a6321 100644
8611 --- a/arch/sparc/kernel/prom_common.c
8612 +++ b/arch/sparc/kernel/prom_common.c
8613 @@ -143,7 +143,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8614
8615 unsigned int prom_early_allocated __initdata;
8616
8617 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8618 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8619 .nextprop = prom_common_nextprop,
8620 .getproplen = prom_getproplen,
8621 .getproperty = prom_getproperty,
8622 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8623 index 7ff45e4..a58f271 100644
8624 --- a/arch/sparc/kernel/ptrace_64.c
8625 +++ b/arch/sparc/kernel/ptrace_64.c
8626 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8627 return ret;
8628 }
8629
8630 +#ifdef CONFIG_GRKERNSEC_SETXID
8631 +extern void gr_delayed_cred_worker(void);
8632 +#endif
8633 +
8634 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8635 {
8636 int ret = 0;
8637 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8638 /* do the secure computing check first */
8639 secure_computing_strict(regs->u_regs[UREG_G1]);
8640
8641 +#ifdef CONFIG_GRKERNSEC_SETXID
8642 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8643 + gr_delayed_cred_worker();
8644 +#endif
8645 +
8646 if (test_thread_flag(TIF_SYSCALL_TRACE))
8647 ret = tracehook_report_syscall_entry(regs);
8648
8649 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8650
8651 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8652 {
8653 +#ifdef CONFIG_GRKERNSEC_SETXID
8654 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8655 + gr_delayed_cred_worker();
8656 +#endif
8657 +
8658 audit_syscall_exit(regs);
8659
8660 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8661 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8662 index 2da0bdc..79128d2 100644
8663 --- a/arch/sparc/kernel/sys_sparc_32.c
8664 +++ b/arch/sparc/kernel/sys_sparc_32.c
8665 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8666 if (len > TASK_SIZE - PAGE_SIZE)
8667 return -ENOMEM;
8668 if (!addr)
8669 - addr = TASK_UNMAPPED_BASE;
8670 + addr = current->mm->mmap_base;
8671
8672 info.flags = 0;
8673 info.length = len;
8674 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8675 index 708bc29..f0129cb 100644
8676 --- a/arch/sparc/kernel/sys_sparc_64.c
8677 +++ b/arch/sparc/kernel/sys_sparc_64.c
8678 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8679 struct vm_area_struct * vma;
8680 unsigned long task_size = TASK_SIZE;
8681 int do_color_align;
8682 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8683 struct vm_unmapped_area_info info;
8684
8685 if (flags & MAP_FIXED) {
8686 /* We do not accept a shared mapping if it would violate
8687 * cache aliasing constraints.
8688 */
8689 - if ((flags & MAP_SHARED) &&
8690 + if ((filp || (flags & MAP_SHARED)) &&
8691 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8692 return -EINVAL;
8693 return addr;
8694 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8695 if (filp || (flags & MAP_SHARED))
8696 do_color_align = 1;
8697
8698 +#ifdef CONFIG_PAX_RANDMMAP
8699 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8700 +#endif
8701 +
8702 if (addr) {
8703 if (do_color_align)
8704 addr = COLOR_ALIGN(addr, pgoff);
8705 @@ -118,14 +123,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8706 addr = PAGE_ALIGN(addr);
8707
8708 vma = find_vma(mm, addr);
8709 - if (task_size - len >= addr &&
8710 - (!vma || addr + len <= vma->vm_start))
8711 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8712 return addr;
8713 }
8714
8715 info.flags = 0;
8716 info.length = len;
8717 - info.low_limit = TASK_UNMAPPED_BASE;
8718 + info.low_limit = mm->mmap_base;
8719 info.high_limit = min(task_size, VA_EXCLUDE_START);
8720 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8721 info.align_offset = pgoff << PAGE_SHIFT;
8722 @@ -134,6 +138,12 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8723 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8724 VM_BUG_ON(addr != -ENOMEM);
8725 info.low_limit = VA_EXCLUDE_END;
8726 +
8727 +#ifdef CONFIG_PAX_RANDMMAP
8728 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8729 + info.low_limit += mm->delta_mmap;
8730 +#endif
8731 +
8732 info.high_limit = task_size;
8733 addr = vm_unmapped_area(&info);
8734 }
8735 @@ -151,6 +161,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8736 unsigned long task_size = STACK_TOP32;
8737 unsigned long addr = addr0;
8738 int do_color_align;
8739 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8740 struct vm_unmapped_area_info info;
8741
8742 /* This should only ever run for 32-bit processes. */
8743 @@ -160,7 +171,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 @@ -173,6 +184,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 /* requesting a specific address */
8761 if (addr) {
8762 if (do_color_align)
8763 @@ -181,8 +196,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
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 @@ -204,6 +218,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8774 VM_BUG_ON(addr != -ENOMEM);
8775 info.flags = 0;
8776 info.low_limit = TASK_UNMAPPED_BASE;
8777 +
8778 +#ifdef CONFIG_PAX_RANDMMAP
8779 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8780 + info.low_limit += mm->delta_mmap;
8781 +#endif
8782 +
8783 info.high_limit = STACK_TOP32;
8784 addr = vm_unmapped_area(&info);
8785 }
8786 @@ -264,6 +284,10 @@ static unsigned long mmap_rnd(void)
8787 {
8788 unsigned long rnd = 0UL;
8789
8790 +#ifdef CONFIG_PAX_RANDMMAP
8791 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8792 +#endif
8793 +
8794 if (current->flags & PF_RANDOMIZE) {
8795 unsigned long val = get_random_int();
8796 if (test_thread_flag(TIF_32BIT))
8797 @@ -289,6 +313,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8798 gap == RLIM_INFINITY ||
8799 sysctl_legacy_va_layout) {
8800 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8801 +
8802 +#ifdef CONFIG_PAX_RANDMMAP
8803 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8804 + mm->mmap_base += mm->delta_mmap;
8805 +#endif
8806 +
8807 mm->get_unmapped_area = arch_get_unmapped_area;
8808 mm->unmap_area = arch_unmap_area;
8809 } else {
8810 @@ -301,6 +331,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8811 gap = (task_size / 6 * 5);
8812
8813 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8814 +
8815 +#ifdef CONFIG_PAX_RANDMMAP
8816 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8817 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8818 +#endif
8819 +
8820 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8821 mm->unmap_area = arch_unmap_area_topdown;
8822 }
8823 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8824 index e0fed77..604a7e5 100644
8825 --- a/arch/sparc/kernel/syscalls.S
8826 +++ b/arch/sparc/kernel/syscalls.S
8827 @@ -58,7 +58,7 @@ sys32_rt_sigreturn:
8828 #endif
8829 .align 32
8830 1: ldx [%g6 + TI_FLAGS], %l5
8831 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8832 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8833 be,pt %icc, rtrap
8834 nop
8835 call syscall_trace_leave
8836 @@ -190,7 +190,7 @@ linux_sparc_syscall32:
8837
8838 srl %i5, 0, %o5 ! IEU1
8839 srl %i2, 0, %o2 ! IEU0 Group
8840 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8841 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8842 bne,pn %icc, linux_syscall_trace32 ! CTI
8843 mov %i0, %l5 ! IEU1
8844 call %l7 ! CTI Group brk forced
8845 @@ -213,7 +213,7 @@ linux_sparc_syscall:
8846
8847 mov %i3, %o3 ! IEU1
8848 mov %i4, %o4 ! IEU0 Group
8849 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8850 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8851 bne,pn %icc, linux_syscall_trace ! CTI Group
8852 mov %i0, %l5 ! IEU0
8853 2: call %l7 ! CTI Group brk forced
8854 @@ -229,7 +229,7 @@ ret_sys_call:
8855
8856 cmp %o0, -ERESTART_RESTARTBLOCK
8857 bgeu,pn %xcc, 1f
8858 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8859 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8860 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8861
8862 2:
8863 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8864 index 654e8aa..45f431b 100644
8865 --- a/arch/sparc/kernel/sysfs.c
8866 +++ b/arch/sparc/kernel/sysfs.c
8867 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8868 return NOTIFY_OK;
8869 }
8870
8871 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8872 +static struct notifier_block sysfs_cpu_nb = {
8873 .notifier_call = sysfs_cpu_notify,
8874 };
8875
8876 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8877 index a5785ea..405c5f7 100644
8878 --- a/arch/sparc/kernel/traps_32.c
8879 +++ b/arch/sparc/kernel/traps_32.c
8880 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8881 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8882 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8883
8884 +extern void gr_handle_kernel_exploit(void);
8885 +
8886 void die_if_kernel(char *str, struct pt_regs *regs)
8887 {
8888 static int die_counter;
8889 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8890 count++ < 30 &&
8891 (((unsigned long) rw) >= PAGE_OFFSET) &&
8892 !(((unsigned long) rw) & 0x7)) {
8893 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8894 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8895 (void *) rw->ins[7]);
8896 rw = (struct reg_window32 *)rw->ins[6];
8897 }
8898 }
8899 printk("Instruction DUMP:");
8900 instruction_dump ((unsigned long *) regs->pc);
8901 - if(regs->psr & PSR_PS)
8902 + if(regs->psr & PSR_PS) {
8903 + gr_handle_kernel_exploit();
8904 do_exit(SIGKILL);
8905 + }
8906 do_exit(SIGSEGV);
8907 }
8908
8909 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8910 index e7ecf15..6520e65 100644
8911 --- a/arch/sparc/kernel/traps_64.c
8912 +++ b/arch/sparc/kernel/traps_64.c
8913 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8914 i + 1,
8915 p->trapstack[i].tstate, p->trapstack[i].tpc,
8916 p->trapstack[i].tnpc, p->trapstack[i].tt);
8917 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8918 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8919 }
8920 }
8921
8922 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8923
8924 lvl -= 0x100;
8925 if (regs->tstate & TSTATE_PRIV) {
8926 +
8927 +#ifdef CONFIG_PAX_REFCOUNT
8928 + if (lvl == 6)
8929 + pax_report_refcount_overflow(regs);
8930 +#endif
8931 +
8932 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8933 die_if_kernel(buffer, regs);
8934 }
8935 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8936 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8937 {
8938 char buffer[32];
8939 -
8940 +
8941 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8942 0, lvl, SIGTRAP) == NOTIFY_STOP)
8943 return;
8944
8945 +#ifdef CONFIG_PAX_REFCOUNT
8946 + if (lvl == 6)
8947 + pax_report_refcount_overflow(regs);
8948 +#endif
8949 +
8950 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8951
8952 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8953 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8954 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8955 printk("%s" "ERROR(%d): ",
8956 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8957 - printk("TPC<%pS>\n", (void *) regs->tpc);
8958 + printk("TPC<%pA>\n", (void *) regs->tpc);
8959 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8960 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8961 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8962 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8963 smp_processor_id(),
8964 (type & 0x1) ? 'I' : 'D',
8965 regs->tpc);
8966 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8967 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8968 panic("Irrecoverable Cheetah+ parity error.");
8969 }
8970
8971 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8972 smp_processor_id(),
8973 (type & 0x1) ? 'I' : 'D',
8974 regs->tpc);
8975 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8976 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8977 }
8978
8979 struct sun4v_error_entry {
8980 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8981
8982 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8983 regs->tpc, tl);
8984 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8985 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8986 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8987 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8988 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8989 (void *) regs->u_regs[UREG_I7]);
8990 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8991 "pte[%lx] error[%lx]\n",
8992 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8993
8994 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8995 regs->tpc, tl);
8996 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8997 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8998 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8999 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9000 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9001 (void *) regs->u_regs[UREG_I7]);
9002 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9003 "pte[%lx] error[%lx]\n",
9004 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9005 fp = (unsigned long)sf->fp + STACK_BIAS;
9006 }
9007
9008 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9009 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9010 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9011 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9012 int index = tsk->curr_ret_stack;
9013 if (tsk->ret_stack && index >= graph) {
9014 pc = tsk->ret_stack[index - graph].ret;
9015 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9016 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9017 graph++;
9018 }
9019 }
9020 @@ -2367,6 +2378,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9021 return (struct reg_window *) (fp + STACK_BIAS);
9022 }
9023
9024 +extern void gr_handle_kernel_exploit(void);
9025 +
9026 void die_if_kernel(char *str, struct pt_regs *regs)
9027 {
9028 static int die_counter;
9029 @@ -2395,7 +2408,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9030 while (rw &&
9031 count++ < 30 &&
9032 kstack_valid(tp, (unsigned long) rw)) {
9033 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9034 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9035 (void *) rw->ins[7]);
9036
9037 rw = kernel_stack_up(rw);
9038 @@ -2408,8 +2421,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9039 }
9040 user_instruction_dump ((unsigned int __user *) regs->tpc);
9041 }
9042 - if (regs->tstate & TSTATE_PRIV)
9043 + if (regs->tstate & TSTATE_PRIV) {
9044 + gr_handle_kernel_exploit();
9045 do_exit(SIGKILL);
9046 + }
9047 do_exit(SIGSEGV);
9048 }
9049 EXPORT_SYMBOL(die_if_kernel);
9050 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9051 index 8201c25e..072a2a7 100644
9052 --- a/arch/sparc/kernel/unaligned_64.c
9053 +++ b/arch/sparc/kernel/unaligned_64.c
9054 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9055 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9056
9057 if (__ratelimit(&ratelimit)) {
9058 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9059 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9060 regs->tpc, (void *) regs->tpc);
9061 }
9062 }
9063 diff --git a/arch/sparc/kernel/us3_cpufreq.c b/arch/sparc/kernel/us3_cpufreq.c
9064 index eb1624b..f9f4ddb 100644
9065 --- a/arch/sparc/kernel/us3_cpufreq.c
9066 +++ b/arch/sparc/kernel/us3_cpufreq.c
9067 @@ -18,14 +18,12 @@
9068 #include <asm/head.h>
9069 #include <asm/timer.h>
9070
9071 -static struct cpufreq_driver *cpufreq_us3_driver;
9072 -
9073 struct us3_freq_percpu_info {
9074 struct cpufreq_frequency_table table[4];
9075 };
9076
9077 /* Indexed by cpu number. */
9078 -static struct us3_freq_percpu_info *us3_freq_table;
9079 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
9080
9081 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
9082 * in the Safari config register.
9083 @@ -191,12 +189,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
9084
9085 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
9086 {
9087 - if (cpufreq_us3_driver)
9088 - us3_set_cpu_divider_index(policy->cpu, 0);
9089 + us3_set_cpu_divider_index(policy->cpu, 0);
9090
9091 return 0;
9092 }
9093
9094 +static int __init us3_freq_init(void);
9095 +static void __exit us3_freq_exit(void);
9096 +
9097 +static struct cpufreq_driver cpufreq_us3_driver = {
9098 + .init = us3_freq_cpu_init,
9099 + .verify = us3_freq_verify,
9100 + .target = us3_freq_target,
9101 + .get = us3_freq_get,
9102 + .exit = us3_freq_cpu_exit,
9103 + .owner = THIS_MODULE,
9104 + .name = "UltraSPARC-III",
9105 +
9106 +};
9107 +
9108 static int __init us3_freq_init(void)
9109 {
9110 unsigned long manuf, impl, ver;
9111 @@ -213,57 +224,15 @@ static int __init us3_freq_init(void)
9112 (impl == CHEETAH_IMPL ||
9113 impl == CHEETAH_PLUS_IMPL ||
9114 impl == JAGUAR_IMPL ||
9115 - impl == PANTHER_IMPL)) {
9116 - struct cpufreq_driver *driver;
9117 -
9118 - ret = -ENOMEM;
9119 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
9120 - if (!driver)
9121 - goto err_out;
9122 -
9123 - us3_freq_table = kzalloc(
9124 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
9125 - GFP_KERNEL);
9126 - if (!us3_freq_table)
9127 - goto err_out;
9128 -
9129 - driver->init = us3_freq_cpu_init;
9130 - driver->verify = us3_freq_verify;
9131 - driver->target = us3_freq_target;
9132 - driver->get = us3_freq_get;
9133 - driver->exit = us3_freq_cpu_exit;
9134 - driver->owner = THIS_MODULE,
9135 - strcpy(driver->name, "UltraSPARC-III");
9136 -
9137 - cpufreq_us3_driver = driver;
9138 - ret = cpufreq_register_driver(driver);
9139 - if (ret)
9140 - goto err_out;
9141 -
9142 - return 0;
9143 -
9144 -err_out:
9145 - if (driver) {
9146 - kfree(driver);
9147 - cpufreq_us3_driver = NULL;
9148 - }
9149 - kfree(us3_freq_table);
9150 - us3_freq_table = NULL;
9151 - return ret;
9152 - }
9153 + impl == PANTHER_IMPL))
9154 + return cpufreq_register_driver(cpufreq_us3_driver);
9155
9156 return -ENODEV;
9157 }
9158
9159 static void __exit us3_freq_exit(void)
9160 {
9161 - if (cpufreq_us3_driver) {
9162 - cpufreq_unregister_driver(cpufreq_us3_driver);
9163 - kfree(cpufreq_us3_driver);
9164 - cpufreq_us3_driver = NULL;
9165 - kfree(us3_freq_table);
9166 - us3_freq_table = NULL;
9167 - }
9168 + cpufreq_unregister_driver(cpufreq_us3_driver);
9169 }
9170
9171 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
9172 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9173 index 8410065f2..4fd4ca22 100644
9174 --- a/arch/sparc/lib/Makefile
9175 +++ b/arch/sparc/lib/Makefile
9176 @@ -2,7 +2,7 @@
9177 #
9178
9179 asflags-y := -ansi -DST_DIV0=0x02
9180 -ccflags-y := -Werror
9181 +#ccflags-y := -Werror
9182
9183 lib-$(CONFIG_SPARC32) += ashrdi3.o
9184 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9185 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9186 index 85c233d..68500e0 100644
9187 --- a/arch/sparc/lib/atomic_64.S
9188 +++ b/arch/sparc/lib/atomic_64.S
9189 @@ -17,7 +17,12 @@
9190 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9191 BACKOFF_SETUP(%o2)
9192 1: lduw [%o1], %g1
9193 - add %g1, %o0, %g7
9194 + addcc %g1, %o0, %g7
9195 +
9196 +#ifdef CONFIG_PAX_REFCOUNT
9197 + tvs %icc, 6
9198 +#endif
9199 +
9200 cas [%o1], %g1, %g7
9201 cmp %g1, %g7
9202 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9203 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9204 2: BACKOFF_SPIN(%o2, %o3, 1b)
9205 ENDPROC(atomic_add)
9206
9207 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9208 + BACKOFF_SETUP(%o2)
9209 +1: lduw [%o1], %g1
9210 + add %g1, %o0, %g7
9211 + cas [%o1], %g1, %g7
9212 + cmp %g1, %g7
9213 + bne,pn %icc, 2f
9214 + nop
9215 + retl
9216 + nop
9217 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9218 +ENDPROC(atomic_add_unchecked)
9219 +
9220 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9221 BACKOFF_SETUP(%o2)
9222 1: lduw [%o1], %g1
9223 - sub %g1, %o0, %g7
9224 + subcc %g1, %o0, %g7
9225 +
9226 +#ifdef CONFIG_PAX_REFCOUNT
9227 + tvs %icc, 6
9228 +#endif
9229 +
9230 cas [%o1], %g1, %g7
9231 cmp %g1, %g7
9232 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9233 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9234 2: BACKOFF_SPIN(%o2, %o3, 1b)
9235 ENDPROC(atomic_sub)
9236
9237 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9238 + BACKOFF_SETUP(%o2)
9239 +1: lduw [%o1], %g1
9240 + sub %g1, %o0, %g7
9241 + cas [%o1], %g1, %g7
9242 + cmp %g1, %g7
9243 + bne,pn %icc, 2f
9244 + nop
9245 + retl
9246 + nop
9247 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9248 +ENDPROC(atomic_sub_unchecked)
9249 +
9250 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9251 BACKOFF_SETUP(%o2)
9252 1: lduw [%o1], %g1
9253 - add %g1, %o0, %g7
9254 + addcc %g1, %o0, %g7
9255 +
9256 +#ifdef CONFIG_PAX_REFCOUNT
9257 + tvs %icc, 6
9258 +#endif
9259 +
9260 cas [%o1], %g1, %g7
9261 cmp %g1, %g7
9262 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9263 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9264 2: BACKOFF_SPIN(%o2, %o3, 1b)
9265 ENDPROC(atomic_add_ret)
9266
9267 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9268 + BACKOFF_SETUP(%o2)
9269 +1: lduw [%o1], %g1
9270 + addcc %g1, %o0, %g7
9271 + cas [%o1], %g1, %g7
9272 + cmp %g1, %g7
9273 + bne,pn %icc, 2f
9274 + add %g7, %o0, %g7
9275 + sra %g7, 0, %o0
9276 + retl
9277 + nop
9278 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9279 +ENDPROC(atomic_add_ret_unchecked)
9280 +
9281 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9282 BACKOFF_SETUP(%o2)
9283 1: lduw [%o1], %g1
9284 - sub %g1, %o0, %g7
9285 + subcc %g1, %o0, %g7
9286 +
9287 +#ifdef CONFIG_PAX_REFCOUNT
9288 + tvs %icc, 6
9289 +#endif
9290 +
9291 cas [%o1], %g1, %g7
9292 cmp %g1, %g7
9293 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9294 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9295 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9296 BACKOFF_SETUP(%o2)
9297 1: ldx [%o1], %g1
9298 - add %g1, %o0, %g7
9299 + addcc %g1, %o0, %g7
9300 +
9301 +#ifdef CONFIG_PAX_REFCOUNT
9302 + tvs %xcc, 6
9303 +#endif
9304 +
9305 casx [%o1], %g1, %g7
9306 cmp %g1, %g7
9307 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9308 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9309 2: BACKOFF_SPIN(%o2, %o3, 1b)
9310 ENDPROC(atomic64_add)
9311
9312 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9313 + BACKOFF_SETUP(%o2)
9314 +1: ldx [%o1], %g1
9315 + addcc %g1, %o0, %g7
9316 + casx [%o1], %g1, %g7
9317 + cmp %g1, %g7
9318 + bne,pn %xcc, 2f
9319 + nop
9320 + retl
9321 + nop
9322 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9323 +ENDPROC(atomic64_add_unchecked)
9324 +
9325 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9326 BACKOFF_SETUP(%o2)
9327 1: ldx [%o1], %g1
9328 - sub %g1, %o0, %g7
9329 + subcc %g1, %o0, %g7
9330 +
9331 +#ifdef CONFIG_PAX_REFCOUNT
9332 + tvs %xcc, 6
9333 +#endif
9334 +
9335 casx [%o1], %g1, %g7
9336 cmp %g1, %g7
9337 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9338 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9339 2: BACKOFF_SPIN(%o2, %o3, 1b)
9340 ENDPROC(atomic64_sub)
9341
9342 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9343 + BACKOFF_SETUP(%o2)
9344 +1: ldx [%o1], %g1
9345 + subcc %g1, %o0, %g7
9346 + casx [%o1], %g1, %g7
9347 + cmp %g1, %g7
9348 + bne,pn %xcc, 2f
9349 + nop
9350 + retl
9351 + nop
9352 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9353 +ENDPROC(atomic64_sub_unchecked)
9354 +
9355 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9356 BACKOFF_SETUP(%o2)
9357 1: ldx [%o1], %g1
9358 - add %g1, %o0, %g7
9359 + addcc %g1, %o0, %g7
9360 +
9361 +#ifdef CONFIG_PAX_REFCOUNT
9362 + tvs %xcc, 6
9363 +#endif
9364 +
9365 casx [%o1], %g1, %g7
9366 cmp %g1, %g7
9367 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9368 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9369 2: BACKOFF_SPIN(%o2, %o3, 1b)
9370 ENDPROC(atomic64_add_ret)
9371
9372 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9373 + BACKOFF_SETUP(%o2)
9374 +1: ldx [%o1], %g1
9375 + addcc %g1, %o0, %g7
9376 + casx [%o1], %g1, %g7
9377 + cmp %g1, %g7
9378 + bne,pn %xcc, 2f
9379 + add %g7, %o0, %g7
9380 + mov %g7, %o0
9381 + retl
9382 + nop
9383 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9384 +ENDPROC(atomic64_add_ret_unchecked)
9385 +
9386 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9387 BACKOFF_SETUP(%o2)
9388 1: ldx [%o1], %g1
9389 - sub %g1, %o0, %g7
9390 + subcc %g1, %o0, %g7
9391 +
9392 +#ifdef CONFIG_PAX_REFCOUNT
9393 + tvs %xcc, 6
9394 +#endif
9395 +
9396 casx [%o1], %g1, %g7
9397 cmp %g1, %g7
9398 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9399 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9400 index 0c4e35e..745d3e4 100644
9401 --- a/arch/sparc/lib/ksyms.c
9402 +++ b/arch/sparc/lib/ksyms.c
9403 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9404
9405 /* Atomic counter implementation. */
9406 EXPORT_SYMBOL(atomic_add);
9407 +EXPORT_SYMBOL(atomic_add_unchecked);
9408 EXPORT_SYMBOL(atomic_add_ret);
9409 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9410 EXPORT_SYMBOL(atomic_sub);
9411 +EXPORT_SYMBOL(atomic_sub_unchecked);
9412 EXPORT_SYMBOL(atomic_sub_ret);
9413 EXPORT_SYMBOL(atomic64_add);
9414 +EXPORT_SYMBOL(atomic64_add_unchecked);
9415 EXPORT_SYMBOL(atomic64_add_ret);
9416 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9417 EXPORT_SYMBOL(atomic64_sub);
9418 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9419 EXPORT_SYMBOL(atomic64_sub_ret);
9420 EXPORT_SYMBOL(atomic64_dec_if_positive);
9421
9422 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9423 index 30c3ecc..736f015 100644
9424 --- a/arch/sparc/mm/Makefile
9425 +++ b/arch/sparc/mm/Makefile
9426 @@ -2,7 +2,7 @@
9427 #
9428
9429 asflags-y := -ansi
9430 -ccflags-y := -Werror
9431 +#ccflags-y := -Werror
9432
9433 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9434 obj-y += fault_$(BITS).o
9435 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9436 index e98bfda..ea8d221 100644
9437 --- a/arch/sparc/mm/fault_32.c
9438 +++ b/arch/sparc/mm/fault_32.c
9439 @@ -21,6 +21,9 @@
9440 #include <linux/perf_event.h>
9441 #include <linux/interrupt.h>
9442 #include <linux/kdebug.h>
9443 +#include <linux/slab.h>
9444 +#include <linux/pagemap.h>
9445 +#include <linux/compiler.h>
9446
9447 #include <asm/page.h>
9448 #include <asm/pgtable.h>
9449 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9450 return safe_compute_effective_address(regs, insn);
9451 }
9452
9453 +#ifdef CONFIG_PAX_PAGEEXEC
9454 +#ifdef CONFIG_PAX_DLRESOLVE
9455 +static void pax_emuplt_close(struct vm_area_struct *vma)
9456 +{
9457 + vma->vm_mm->call_dl_resolve = 0UL;
9458 +}
9459 +
9460 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9461 +{
9462 + unsigned int *kaddr;
9463 +
9464 + vmf->page = alloc_page(GFP_HIGHUSER);
9465 + if (!vmf->page)
9466 + return VM_FAULT_OOM;
9467 +
9468 + kaddr = kmap(vmf->page);
9469 + memset(kaddr, 0, PAGE_SIZE);
9470 + kaddr[0] = 0x9DE3BFA8U; /* save */
9471 + flush_dcache_page(vmf->page);
9472 + kunmap(vmf->page);
9473 + return VM_FAULT_MAJOR;
9474 +}
9475 +
9476 +static const struct vm_operations_struct pax_vm_ops = {
9477 + .close = pax_emuplt_close,
9478 + .fault = pax_emuplt_fault
9479 +};
9480 +
9481 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9482 +{
9483 + int ret;
9484 +
9485 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9486 + vma->vm_mm = current->mm;
9487 + vma->vm_start = addr;
9488 + vma->vm_end = addr + PAGE_SIZE;
9489 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9490 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9491 + vma->vm_ops = &pax_vm_ops;
9492 +
9493 + ret = insert_vm_struct(current->mm, vma);
9494 + if (ret)
9495 + return ret;
9496 +
9497 + ++current->mm->total_vm;
9498 + return 0;
9499 +}
9500 +#endif
9501 +
9502 +/*
9503 + * PaX: decide what to do with offenders (regs->pc = fault address)
9504 + *
9505 + * returns 1 when task should be killed
9506 + * 2 when patched PLT trampoline was detected
9507 + * 3 when unpatched PLT trampoline was detected
9508 + */
9509 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9510 +{
9511 +
9512 +#ifdef CONFIG_PAX_EMUPLT
9513 + int err;
9514 +
9515 + do { /* PaX: patched PLT emulation #1 */
9516 + unsigned int sethi1, sethi2, jmpl;
9517 +
9518 + err = get_user(sethi1, (unsigned int *)regs->pc);
9519 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9520 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9521 +
9522 + if (err)
9523 + break;
9524 +
9525 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9526 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9527 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9528 + {
9529 + unsigned int addr;
9530 +
9531 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9532 + addr = regs->u_regs[UREG_G1];
9533 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9534 + regs->pc = addr;
9535 + regs->npc = addr+4;
9536 + return 2;
9537 + }
9538 + } while (0);
9539 +
9540 + do { /* PaX: patched PLT emulation #2 */
9541 + unsigned int ba;
9542 +
9543 + err = get_user(ba, (unsigned int *)regs->pc);
9544 +
9545 + if (err)
9546 + break;
9547 +
9548 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9549 + unsigned int addr;
9550 +
9551 + if ((ba & 0xFFC00000U) == 0x30800000U)
9552 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9553 + else
9554 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9555 + regs->pc = addr;
9556 + regs->npc = addr+4;
9557 + return 2;
9558 + }
9559 + } while (0);
9560 +
9561 + do { /* PaX: patched PLT emulation #3 */
9562 + unsigned int sethi, bajmpl, nop;
9563 +
9564 + err = get_user(sethi, (unsigned int *)regs->pc);
9565 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9566 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9567 +
9568 + if (err)
9569 + break;
9570 +
9571 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9572 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9573 + nop == 0x01000000U)
9574 + {
9575 + unsigned int addr;
9576 +
9577 + addr = (sethi & 0x003FFFFFU) << 10;
9578 + regs->u_regs[UREG_G1] = addr;
9579 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9580 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9581 + else
9582 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9583 + regs->pc = addr;
9584 + regs->npc = addr+4;
9585 + return 2;
9586 + }
9587 + } while (0);
9588 +
9589 + do { /* PaX: unpatched PLT emulation step 1 */
9590 + unsigned int sethi, ba, nop;
9591 +
9592 + err = get_user(sethi, (unsigned int *)regs->pc);
9593 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9594 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9595 +
9596 + if (err)
9597 + break;
9598 +
9599 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9600 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9601 + nop == 0x01000000U)
9602 + {
9603 + unsigned int addr, save, call;
9604 +
9605 + if ((ba & 0xFFC00000U) == 0x30800000U)
9606 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9607 + else
9608 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9609 +
9610 + err = get_user(save, (unsigned int *)addr);
9611 + err |= get_user(call, (unsigned int *)(addr+4));
9612 + err |= get_user(nop, (unsigned int *)(addr+8));
9613 + if (err)
9614 + break;
9615 +
9616 +#ifdef CONFIG_PAX_DLRESOLVE
9617 + if (save == 0x9DE3BFA8U &&
9618 + (call & 0xC0000000U) == 0x40000000U &&
9619 + nop == 0x01000000U)
9620 + {
9621 + struct vm_area_struct *vma;
9622 + unsigned long call_dl_resolve;
9623 +
9624 + down_read(&current->mm->mmap_sem);
9625 + call_dl_resolve = current->mm->call_dl_resolve;
9626 + up_read(&current->mm->mmap_sem);
9627 + if (likely(call_dl_resolve))
9628 + goto emulate;
9629 +
9630 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9631 +
9632 + down_write(&current->mm->mmap_sem);
9633 + if (current->mm->call_dl_resolve) {
9634 + call_dl_resolve = current->mm->call_dl_resolve;
9635 + up_write(&current->mm->mmap_sem);
9636 + if (vma)
9637 + kmem_cache_free(vm_area_cachep, vma);
9638 + goto emulate;
9639 + }
9640 +
9641 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9642 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9643 + up_write(&current->mm->mmap_sem);
9644 + if (vma)
9645 + kmem_cache_free(vm_area_cachep, vma);
9646 + return 1;
9647 + }
9648 +
9649 + if (pax_insert_vma(vma, call_dl_resolve)) {
9650 + up_write(&current->mm->mmap_sem);
9651 + kmem_cache_free(vm_area_cachep, vma);
9652 + return 1;
9653 + }
9654 +
9655 + current->mm->call_dl_resolve = call_dl_resolve;
9656 + up_write(&current->mm->mmap_sem);
9657 +
9658 +emulate:
9659 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9660 + regs->pc = call_dl_resolve;
9661 + regs->npc = addr+4;
9662 + return 3;
9663 + }
9664 +#endif
9665 +
9666 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9667 + if ((save & 0xFFC00000U) == 0x05000000U &&
9668 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9669 + nop == 0x01000000U)
9670 + {
9671 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9672 + regs->u_regs[UREG_G2] = addr + 4;
9673 + addr = (save & 0x003FFFFFU) << 10;
9674 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9675 + regs->pc = addr;
9676 + regs->npc = addr+4;
9677 + return 3;
9678 + }
9679 + }
9680 + } while (0);
9681 +
9682 + do { /* PaX: unpatched PLT emulation step 2 */
9683 + unsigned int save, call, nop;
9684 +
9685 + err = get_user(save, (unsigned int *)(regs->pc-4));
9686 + err |= get_user(call, (unsigned int *)regs->pc);
9687 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9688 + if (err)
9689 + break;
9690 +
9691 + if (save == 0x9DE3BFA8U &&
9692 + (call & 0xC0000000U) == 0x40000000U &&
9693 + nop == 0x01000000U)
9694 + {
9695 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9696 +
9697 + regs->u_regs[UREG_RETPC] = regs->pc;
9698 + regs->pc = dl_resolve;
9699 + regs->npc = dl_resolve+4;
9700 + return 3;
9701 + }
9702 + } while (0);
9703 +#endif
9704 +
9705 + return 1;
9706 +}
9707 +
9708 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9709 +{
9710 + unsigned long i;
9711 +
9712 + printk(KERN_ERR "PAX: bytes at PC: ");
9713 + for (i = 0; i < 8; i++) {
9714 + unsigned int c;
9715 + if (get_user(c, (unsigned int *)pc+i))
9716 + printk(KERN_CONT "???????? ");
9717 + else
9718 + printk(KERN_CONT "%08x ", c);
9719 + }
9720 + printk("\n");
9721 +}
9722 +#endif
9723 +
9724 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9725 int text_fault)
9726 {
9727 @@ -230,6 +504,24 @@ good_area:
9728 if (!(vma->vm_flags & VM_WRITE))
9729 goto bad_area;
9730 } else {
9731 +
9732 +#ifdef CONFIG_PAX_PAGEEXEC
9733 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9734 + up_read(&mm->mmap_sem);
9735 + switch (pax_handle_fetch_fault(regs)) {
9736 +
9737 +#ifdef CONFIG_PAX_EMUPLT
9738 + case 2:
9739 + case 3:
9740 + return;
9741 +#endif
9742 +
9743 + }
9744 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9745 + do_group_exit(SIGKILL);
9746 + }
9747 +#endif
9748 +
9749 /* Allow reads even for write-only mappings */
9750 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9751 goto bad_area;
9752 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9753 index 5062ff3..e0b75f3 100644
9754 --- a/arch/sparc/mm/fault_64.c
9755 +++ b/arch/sparc/mm/fault_64.c
9756 @@ -21,6 +21,9 @@
9757 #include <linux/kprobes.h>
9758 #include <linux/kdebug.h>
9759 #include <linux/percpu.h>
9760 +#include <linux/slab.h>
9761 +#include <linux/pagemap.h>
9762 +#include <linux/compiler.h>
9763
9764 #include <asm/page.h>
9765 #include <asm/pgtable.h>
9766 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9767 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9768 regs->tpc);
9769 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9770 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9771 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9772 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9773 dump_stack();
9774 unhandled_fault(regs->tpc, current, regs);
9775 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9776 show_regs(regs);
9777 }
9778
9779 +#ifdef CONFIG_PAX_PAGEEXEC
9780 +#ifdef CONFIG_PAX_DLRESOLVE
9781 +static void pax_emuplt_close(struct vm_area_struct *vma)
9782 +{
9783 + vma->vm_mm->call_dl_resolve = 0UL;
9784 +}
9785 +
9786 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9787 +{
9788 + unsigned int *kaddr;
9789 +
9790 + vmf->page = alloc_page(GFP_HIGHUSER);
9791 + if (!vmf->page)
9792 + return VM_FAULT_OOM;
9793 +
9794 + kaddr = kmap(vmf->page);
9795 + memset(kaddr, 0, PAGE_SIZE);
9796 + kaddr[0] = 0x9DE3BFA8U; /* save */
9797 + flush_dcache_page(vmf->page);
9798 + kunmap(vmf->page);
9799 + return VM_FAULT_MAJOR;
9800 +}
9801 +
9802 +static const struct vm_operations_struct pax_vm_ops = {
9803 + .close = pax_emuplt_close,
9804 + .fault = pax_emuplt_fault
9805 +};
9806 +
9807 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9808 +{
9809 + int ret;
9810 +
9811 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9812 + vma->vm_mm = current->mm;
9813 + vma->vm_start = addr;
9814 + vma->vm_end = addr + PAGE_SIZE;
9815 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9816 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9817 + vma->vm_ops = &pax_vm_ops;
9818 +
9819 + ret = insert_vm_struct(current->mm, vma);
9820 + if (ret)
9821 + return ret;
9822 +
9823 + ++current->mm->total_vm;
9824 + return 0;
9825 +}
9826 +#endif
9827 +
9828 +/*
9829 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9830 + *
9831 + * returns 1 when task should be killed
9832 + * 2 when patched PLT trampoline was detected
9833 + * 3 when unpatched PLT trampoline was detected
9834 + */
9835 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9836 +{
9837 +
9838 +#ifdef CONFIG_PAX_EMUPLT
9839 + int err;
9840 +
9841 + do { /* PaX: patched PLT emulation #1 */
9842 + unsigned int sethi1, sethi2, jmpl;
9843 +
9844 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9845 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9846 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9847 +
9848 + if (err)
9849 + break;
9850 +
9851 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9852 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9853 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9854 + {
9855 + unsigned long addr;
9856 +
9857 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9858 + addr = regs->u_regs[UREG_G1];
9859 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9860 +
9861 + if (test_thread_flag(TIF_32BIT))
9862 + addr &= 0xFFFFFFFFUL;
9863 +
9864 + regs->tpc = addr;
9865 + regs->tnpc = addr+4;
9866 + return 2;
9867 + }
9868 + } while (0);
9869 +
9870 + do { /* PaX: patched PLT emulation #2 */
9871 + unsigned int ba;
9872 +
9873 + err = get_user(ba, (unsigned int *)regs->tpc);
9874 +
9875 + if (err)
9876 + break;
9877 +
9878 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9879 + unsigned long addr;
9880 +
9881 + if ((ba & 0xFFC00000U) == 0x30800000U)
9882 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9883 + else
9884 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9885 +
9886 + if (test_thread_flag(TIF_32BIT))
9887 + addr &= 0xFFFFFFFFUL;
9888 +
9889 + regs->tpc = addr;
9890 + regs->tnpc = addr+4;
9891 + return 2;
9892 + }
9893 + } while (0);
9894 +
9895 + do { /* PaX: patched PLT emulation #3 */
9896 + unsigned int sethi, bajmpl, nop;
9897 +
9898 + err = get_user(sethi, (unsigned int *)regs->tpc);
9899 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9900 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9901 +
9902 + if (err)
9903 + break;
9904 +
9905 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9906 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9907 + nop == 0x01000000U)
9908 + {
9909 + unsigned long addr;
9910 +
9911 + addr = (sethi & 0x003FFFFFU) << 10;
9912 + regs->u_regs[UREG_G1] = addr;
9913 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9914 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9915 + else
9916 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9917 +
9918 + if (test_thread_flag(TIF_32BIT))
9919 + addr &= 0xFFFFFFFFUL;
9920 +
9921 + regs->tpc = addr;
9922 + regs->tnpc = addr+4;
9923 + return 2;
9924 + }
9925 + } while (0);
9926 +
9927 + do { /* PaX: patched PLT emulation #4 */
9928 + unsigned int sethi, mov1, call, mov2;
9929 +
9930 + err = get_user(sethi, (unsigned int *)regs->tpc);
9931 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9932 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9933 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9934 +
9935 + if (err)
9936 + break;
9937 +
9938 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9939 + mov1 == 0x8210000FU &&
9940 + (call & 0xC0000000U) == 0x40000000U &&
9941 + mov2 == 0x9E100001U)
9942 + {
9943 + unsigned long addr;
9944 +
9945 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9946 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9947 +
9948 + if (test_thread_flag(TIF_32BIT))
9949 + addr &= 0xFFFFFFFFUL;
9950 +
9951 + regs->tpc = addr;
9952 + regs->tnpc = addr+4;
9953 + return 2;
9954 + }
9955 + } while (0);
9956 +
9957 + do { /* PaX: patched PLT emulation #5 */
9958 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9959 +
9960 + err = get_user(sethi, (unsigned int *)regs->tpc);
9961 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9962 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9963 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9964 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9965 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9966 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9967 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9968 +
9969 + if (err)
9970 + break;
9971 +
9972 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9973 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9974 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9975 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9976 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9977 + sllx == 0x83287020U &&
9978 + jmpl == 0x81C04005U &&
9979 + nop == 0x01000000U)
9980 + {
9981 + unsigned long addr;
9982 +
9983 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9984 + regs->u_regs[UREG_G1] <<= 32;
9985 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9986 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9987 + regs->tpc = addr;
9988 + regs->tnpc = addr+4;
9989 + return 2;
9990 + }
9991 + } while (0);
9992 +
9993 + do { /* PaX: patched PLT emulation #6 */
9994 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9995 +
9996 + err = get_user(sethi, (unsigned int *)regs->tpc);
9997 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9998 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9999 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10000 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10001 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10002 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10003 +
10004 + if (err)
10005 + break;
10006 +
10007 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10008 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10009 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10010 + sllx == 0x83287020U &&
10011 + (or & 0xFFFFE000U) == 0x8A116000U &&
10012 + jmpl == 0x81C04005U &&
10013 + nop == 0x01000000U)
10014 + {
10015 + unsigned long addr;
10016 +
10017 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
10018 + regs->u_regs[UREG_G1] <<= 32;
10019 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
10020 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10021 + regs->tpc = addr;
10022 + regs->tnpc = addr+4;
10023 + return 2;
10024 + }
10025 + } while (0);
10026 +
10027 + do { /* PaX: unpatched PLT emulation step 1 */
10028 + unsigned int sethi, ba, nop;
10029 +
10030 + err = get_user(sethi, (unsigned int *)regs->tpc);
10031 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10032 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10033 +
10034 + if (err)
10035 + break;
10036 +
10037 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10038 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10039 + nop == 0x01000000U)
10040 + {
10041 + unsigned long addr;
10042 + unsigned int save, call;
10043 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
10044 +
10045 + if ((ba & 0xFFC00000U) == 0x30800000U)
10046 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10047 + else
10048 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10049 +
10050 + if (test_thread_flag(TIF_32BIT))
10051 + addr &= 0xFFFFFFFFUL;
10052 +
10053 + err = get_user(save, (unsigned int *)addr);
10054 + err |= get_user(call, (unsigned int *)(addr+4));
10055 + err |= get_user(nop, (unsigned int *)(addr+8));
10056 + if (err)
10057 + break;
10058 +
10059 +#ifdef CONFIG_PAX_DLRESOLVE
10060 + if (save == 0x9DE3BFA8U &&
10061 + (call & 0xC0000000U) == 0x40000000U &&
10062 + nop == 0x01000000U)
10063 + {
10064 + struct vm_area_struct *vma;
10065 + unsigned long call_dl_resolve;
10066 +
10067 + down_read(&current->mm->mmap_sem);
10068 + call_dl_resolve = current->mm->call_dl_resolve;
10069 + up_read(&current->mm->mmap_sem);
10070 + if (likely(call_dl_resolve))
10071 + goto emulate;
10072 +
10073 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10074 +
10075 + down_write(&current->mm->mmap_sem);
10076 + if (current->mm->call_dl_resolve) {
10077 + call_dl_resolve = current->mm->call_dl_resolve;
10078 + up_write(&current->mm->mmap_sem);
10079 + if (vma)
10080 + kmem_cache_free(vm_area_cachep, vma);
10081 + goto emulate;
10082 + }
10083 +
10084 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10085 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10086 + up_write(&current->mm->mmap_sem);
10087 + if (vma)
10088 + kmem_cache_free(vm_area_cachep, vma);
10089 + return 1;
10090 + }
10091 +
10092 + if (pax_insert_vma(vma, call_dl_resolve)) {
10093 + up_write(&current->mm->mmap_sem);
10094 + kmem_cache_free(vm_area_cachep, vma);
10095 + return 1;
10096 + }
10097 +
10098 + current->mm->call_dl_resolve = call_dl_resolve;
10099 + up_write(&current->mm->mmap_sem);
10100 +
10101 +emulate:
10102 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10103 + regs->tpc = call_dl_resolve;
10104 + regs->tnpc = addr+4;
10105 + return 3;
10106 + }
10107 +#endif
10108 +
10109 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10110 + if ((save & 0xFFC00000U) == 0x05000000U &&
10111 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10112 + nop == 0x01000000U)
10113 + {
10114 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10115 + regs->u_regs[UREG_G2] = addr + 4;
10116 + addr = (save & 0x003FFFFFU) << 10;
10117 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10118 +
10119 + if (test_thread_flag(TIF_32BIT))
10120 + addr &= 0xFFFFFFFFUL;
10121 +
10122 + regs->tpc = addr;
10123 + regs->tnpc = addr+4;
10124 + return 3;
10125 + }
10126 +
10127 + /* PaX: 64-bit PLT stub */
10128 + err = get_user(sethi1, (unsigned int *)addr);
10129 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10130 + err |= get_user(or1, (unsigned int *)(addr+8));
10131 + err |= get_user(or2, (unsigned int *)(addr+12));
10132 + err |= get_user(sllx, (unsigned int *)(addr+16));
10133 + err |= get_user(add, (unsigned int *)(addr+20));
10134 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10135 + err |= get_user(nop, (unsigned int *)(addr+28));
10136 + if (err)
10137 + break;
10138 +
10139 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10140 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10141 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10142 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10143 + sllx == 0x89293020U &&
10144 + add == 0x8A010005U &&
10145 + jmpl == 0x89C14000U &&
10146 + nop == 0x01000000U)
10147 + {
10148 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10149 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10150 + regs->u_regs[UREG_G4] <<= 32;
10151 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10152 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10153 + regs->u_regs[UREG_G4] = addr + 24;
10154 + addr = regs->u_regs[UREG_G5];
10155 + regs->tpc = addr;
10156 + regs->tnpc = addr+4;
10157 + return 3;
10158 + }
10159 + }
10160 + } while (0);
10161 +
10162 +#ifdef CONFIG_PAX_DLRESOLVE
10163 + do { /* PaX: unpatched PLT emulation step 2 */
10164 + unsigned int save, call, nop;
10165 +
10166 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10167 + err |= get_user(call, (unsigned int *)regs->tpc);
10168 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10169 + if (err)
10170 + break;
10171 +
10172 + if (save == 0x9DE3BFA8U &&
10173 + (call & 0xC0000000U) == 0x40000000U &&
10174 + nop == 0x01000000U)
10175 + {
10176 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10177 +
10178 + if (test_thread_flag(TIF_32BIT))
10179 + dl_resolve &= 0xFFFFFFFFUL;
10180 +
10181 + regs->u_regs[UREG_RETPC] = regs->tpc;
10182 + regs->tpc = dl_resolve;
10183 + regs->tnpc = dl_resolve+4;
10184 + return 3;
10185 + }
10186 + } while (0);
10187 +#endif
10188 +
10189 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10190 + unsigned int sethi, ba, nop;
10191 +
10192 + err = get_user(sethi, (unsigned int *)regs->tpc);
10193 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10194 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10195 +
10196 + if (err)
10197 + break;
10198 +
10199 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10200 + (ba & 0xFFF00000U) == 0x30600000U &&
10201 + nop == 0x01000000U)
10202 + {
10203 + unsigned long addr;
10204 +
10205 + addr = (sethi & 0x003FFFFFU) << 10;
10206 + regs->u_regs[UREG_G1] = addr;
10207 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10208 +
10209 + if (test_thread_flag(TIF_32BIT))
10210 + addr &= 0xFFFFFFFFUL;
10211 +
10212 + regs->tpc = addr;
10213 + regs->tnpc = addr+4;
10214 + return 2;
10215 + }
10216 + } while (0);
10217 +
10218 +#endif
10219 +
10220 + return 1;
10221 +}
10222 +
10223 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10224 +{
10225 + unsigned long i;
10226 +
10227 + printk(KERN_ERR "PAX: bytes at PC: ");
10228 + for (i = 0; i < 8; i++) {
10229 + unsigned int c;
10230 + if (get_user(c, (unsigned int *)pc+i))
10231 + printk(KERN_CONT "???????? ");
10232 + else
10233 + printk(KERN_CONT "%08x ", c);
10234 + }
10235 + printk("\n");
10236 +}
10237 +#endif
10238 +
10239 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10240 {
10241 struct mm_struct *mm = current->mm;
10242 @@ -341,6 +804,29 @@ retry:
10243 if (!vma)
10244 goto bad_area;
10245
10246 +#ifdef CONFIG_PAX_PAGEEXEC
10247 + /* PaX: detect ITLB misses on non-exec pages */
10248 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10249 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10250 + {
10251 + if (address != regs->tpc)
10252 + goto good_area;
10253 +
10254 + up_read(&mm->mmap_sem);
10255 + switch (pax_handle_fetch_fault(regs)) {
10256 +
10257 +#ifdef CONFIG_PAX_EMUPLT
10258 + case 2:
10259 + case 3:
10260 + return;
10261 +#endif
10262 +
10263 + }
10264 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10265 + do_group_exit(SIGKILL);
10266 + }
10267 +#endif
10268 +
10269 /* Pure DTLB misses do not tell us whether the fault causing
10270 * load/store/atomic was a write or not, it only says that there
10271 * was no match. So in such a case we (carefully) read the
10272 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10273 index d2b5944..bd813f2 100644
10274 --- a/arch/sparc/mm/hugetlbpage.c
10275 +++ b/arch/sparc/mm/hugetlbpage.c
10276 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10277
10278 info.flags = 0;
10279 info.length = len;
10280 - info.low_limit = TASK_UNMAPPED_BASE;
10281 + info.low_limit = mm->mmap_base;
10282 info.high_limit = min(task_size, VA_EXCLUDE_START);
10283 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10284 info.align_offset = 0;
10285 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10286 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10287 VM_BUG_ON(addr != -ENOMEM);
10288 info.low_limit = VA_EXCLUDE_END;
10289 +
10290 +#ifdef CONFIG_PAX_RANDMMAP
10291 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10292 + info.low_limit += mm->delta_mmap;
10293 +#endif
10294 +
10295 info.high_limit = task_size;
10296 addr = vm_unmapped_area(&info);
10297 }
10298 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10299 VM_BUG_ON(addr != -ENOMEM);
10300 info.flags = 0;
10301 info.low_limit = TASK_UNMAPPED_BASE;
10302 +
10303 +#ifdef CONFIG_PAX_RANDMMAP
10304 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10305 + info.low_limit += mm->delta_mmap;
10306 +#endif
10307 +
10308 info.high_limit = STACK_TOP32;
10309 addr = vm_unmapped_area(&info);
10310 }
10311 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10312 struct mm_struct *mm = current->mm;
10313 struct vm_area_struct *vma;
10314 unsigned long task_size = TASK_SIZE;
10315 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10316
10317 if (test_thread_flag(TIF_32BIT))
10318 task_size = STACK_TOP32;
10319 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10320 return addr;
10321 }
10322
10323 +#ifdef CONFIG_PAX_RANDMMAP
10324 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10325 +#endif
10326 +
10327 if (addr) {
10328 addr = ALIGN(addr, HPAGE_SIZE);
10329 vma = find_vma(mm, addr);
10330 - if (task_size - len >= addr &&
10331 - (!vma || addr + len <= vma->vm_start))
10332 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10333 return addr;
10334 }
10335 if (mm->get_unmapped_area == arch_get_unmapped_area)
10336 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10337 index f4500c6..889656c 100644
10338 --- a/arch/tile/include/asm/atomic_64.h
10339 +++ b/arch/tile/include/asm/atomic_64.h
10340 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10341
10342 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10343
10344 +#define atomic64_read_unchecked(v) atomic64_read(v)
10345 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10346 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10347 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10348 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10349 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10350 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10351 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10352 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10353 +
10354 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10355 #define smp_mb__before_atomic_dec() smp_mb()
10356 #define smp_mb__after_atomic_dec() smp_mb()
10357 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10358 index a9a5299..0fce79e 100644
10359 --- a/arch/tile/include/asm/cache.h
10360 +++ b/arch/tile/include/asm/cache.h
10361 @@ -15,11 +15,12 @@
10362 #ifndef _ASM_TILE_CACHE_H
10363 #define _ASM_TILE_CACHE_H
10364
10365 +#include <linux/const.h>
10366 #include <arch/chip.h>
10367
10368 /* bytes per L1 data cache line */
10369 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10370 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10371 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10372
10373 /* bytes per L2 cache line */
10374 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10375 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10376 index 9ab078a..d6635c2 100644
10377 --- a/arch/tile/include/asm/uaccess.h
10378 +++ b/arch/tile/include/asm/uaccess.h
10379 @@ -403,9 +403,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10380 const void __user *from,
10381 unsigned long n)
10382 {
10383 - int sz = __compiletime_object_size(to);
10384 + size_t sz = __compiletime_object_size(to);
10385
10386 - if (likely(sz == -1 || sz >= n))
10387 + if (likely(sz == (size_t)-1 || sz >= n))
10388 n = _copy_from_user(to, from, n);
10389 else
10390 copy_from_user_overflow();
10391 diff --git a/arch/um/Makefile b/arch/um/Makefile
10392 index 133f7de..1d6f2f1 100644
10393 --- a/arch/um/Makefile
10394 +++ b/arch/um/Makefile
10395 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10396 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10397 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10398
10399 +ifdef CONSTIFY_PLUGIN
10400 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10401 +endif
10402 +
10403 #This will adjust *FLAGS accordingly to the platform.
10404 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10405
10406 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10407 index 19e1bdd..3665b77 100644
10408 --- a/arch/um/include/asm/cache.h
10409 +++ b/arch/um/include/asm/cache.h
10410 @@ -1,6 +1,7 @@
10411 #ifndef __UM_CACHE_H
10412 #define __UM_CACHE_H
10413
10414 +#include <linux/const.h>
10415
10416 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10417 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10418 @@ -12,6 +13,6 @@
10419 # define L1_CACHE_SHIFT 5
10420 #endif
10421
10422 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10423 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10424
10425 #endif
10426 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10427 index 2e0a6b1..a64d0f5 100644
10428 --- a/arch/um/include/asm/kmap_types.h
10429 +++ b/arch/um/include/asm/kmap_types.h
10430 @@ -8,6 +8,6 @@
10431
10432 /* No more #include "asm/arch/kmap_types.h" ! */
10433
10434 -#define KM_TYPE_NR 14
10435 +#define KM_TYPE_NR 15
10436
10437 #endif
10438 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10439 index 5ff53d9..5850cdf 100644
10440 --- a/arch/um/include/asm/page.h
10441 +++ b/arch/um/include/asm/page.h
10442 @@ -14,6 +14,9 @@
10443 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10444 #define PAGE_MASK (~(PAGE_SIZE-1))
10445
10446 +#define ktla_ktva(addr) (addr)
10447 +#define ktva_ktla(addr) (addr)
10448 +
10449 #ifndef __ASSEMBLY__
10450
10451 struct page;
10452 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10453 index 0032f92..cd151e0 100644
10454 --- a/arch/um/include/asm/pgtable-3level.h
10455 +++ b/arch/um/include/asm/pgtable-3level.h
10456 @@ -58,6 +58,7 @@
10457 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10458 #define pud_populate(mm, pud, pmd) \
10459 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10460 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10461
10462 #ifdef CONFIG_64BIT
10463 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10464 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10465 index b462b13..e7a19aa 100644
10466 --- a/arch/um/kernel/process.c
10467 +++ b/arch/um/kernel/process.c
10468 @@ -386,22 +386,6 @@ int singlestepping(void * t)
10469 return 2;
10470 }
10471
10472 -/*
10473 - * Only x86 and x86_64 have an arch_align_stack().
10474 - * All other arches have "#define arch_align_stack(x) (x)"
10475 - * in their asm/system.h
10476 - * As this is included in UML from asm-um/system-generic.h,
10477 - * we can use it to behave as the subarch does.
10478 - */
10479 -#ifndef arch_align_stack
10480 -unsigned long arch_align_stack(unsigned long sp)
10481 -{
10482 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10483 - sp -= get_random_int() % 8192;
10484 - return sp & ~0xf;
10485 -}
10486 -#endif
10487 -
10488 unsigned long get_wchan(struct task_struct *p)
10489 {
10490 unsigned long stack_page, sp, ip;
10491 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10492 index ad8f795..2c7eec6 100644
10493 --- a/arch/unicore32/include/asm/cache.h
10494 +++ b/arch/unicore32/include/asm/cache.h
10495 @@ -12,8 +12,10 @@
10496 #ifndef __UNICORE_CACHE_H__
10497 #define __UNICORE_CACHE_H__
10498
10499 -#define L1_CACHE_SHIFT (5)
10500 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10501 +#include <linux/const.h>
10502 +
10503 +#define L1_CACHE_SHIFT 5
10504 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10505
10506 /*
10507 * Memory returned by kmalloc() may be used for DMA, so we must make
10508 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10509 index 0694d09..58ea1a1 100644
10510 --- a/arch/x86/Kconfig
10511 +++ b/arch/x86/Kconfig
10512 @@ -238,7 +238,7 @@ config X86_HT
10513
10514 config X86_32_LAZY_GS
10515 def_bool y
10516 - depends on X86_32 && !CC_STACKPROTECTOR
10517 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10518
10519 config ARCH_HWEIGHT_CFLAGS
10520 string
10521 @@ -1031,6 +1031,7 @@ config MICROCODE_OLD_INTERFACE
10522
10523 config X86_MSR
10524 tristate "/dev/cpu/*/msr - Model-specific register support"
10525 + depends on !GRKERNSEC_KMEM
10526 ---help---
10527 This device gives privileged processes access to the x86
10528 Model-Specific Registers (MSRs). It is a character device with
10529 @@ -1054,7 +1055,7 @@ choice
10530
10531 config NOHIGHMEM
10532 bool "off"
10533 - depends on !X86_NUMAQ
10534 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10535 ---help---
10536 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10537 However, the address space of 32-bit x86 processors is only 4
10538 @@ -1091,7 +1092,7 @@ config NOHIGHMEM
10539
10540 config HIGHMEM4G
10541 bool "4GB"
10542 - depends on !X86_NUMAQ
10543 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10544 ---help---
10545 Select this if you have a 32-bit processor and between 1 and 4
10546 gigabytes of physical RAM.
10547 @@ -1145,7 +1146,7 @@ config PAGE_OFFSET
10548 hex
10549 default 0xB0000000 if VMSPLIT_3G_OPT
10550 default 0x80000000 if VMSPLIT_2G
10551 - default 0x78000000 if VMSPLIT_2G_OPT
10552 + default 0x70000000 if VMSPLIT_2G_OPT
10553 default 0x40000000 if VMSPLIT_1G
10554 default 0xC0000000
10555 depends on X86_32
10556 @@ -1542,6 +1543,7 @@ config SECCOMP
10557
10558 config CC_STACKPROTECTOR
10559 bool "Enable -fstack-protector buffer overflow detection"
10560 + depends on X86_64 || !PAX_MEMORY_UDEREF
10561 ---help---
10562 This option turns on the -fstack-protector GCC feature. This
10563 feature puts, at the beginning of functions, a canary value on
10564 @@ -1662,6 +1664,8 @@ config X86_NEED_RELOCS
10565 config PHYSICAL_ALIGN
10566 hex "Alignment value to which kernel should be aligned" if X86_32
10567 default "0x1000000"
10568 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10569 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10570 range 0x2000 0x1000000
10571 ---help---
10572 This value puts the alignment restrictions on physical address
10573 @@ -1737,9 +1741,10 @@ config DEBUG_HOTPLUG_CPU0
10574 If unsure, say N.
10575
10576 config COMPAT_VDSO
10577 - def_bool y
10578 + def_bool n
10579 prompt "Compat VDSO support"
10580 depends on X86_32 || IA32_EMULATION
10581 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10582 ---help---
10583 Map the 32-bit VDSO to the predictable old-style address too.
10584
10585 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10586 index c026cca..14657ae 100644
10587 --- a/arch/x86/Kconfig.cpu
10588 +++ b/arch/x86/Kconfig.cpu
10589 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10590
10591 config X86_F00F_BUG
10592 def_bool y
10593 - depends on M586MMX || M586TSC || M586 || M486
10594 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10595
10596 config X86_INVD_BUG
10597 def_bool y
10598 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10599
10600 config X86_ALIGNMENT_16
10601 def_bool y
10602 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10603 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10604
10605 config X86_INTEL_USERCOPY
10606 def_bool y
10607 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10608 # generates cmov.
10609 config X86_CMOV
10610 def_bool y
10611 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10612 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10613
10614 config X86_MINIMUM_CPU_FAMILY
10615 int
10616 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10617 index b322f12..652d0d9 100644
10618 --- a/arch/x86/Kconfig.debug
10619 +++ b/arch/x86/Kconfig.debug
10620 @@ -84,7 +84,7 @@ config X86_PTDUMP
10621 config DEBUG_RODATA
10622 bool "Write protect kernel read-only data structures"
10623 default y
10624 - depends on DEBUG_KERNEL
10625 + depends on DEBUG_KERNEL && BROKEN
10626 ---help---
10627 Mark the kernel read-only data as write-protected in the pagetables,
10628 in order to catch accidental (and incorrect) writes to such const
10629 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10630
10631 config DEBUG_SET_MODULE_RONX
10632 bool "Set loadable kernel module data as NX and text as RO"
10633 - depends on MODULES
10634 + depends on MODULES && BROKEN
10635 ---help---
10636 This option helps catch unintended modifications to loadable
10637 kernel module's text and read-only data. It also prevents execution
10638 @@ -294,7 +294,7 @@ config OPTIMIZE_INLINING
10639
10640 config DEBUG_STRICT_USER_COPY_CHECKS
10641 bool "Strict copy size checks"
10642 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
10643 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
10644 ---help---
10645 Enabling this option turns a certain set of sanity checks for user
10646 copy operations into compile time failures.
10647 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10648 index e71fc42..7829607 100644
10649 --- a/arch/x86/Makefile
10650 +++ b/arch/x86/Makefile
10651 @@ -50,6 +50,7 @@ else
10652 UTS_MACHINE := x86_64
10653 CHECKFLAGS += -D__x86_64__ -m64
10654
10655 + biarch := $(call cc-option,-m64)
10656 KBUILD_AFLAGS += -m64
10657 KBUILD_CFLAGS += -m64
10658
10659 @@ -230,3 +231,12 @@ define archhelp
10660 echo ' FDARGS="..." arguments for the booted kernel'
10661 echo ' FDINITRD=file initrd for the booted kernel'
10662 endef
10663 +
10664 +define OLD_LD
10665 +
10666 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10667 +*** Please upgrade your binutils to 2.18 or newer
10668 +endef
10669 +
10670 +archprepare:
10671 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10672 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10673 index 379814b..add62ce 100644
10674 --- a/arch/x86/boot/Makefile
10675 +++ b/arch/x86/boot/Makefile
10676 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10677 $(call cc-option, -fno-stack-protector) \
10678 $(call cc-option, -mpreferred-stack-boundary=2)
10679 KBUILD_CFLAGS += $(call cc-option, -m32)
10680 +ifdef CONSTIFY_PLUGIN
10681 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10682 +endif
10683 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10684 GCOV_PROFILE := n
10685
10686 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10687 index 878e4b9..20537ab 100644
10688 --- a/arch/x86/boot/bitops.h
10689 +++ b/arch/x86/boot/bitops.h
10690 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10691 u8 v;
10692 const u32 *p = (const u32 *)addr;
10693
10694 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10695 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10696 return v;
10697 }
10698
10699 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10700
10701 static inline void set_bit(int nr, void *addr)
10702 {
10703 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10704 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10705 }
10706
10707 #endif /* BOOT_BITOPS_H */
10708 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10709 index 18997e5..83d9c67 100644
10710 --- a/arch/x86/boot/boot.h
10711 +++ b/arch/x86/boot/boot.h
10712 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10713 static inline u16 ds(void)
10714 {
10715 u16 seg;
10716 - asm("movw %%ds,%0" : "=rm" (seg));
10717 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10718 return seg;
10719 }
10720
10721 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10722 static inline int memcmp(const void *s1, const void *s2, size_t len)
10723 {
10724 u8 diff;
10725 - asm("repe; cmpsb; setnz %0"
10726 + asm volatile("repe; cmpsb; setnz %0"
10727 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10728 return diff;
10729 }
10730 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10731 index 5ef205c..342191d 100644
10732 --- a/arch/x86/boot/compressed/Makefile
10733 +++ b/arch/x86/boot/compressed/Makefile
10734 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10735 KBUILD_CFLAGS += $(cflags-y)
10736 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10737 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10738 +ifdef CONSTIFY_PLUGIN
10739 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10740 +endif
10741
10742 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10743 GCOV_PROFILE := n
10744 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10745 index c205035..5853587 100644
10746 --- a/arch/x86/boot/compressed/eboot.c
10747 +++ b/arch/x86/boot/compressed/eboot.c
10748 @@ -150,7 +150,6 @@ again:
10749 *addr = max_addr;
10750 }
10751
10752 -free_pool:
10753 efi_call_phys1(sys_table->boottime->free_pool, map);
10754
10755 fail:
10756 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10757 if (i == map_size / desc_size)
10758 status = EFI_NOT_FOUND;
10759
10760 -free_pool:
10761 efi_call_phys1(sys_table->boottime->free_pool, map);
10762 fail:
10763 return status;
10764 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10765 index 1e3184f..0d11e2e 100644
10766 --- a/arch/x86/boot/compressed/head_32.S
10767 +++ b/arch/x86/boot/compressed/head_32.S
10768 @@ -118,7 +118,7 @@ preferred_addr:
10769 notl %eax
10770 andl %eax, %ebx
10771 #else
10772 - movl $LOAD_PHYSICAL_ADDR, %ebx
10773 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10774 #endif
10775
10776 /* Target address to relocate to for decompression */
10777 @@ -204,7 +204,7 @@ relocated:
10778 * and where it was actually loaded.
10779 */
10780 movl %ebp, %ebx
10781 - subl $LOAD_PHYSICAL_ADDR, %ebx
10782 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10783 jz 2f /* Nothing to be done if loaded at compiled addr. */
10784 /*
10785 * Process relocations.
10786 @@ -212,8 +212,7 @@ relocated:
10787
10788 1: subl $4, %edi
10789 movl (%edi), %ecx
10790 - testl %ecx, %ecx
10791 - jz 2f
10792 + jecxz 2f
10793 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10794 jmp 1b
10795 2:
10796 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10797 index f5d1aaa..cce11dc 100644
10798 --- a/arch/x86/boot/compressed/head_64.S
10799 +++ b/arch/x86/boot/compressed/head_64.S
10800 @@ -91,7 +91,7 @@ ENTRY(startup_32)
10801 notl %eax
10802 andl %eax, %ebx
10803 #else
10804 - movl $LOAD_PHYSICAL_ADDR, %ebx
10805 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10806 #endif
10807
10808 /* Target address to relocate to for decompression */
10809 @@ -273,7 +273,7 @@ preferred_addr:
10810 notq %rax
10811 andq %rax, %rbp
10812 #else
10813 - movq $LOAD_PHYSICAL_ADDR, %rbp
10814 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10815 #endif
10816
10817 /* Target address to relocate to for decompression */
10818 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10819 index 88f7ff6..ed695dd 100644
10820 --- a/arch/x86/boot/compressed/misc.c
10821 +++ b/arch/x86/boot/compressed/misc.c
10822 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10823 case PT_LOAD:
10824 #ifdef CONFIG_RELOCATABLE
10825 dest = output;
10826 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10827 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10828 #else
10829 dest = (void *)(phdr->p_paddr);
10830 #endif
10831 @@ -352,7 +352,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10832 error("Destination address too large");
10833 #endif
10834 #ifndef CONFIG_RELOCATABLE
10835 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10836 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10837 error("Wrong destination address");
10838 #endif
10839
10840 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10841 index 4d3ff03..e4972ff 100644
10842 --- a/arch/x86/boot/cpucheck.c
10843 +++ b/arch/x86/boot/cpucheck.c
10844 @@ -74,7 +74,7 @@ static int has_fpu(void)
10845 u16 fcw = -1, fsw = -1;
10846 u32 cr0;
10847
10848 - asm("movl %%cr0,%0" : "=r" (cr0));
10849 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10850 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10851 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10852 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10853 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10854 {
10855 u32 f0, f1;
10856
10857 - asm("pushfl ; "
10858 + asm volatile("pushfl ; "
10859 "pushfl ; "
10860 "popl %0 ; "
10861 "movl %0,%1 ; "
10862 @@ -115,7 +115,7 @@ static void get_flags(void)
10863 set_bit(X86_FEATURE_FPU, cpu.flags);
10864
10865 if (has_eflag(X86_EFLAGS_ID)) {
10866 - asm("cpuid"
10867 + asm volatile("cpuid"
10868 : "=a" (max_intel_level),
10869 "=b" (cpu_vendor[0]),
10870 "=d" (cpu_vendor[1]),
10871 @@ -124,7 +124,7 @@ static void get_flags(void)
10872
10873 if (max_intel_level >= 0x00000001 &&
10874 max_intel_level <= 0x0000ffff) {
10875 - asm("cpuid"
10876 + asm volatile("cpuid"
10877 : "=a" (tfms),
10878 "=c" (cpu.flags[4]),
10879 "=d" (cpu.flags[0])
10880 @@ -136,7 +136,7 @@ static void get_flags(void)
10881 cpu.model += ((tfms >> 16) & 0xf) << 4;
10882 }
10883
10884 - asm("cpuid"
10885 + asm volatile("cpuid"
10886 : "=a" (max_amd_level)
10887 : "a" (0x80000000)
10888 : "ebx", "ecx", "edx");
10889 @@ -144,7 +144,7 @@ static void get_flags(void)
10890 if (max_amd_level >= 0x80000001 &&
10891 max_amd_level <= 0x8000ffff) {
10892 u32 eax = 0x80000001;
10893 - asm("cpuid"
10894 + asm volatile("cpuid"
10895 : "+a" (eax),
10896 "=c" (cpu.flags[6]),
10897 "=d" (cpu.flags[1])
10898 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10899 u32 ecx = MSR_K7_HWCR;
10900 u32 eax, edx;
10901
10902 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10903 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10904 eax &= ~(1 << 15);
10905 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10906 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10907
10908 get_flags(); /* Make sure it really did something */
10909 err = check_flags();
10910 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10911 u32 ecx = MSR_VIA_FCR;
10912 u32 eax, edx;
10913
10914 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10915 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10916 eax |= (1<<1)|(1<<7);
10917 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10918 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10919
10920 set_bit(X86_FEATURE_CX8, cpu.flags);
10921 err = check_flags();
10922 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10923 u32 eax, edx;
10924 u32 level = 1;
10925
10926 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10927 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10928 - asm("cpuid"
10929 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10930 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10931 + asm volatile("cpuid"
10932 : "+a" (level), "=d" (cpu.flags[0])
10933 : : "ecx", "ebx");
10934 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10935 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10936
10937 err = check_flags();
10938 }
10939 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10940 index 944ce59..87ee37a 100644
10941 --- a/arch/x86/boot/header.S
10942 +++ b/arch/x86/boot/header.S
10943 @@ -401,10 +401,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10944 # single linked list of
10945 # struct setup_data
10946
10947 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10948 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10949
10950 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10951 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10952 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10953 +#else
10954 #define VO_INIT_SIZE (VO__end - VO__text)
10955 +#endif
10956 #if ZO_INIT_SIZE > VO_INIT_SIZE
10957 #define INIT_SIZE ZO_INIT_SIZE
10958 #else
10959 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10960 index db75d07..8e6d0af 100644
10961 --- a/arch/x86/boot/memory.c
10962 +++ b/arch/x86/boot/memory.c
10963 @@ -19,7 +19,7 @@
10964
10965 static int detect_memory_e820(void)
10966 {
10967 - int count = 0;
10968 + unsigned int count = 0;
10969 struct biosregs ireg, oreg;
10970 struct e820entry *desc = boot_params.e820_map;
10971 static struct e820entry buf; /* static so it is zeroed */
10972 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10973 index 11e8c6e..fdbb1ed 100644
10974 --- a/arch/x86/boot/video-vesa.c
10975 +++ b/arch/x86/boot/video-vesa.c
10976 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10977
10978 boot_params.screen_info.vesapm_seg = oreg.es;
10979 boot_params.screen_info.vesapm_off = oreg.di;
10980 + boot_params.screen_info.vesapm_size = oreg.cx;
10981 }
10982
10983 /*
10984 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10985 index 43eda28..5ab5fdb 100644
10986 --- a/arch/x86/boot/video.c
10987 +++ b/arch/x86/boot/video.c
10988 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10989 static unsigned int get_entry(void)
10990 {
10991 char entry_buf[4];
10992 - int i, len = 0;
10993 + unsigned int i, len = 0;
10994 int key;
10995 unsigned int v;
10996
10997 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10998 index 5b577d5..3c1fed4 100644
10999 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11000 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11001 @@ -8,6 +8,8 @@
11002 * including this sentence is retained in full.
11003 */
11004
11005 +#include <asm/alternative-asm.h>
11006 +
11007 .extern crypto_ft_tab
11008 .extern crypto_it_tab
11009 .extern crypto_fl_tab
11010 @@ -71,6 +73,8 @@ FUNC: movq r1,r2; \
11011 je B192; \
11012 leaq 32(r9),r9;
11013
11014 +#define ret pax_force_retaddr 0, 1; ret
11015 +
11016 #define epilogue(r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11017 movq r1,r2; \
11018 movq r3,r4; \
11019 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11020 index 3470624..201259d 100644
11021 --- a/arch/x86/crypto/aesni-intel_asm.S
11022 +++ b/arch/x86/crypto/aesni-intel_asm.S
11023 @@ -31,6 +31,7 @@
11024
11025 #include <linux/linkage.h>
11026 #include <asm/inst.h>
11027 +#include <asm/alternative-asm.h>
11028
11029 #ifdef __x86_64__
11030 .data
11031 @@ -1436,7 +1437,9 @@ _return_T_done_decrypt:
11032 pop %r14
11033 pop %r13
11034 pop %r12
11035 + pax_force_retaddr 0, 1
11036 ret
11037 +ENDPROC(aesni_gcm_dec)
11038
11039
11040 /*****************************************************************************
11041 @@ -1699,7 +1702,9 @@ _return_T_done_encrypt:
11042 pop %r14
11043 pop %r13
11044 pop %r12
11045 + pax_force_retaddr 0, 1
11046 ret
11047 +ENDPROC(aesni_gcm_enc)
11048
11049 #endif
11050
11051 @@ -1714,6 +1719,7 @@ _key_expansion_256a:
11052 pxor %xmm1, %xmm0
11053 movaps %xmm0, (TKEYP)
11054 add $0x10, TKEYP
11055 + pax_force_retaddr_bts
11056 ret
11057
11058 .align 4
11059 @@ -1738,6 +1744,7 @@ _key_expansion_192a:
11060 shufps $0b01001110, %xmm2, %xmm1
11061 movaps %xmm1, 0x10(TKEYP)
11062 add $0x20, TKEYP
11063 + pax_force_retaddr_bts
11064 ret
11065
11066 .align 4
11067 @@ -1757,6 +1764,7 @@ _key_expansion_192b:
11068
11069 movaps %xmm0, (TKEYP)
11070 add $0x10, TKEYP
11071 + pax_force_retaddr_bts
11072 ret
11073
11074 .align 4
11075 @@ -1769,6 +1777,7 @@ _key_expansion_256b:
11076 pxor %xmm1, %xmm2
11077 movaps %xmm2, (TKEYP)
11078 add $0x10, TKEYP
11079 + pax_force_retaddr_bts
11080 ret
11081
11082 /*
11083 @@ -1881,7 +1890,9 @@ ENTRY(aesni_set_key)
11084 #ifndef __x86_64__
11085 popl KEYP
11086 #endif
11087 + pax_force_retaddr 0, 1
11088 ret
11089 +ENDPROC(aesni_set_key)
11090
11091 /*
11092 * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
11093 @@ -1902,7 +1913,9 @@ ENTRY(aesni_enc)
11094 popl KLEN
11095 popl KEYP
11096 #endif
11097 + pax_force_retaddr 0, 1
11098 ret
11099 +ENDPROC(aesni_enc)
11100
11101 /*
11102 * _aesni_enc1: internal ABI
11103 @@ -1959,6 +1972,7 @@ _aesni_enc1:
11104 AESENC KEY STATE
11105 movaps 0x70(TKEYP), KEY
11106 AESENCLAST KEY STATE
11107 + pax_force_retaddr_bts
11108 ret
11109
11110 /*
11111 @@ -2067,6 +2081,7 @@ _aesni_enc4:
11112 AESENCLAST KEY STATE2
11113 AESENCLAST KEY STATE3
11114 AESENCLAST KEY STATE4
11115 + pax_force_retaddr_bts
11116 ret
11117
11118 /*
11119 @@ -2089,7 +2104,9 @@ ENTRY(aesni_dec)
11120 popl KLEN
11121 popl KEYP
11122 #endif
11123 + pax_force_retaddr 0, 1
11124 ret
11125 +ENDPROC(aesni_dec)
11126
11127 /*
11128 * _aesni_dec1: internal ABI
11129 @@ -2146,6 +2163,7 @@ _aesni_dec1:
11130 AESDEC KEY STATE
11131 movaps 0x70(TKEYP), KEY
11132 AESDECLAST KEY STATE
11133 + pax_force_retaddr_bts
11134 ret
11135
11136 /*
11137 @@ -2254,6 +2272,7 @@ _aesni_dec4:
11138 AESDECLAST KEY STATE2
11139 AESDECLAST KEY STATE3
11140 AESDECLAST KEY STATE4
11141 + pax_force_retaddr_bts
11142 ret
11143
11144 /*
11145 @@ -2311,7 +2330,9 @@ ENTRY(aesni_ecb_enc)
11146 popl KEYP
11147 popl LEN
11148 #endif
11149 + pax_force_retaddr 0, 1
11150 ret
11151 +ENDPROC(aesni_ecb_enc)
11152
11153 /*
11154 * void aesni_ecb_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11155 @@ -2369,7 +2390,9 @@ ENTRY(aesni_ecb_dec)
11156 popl KEYP
11157 popl LEN
11158 #endif
11159 + pax_force_retaddr 0, 1
11160 ret
11161 +ENDPROC(aesni_ecb_dec)
11162
11163 /*
11164 * void aesni_cbc_enc(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11165 @@ -2410,7 +2433,9 @@ ENTRY(aesni_cbc_enc)
11166 popl LEN
11167 popl IVP
11168 #endif
11169 + pax_force_retaddr 0, 1
11170 ret
11171 +ENDPROC(aesni_cbc_enc)
11172
11173 /*
11174 * void aesni_cbc_dec(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src,
11175 @@ -2500,7 +2525,9 @@ ENTRY(aesni_cbc_dec)
11176 popl LEN
11177 popl IVP
11178 #endif
11179 + pax_force_retaddr 0, 1
11180 ret
11181 +ENDPROC(aesni_cbc_dec)
11182
11183 #ifdef __x86_64__
11184 .align 16
11185 @@ -2526,6 +2553,7 @@ _aesni_inc_init:
11186 mov $1, TCTR_LOW
11187 MOVQ_R64_XMM TCTR_LOW INC
11188 MOVQ_R64_XMM CTR TCTR_LOW
11189 + pax_force_retaddr_bts
11190 ret
11191
11192 /*
11193 @@ -2554,6 +2582,7 @@ _aesni_inc:
11194 .Linc_low:
11195 movaps CTR, IV
11196 PSHUFB_XMM BSWAP_MASK IV
11197 + pax_force_retaddr_bts
11198 ret
11199
11200 /*
11201 @@ -2614,5 +2643,7 @@ ENTRY(aesni_ctr_enc)
11202 .Lctr_enc_ret:
11203 movups IV, (IVP)
11204 .Lctr_enc_just_ret:
11205 + pax_force_retaddr 0, 1
11206 ret
11207 +ENDPROC(aesni_ctr_enc)
11208 #endif
11209 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11210 index 391d245..67f35c2 100644
11211 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11212 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11213 @@ -20,6 +20,8 @@
11214 *
11215 */
11216
11217 +#include <asm/alternative-asm.h>
11218 +
11219 .file "blowfish-x86_64-asm.S"
11220 .text
11221
11222 @@ -151,9 +153,11 @@ __blowfish_enc_blk:
11223 jnz __enc_xor;
11224
11225 write_block();
11226 + pax_force_retaddr 0, 1
11227 ret;
11228 __enc_xor:
11229 xor_block();
11230 + pax_force_retaddr 0, 1
11231 ret;
11232
11233 .align 8
11234 @@ -188,6 +192,7 @@ blowfish_dec_blk:
11235
11236 movq %r11, %rbp;
11237
11238 + pax_force_retaddr 0, 1
11239 ret;
11240
11241 /**********************************************************************
11242 @@ -342,6 +347,7 @@ __blowfish_enc_blk_4way:
11243
11244 popq %rbx;
11245 popq %rbp;
11246 + pax_force_retaddr 0, 1
11247 ret;
11248
11249 __enc_xor4:
11250 @@ -349,6 +355,7 @@ __enc_xor4:
11251
11252 popq %rbx;
11253 popq %rbp;
11254 + pax_force_retaddr 0, 1
11255 ret;
11256
11257 .align 8
11258 @@ -386,5 +393,6 @@ blowfish_dec_blk_4way:
11259 popq %rbx;
11260 popq %rbp;
11261
11262 + pax_force_retaddr 0, 1
11263 ret;
11264
11265 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11266 index 0b33743..7a56206 100644
11267 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11268 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11269 @@ -20,6 +20,8 @@
11270 *
11271 */
11272
11273 +#include <asm/alternative-asm.h>
11274 +
11275 .file "camellia-x86_64-asm_64.S"
11276 .text
11277
11278 @@ -229,12 +231,14 @@ __enc_done:
11279 enc_outunpack(mov, RT1);
11280
11281 movq RRBP, %rbp;
11282 + pax_force_retaddr 0, 1
11283 ret;
11284
11285 __enc_xor:
11286 enc_outunpack(xor, RT1);
11287
11288 movq RRBP, %rbp;
11289 + pax_force_retaddr 0, 1
11290 ret;
11291
11292 .global camellia_dec_blk;
11293 @@ -275,6 +279,7 @@ __dec_rounds16:
11294 dec_outunpack();
11295
11296 movq RRBP, %rbp;
11297 + pax_force_retaddr 0, 1
11298 ret;
11299
11300 /**********************************************************************
11301 @@ -468,6 +473,7 @@ __enc2_done:
11302
11303 movq RRBP, %rbp;
11304 popq %rbx;
11305 + pax_force_retaddr 0, 1
11306 ret;
11307
11308 __enc2_xor:
11309 @@ -475,6 +481,7 @@ __enc2_xor:
11310
11311 movq RRBP, %rbp;
11312 popq %rbx;
11313 + pax_force_retaddr 0, 1
11314 ret;
11315
11316 .global camellia_dec_blk_2way;
11317 @@ -517,4 +524,5 @@ __dec2_rounds16:
11318
11319 movq RRBP, %rbp;
11320 movq RXOR, %rbx;
11321 + pax_force_retaddr 0, 1
11322 ret;
11323 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11324 index 15b00ac..2071784 100644
11325 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11326 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11327 @@ -23,6 +23,8 @@
11328 *
11329 */
11330
11331 +#include <asm/alternative-asm.h>
11332 +
11333 .file "cast5-avx-x86_64-asm_64.S"
11334
11335 .extern cast_s1
11336 @@ -281,6 +283,7 @@ __skip_enc:
11337 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11338 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11339
11340 + pax_force_retaddr 0, 1
11341 ret;
11342
11343 .align 16
11344 @@ -353,6 +356,7 @@ __dec_tail:
11345 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11346 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11347
11348 + pax_force_retaddr 0, 1
11349 ret;
11350
11351 __skip_dec:
11352 @@ -392,6 +396,7 @@ cast5_ecb_enc_16way:
11353 vmovdqu RR4, (6*4*4)(%r11);
11354 vmovdqu RL4, (7*4*4)(%r11);
11355
11356 + pax_force_retaddr
11357 ret;
11358
11359 .align 16
11360 @@ -427,6 +432,7 @@ cast5_ecb_dec_16way:
11361 vmovdqu RR4, (6*4*4)(%r11);
11362 vmovdqu RL4, (7*4*4)(%r11);
11363
11364 + pax_force_retaddr
11365 ret;
11366
11367 .align 16
11368 @@ -479,6 +485,7 @@ cast5_cbc_dec_16way:
11369
11370 popq %r12;
11371
11372 + pax_force_retaddr
11373 ret;
11374
11375 .align 16
11376 @@ -555,4 +562,5 @@ cast5_ctr_16way:
11377
11378 popq %r12;
11379
11380 + pax_force_retaddr
11381 ret;
11382 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11383 index 2569d0d..637c289 100644
11384 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11385 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11386 @@ -23,6 +23,8 @@
11387 *
11388 */
11389
11390 +#include <asm/alternative-asm.h>
11391 +
11392 #include "glue_helper-asm-avx.S"
11393
11394 .file "cast6-avx-x86_64-asm_64.S"
11395 @@ -294,6 +296,7 @@ __cast6_enc_blk8:
11396 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11397 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11398
11399 + pax_force_retaddr 0, 1
11400 ret;
11401
11402 .align 8
11403 @@ -340,6 +343,7 @@ __cast6_dec_blk8:
11404 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11405 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11406
11407 + pax_force_retaddr 0, 1
11408 ret;
11409
11410 .align 8
11411 @@ -361,6 +365,7 @@ cast6_ecb_enc_8way:
11412
11413 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11414
11415 + pax_force_retaddr
11416 ret;
11417
11418 .align 8
11419 @@ -382,6 +387,7 @@ cast6_ecb_dec_8way:
11420
11421 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11422
11423 + pax_force_retaddr
11424 ret;
11425
11426 .align 8
11427 @@ -408,6 +414,7 @@ cast6_cbc_dec_8way:
11428
11429 popq %r12;
11430
11431 + pax_force_retaddr
11432 ret;
11433
11434 .align 8
11435 @@ -436,4 +443,5 @@ cast6_ctr_8way:
11436
11437 popq %r12;
11438
11439 + pax_force_retaddr
11440 ret;
11441 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11442 index 6214a9b..1f4fc9a 100644
11443 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11444 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11445 @@ -1,3 +1,5 @@
11446 +#include <asm/alternative-asm.h>
11447 +
11448 # enter ECRYPT_encrypt_bytes
11449 .text
11450 .p2align 5
11451 @@ -790,6 +792,7 @@ ECRYPT_encrypt_bytes:
11452 add %r11,%rsp
11453 mov %rdi,%rax
11454 mov %rsi,%rdx
11455 + pax_force_retaddr 0, 1
11456 ret
11457 # bytesatleast65:
11458 ._bytesatleast65:
11459 @@ -891,6 +894,7 @@ ECRYPT_keysetup:
11460 add %r11,%rsp
11461 mov %rdi,%rax
11462 mov %rsi,%rdx
11463 + pax_force_retaddr
11464 ret
11465 # enter ECRYPT_ivsetup
11466 .text
11467 @@ -917,4 +921,5 @@ ECRYPT_ivsetup:
11468 add %r11,%rsp
11469 mov %rdi,%rax
11470 mov %rsi,%rdx
11471 + pax_force_retaddr
11472 ret
11473 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11474 index 02b0e9f..cf4cf5c 100644
11475 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11476 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11477 @@ -24,6 +24,8 @@
11478 *
11479 */
11480
11481 +#include <asm/alternative-asm.h>
11482 +
11483 #include "glue_helper-asm-avx.S"
11484
11485 .file "serpent-avx-x86_64-asm_64.S"
11486 @@ -618,6 +620,7 @@ __serpent_enc_blk8_avx:
11487 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11488 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11489
11490 + pax_force_retaddr
11491 ret;
11492
11493 .align 8
11494 @@ -673,6 +676,7 @@ __serpent_dec_blk8_avx:
11495 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11496 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11497
11498 + pax_force_retaddr
11499 ret;
11500
11501 .align 8
11502 @@ -692,6 +696,7 @@ serpent_ecb_enc_8way_avx:
11503
11504 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11505
11506 + pax_force_retaddr
11507 ret;
11508
11509 .align 8
11510 @@ -711,6 +716,7 @@ serpent_ecb_dec_8way_avx:
11511
11512 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11513
11514 + pax_force_retaddr
11515 ret;
11516
11517 .align 8
11518 @@ -730,6 +736,7 @@ serpent_cbc_dec_8way_avx:
11519
11520 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11521
11522 + pax_force_retaddr
11523 ret;
11524
11525 .align 8
11526 @@ -751,4 +758,5 @@ serpent_ctr_8way_avx:
11527
11528 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11529
11530 + pax_force_retaddr
11531 ret;
11532 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11533 index 3ee1ff0..cbc568b 100644
11534 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11535 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11536 @@ -24,6 +24,8 @@
11537 *
11538 */
11539
11540 +#include <asm/alternative-asm.h>
11541 +
11542 .file "serpent-sse2-x86_64-asm_64.S"
11543 .text
11544
11545 @@ -692,12 +694,14 @@ __serpent_enc_blk_8way:
11546 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11547 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11548
11549 + pax_force_retaddr
11550 ret;
11551
11552 __enc_xor8:
11553 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11554 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11555
11556 + pax_force_retaddr
11557 ret;
11558
11559 .align 8
11560 @@ -755,4 +759,5 @@ serpent_dec_blk_8way:
11561 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11562 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11563
11564 + pax_force_retaddr
11565 ret;
11566 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11567 index 49d6987..df66bd4 100644
11568 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11569 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11570 @@ -28,6 +28,8 @@
11571 * (at your option) any later version.
11572 */
11573
11574 +#include <asm/alternative-asm.h>
11575 +
11576 #define CTX %rdi // arg1
11577 #define BUF %rsi // arg2
11578 #define CNT %rdx // arg3
11579 @@ -104,6 +106,7 @@
11580 pop %r12
11581 pop %rbp
11582 pop %rbx
11583 + pax_force_retaddr 0, 1
11584 ret
11585
11586 .size \name, .-\name
11587 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11588 index ebac16b..8092eb9 100644
11589 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11590 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11591 @@ -23,6 +23,8 @@
11592 *
11593 */
11594
11595 +#include <asm/alternative-asm.h>
11596 +
11597 #include "glue_helper-asm-avx.S"
11598
11599 .file "twofish-avx-x86_64-asm_64.S"
11600 @@ -283,6 +285,7 @@ __twofish_enc_blk8:
11601 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11602 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11603
11604 + pax_force_retaddr 0, 1
11605 ret;
11606
11607 .align 8
11608 @@ -324,6 +327,7 @@ __twofish_dec_blk8:
11609 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11610 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11611
11612 + pax_force_retaddr 0, 1
11613 ret;
11614
11615 .align 8
11616 @@ -345,6 +349,7 @@ twofish_ecb_enc_8way:
11617
11618 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11619
11620 + pax_force_retaddr 0, 1
11621 ret;
11622
11623 .align 8
11624 @@ -366,6 +371,7 @@ twofish_ecb_dec_8way:
11625
11626 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11627
11628 + pax_force_retaddr 0, 1
11629 ret;
11630
11631 .align 8
11632 @@ -392,6 +398,7 @@ twofish_cbc_dec_8way:
11633
11634 popq %r12;
11635
11636 + pax_force_retaddr 0, 1
11637 ret;
11638
11639 .align 8
11640 @@ -420,4 +427,5 @@ twofish_ctr_8way:
11641
11642 popq %r12;
11643
11644 + pax_force_retaddr 0, 1
11645 ret;
11646 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11647 index 5b012a2..36d5364 100644
11648 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11649 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11650 @@ -20,6 +20,8 @@
11651 *
11652 */
11653
11654 +#include <asm/alternative-asm.h>
11655 +
11656 .file "twofish-x86_64-asm-3way.S"
11657 .text
11658
11659 @@ -260,6 +262,7 @@ __twofish_enc_blk_3way:
11660 popq %r13;
11661 popq %r14;
11662 popq %r15;
11663 + pax_force_retaddr 0, 1
11664 ret;
11665
11666 __enc_xor3:
11667 @@ -271,6 +274,7 @@ __enc_xor3:
11668 popq %r13;
11669 popq %r14;
11670 popq %r15;
11671 + pax_force_retaddr 0, 1
11672 ret;
11673
11674 .global twofish_dec_blk_3way
11675 @@ -312,5 +316,6 @@ twofish_dec_blk_3way:
11676 popq %r13;
11677 popq %r14;
11678 popq %r15;
11679 + pax_force_retaddr 0, 1
11680 ret;
11681
11682 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11683 index 7bcf3fc..f53832f 100644
11684 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11685 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11686 @@ -21,6 +21,7 @@
11687 .text
11688
11689 #include <asm/asm-offsets.h>
11690 +#include <asm/alternative-asm.h>
11691
11692 #define a_offset 0
11693 #define b_offset 4
11694 @@ -268,6 +269,7 @@ twofish_enc_blk:
11695
11696 popq R1
11697 movq $1,%rax
11698 + pax_force_retaddr 0, 1
11699 ret
11700
11701 twofish_dec_blk:
11702 @@ -319,4 +321,5 @@ twofish_dec_blk:
11703
11704 popq R1
11705 movq $1,%rax
11706 + pax_force_retaddr 0, 1
11707 ret
11708 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11709 index a703af1..f5b9c36 100644
11710 --- a/arch/x86/ia32/ia32_aout.c
11711 +++ b/arch/x86/ia32/ia32_aout.c
11712 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11713 unsigned long dump_start, dump_size;
11714 struct user32 dump;
11715
11716 + memset(&dump, 0, sizeof(dump));
11717 +
11718 fs = get_fs();
11719 set_fs(KERNEL_DS);
11720 has_dumped = 1;
11721 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11722 index a1daf4a..f8c4537 100644
11723 --- a/arch/x86/ia32/ia32_signal.c
11724 +++ b/arch/x86/ia32/ia32_signal.c
11725 @@ -348,7 +348,7 @@ static void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
11726 sp -= frame_size;
11727 /* Align the stack pointer according to the i386 ABI,
11728 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11729 - sp = ((sp + 4) & -16ul) - 4;
11730 + sp = ((sp - 12) & -16ul) - 4;
11731 return (void __user *) sp;
11732 }
11733
11734 @@ -406,7 +406,7 @@ int ia32_setup_frame(int sig, struct k_sigaction *ka,
11735 * These are actually not used anymore, but left because some
11736 * gdb versions depend on them as a marker.
11737 */
11738 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11739 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11740 } put_user_catch(err);
11741
11742 if (err)
11743 @@ -448,7 +448,7 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11744 0xb8,
11745 __NR_ia32_rt_sigreturn,
11746 0x80cd,
11747 - 0,
11748 + 0
11749 };
11750
11751 frame = get_sigframe(ka, regs, sizeof(*frame), &fpstate);
11752 @@ -471,16 +471,18 @@ int ia32_setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
11753
11754 if (ka->sa.sa_flags & SA_RESTORER)
11755 restorer = ka->sa.sa_restorer;
11756 + else if (current->mm->context.vdso)
11757 + /* Return stub is in 32bit vsyscall page */
11758 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11759 else
11760 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11761 - rt_sigreturn);
11762 + restorer = &frame->retcode;
11763 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11764
11765 /*
11766 * Not actually used anymore, but left because some gdb
11767 * versions need it.
11768 */
11769 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11770 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11771 } put_user_catch(err);
11772
11773 err |= copy_siginfo_to_user32(&frame->info, info);
11774 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11775 index 142c4ce..19b683f 100644
11776 --- a/arch/x86/ia32/ia32entry.S
11777 +++ b/arch/x86/ia32/ia32entry.S
11778 @@ -15,8 +15,10 @@
11779 #include <asm/irqflags.h>
11780 #include <asm/asm.h>
11781 #include <asm/smap.h>
11782 +#include <asm/pgtable.h>
11783 #include <linux/linkage.h>
11784 #include <linux/err.h>
11785 +#include <asm/alternative-asm.h>
11786
11787 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11788 #include <linux/elf-em.h>
11789 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11790 ENDPROC(native_irq_enable_sysexit)
11791 #endif
11792
11793 + .macro pax_enter_kernel_user
11794 + pax_set_fptr_mask
11795 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11796 + call pax_enter_kernel_user
11797 +#endif
11798 + .endm
11799 +
11800 + .macro pax_exit_kernel_user
11801 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11802 + call pax_exit_kernel_user
11803 +#endif
11804 +#ifdef CONFIG_PAX_RANDKSTACK
11805 + pushq %rax
11806 + pushq %r11
11807 + call pax_randomize_kstack
11808 + popq %r11
11809 + popq %rax
11810 +#endif
11811 + .endm
11812 +
11813 +.macro pax_erase_kstack
11814 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11815 + call pax_erase_kstack
11816 +#endif
11817 +.endm
11818 +
11819 /*
11820 * 32bit SYSENTER instruction entry.
11821 *
11822 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11823 CFI_REGISTER rsp,rbp
11824 SWAPGS_UNSAFE_STACK
11825 movq PER_CPU_VAR(kernel_stack), %rsp
11826 - addq $(KERNEL_STACK_OFFSET),%rsp
11827 - /*
11828 - * No need to follow this irqs on/off section: the syscall
11829 - * disabled irqs, here we enable it straight after entry:
11830 - */
11831 - ENABLE_INTERRUPTS(CLBR_NONE)
11832 movl %ebp,%ebp /* zero extension */
11833 pushq_cfi $__USER32_DS
11834 /*CFI_REL_OFFSET ss,0*/
11835 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11836 CFI_REL_OFFSET rsp,0
11837 pushfq_cfi
11838 /*CFI_REL_OFFSET rflags,0*/
11839 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11840 - CFI_REGISTER rip,r10
11841 + orl $X86_EFLAGS_IF,(%rsp)
11842 + GET_THREAD_INFO(%r11)
11843 + movl TI_sysenter_return(%r11), %r11d
11844 + CFI_REGISTER rip,r11
11845 pushq_cfi $__USER32_CS
11846 /*CFI_REL_OFFSET cs,0*/
11847 movl %eax, %eax
11848 - pushq_cfi %r10
11849 + pushq_cfi %r11
11850 CFI_REL_OFFSET rip,0
11851 pushq_cfi %rax
11852 cld
11853 SAVE_ARGS 0,1,0
11854 + pax_enter_kernel_user
11855 +
11856 +#ifdef CONFIG_PAX_RANDKSTACK
11857 + pax_erase_kstack
11858 +#endif
11859 +
11860 + /*
11861 + * No need to follow this irqs on/off section: the syscall
11862 + * disabled irqs, here we enable it straight after entry:
11863 + */
11864 + ENABLE_INTERRUPTS(CLBR_NONE)
11865 /* no need to do an access_ok check here because rbp has been
11866 32bit zero extended */
11867 +
11868 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11869 + mov $PAX_USER_SHADOW_BASE,%r11
11870 + add %r11,%rbp
11871 +#endif
11872 +
11873 ASM_STAC
11874 1: movl (%rbp),%ebp
11875 _ASM_EXTABLE(1b,ia32_badarg)
11876 ASM_CLAC
11877 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11878 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11879 + GET_THREAD_INFO(%r11)
11880 + orl $TS_COMPAT,TI_status(%r11)
11881 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11882 CFI_REMEMBER_STATE
11883 jnz sysenter_tracesys
11884 cmpq $(IA32_NR_syscalls-1),%rax
11885 @@ -162,12 +204,15 @@ sysenter_do_call:
11886 sysenter_dispatch:
11887 call *ia32_sys_call_table(,%rax,8)
11888 movq %rax,RAX-ARGOFFSET(%rsp)
11889 + GET_THREAD_INFO(%r11)
11890 DISABLE_INTERRUPTS(CLBR_NONE)
11891 TRACE_IRQS_OFF
11892 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11893 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11894 jnz sysexit_audit
11895 sysexit_from_sys_call:
11896 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11897 + pax_exit_kernel_user
11898 + pax_erase_kstack
11899 + andl $~TS_COMPAT,TI_status(%r11)
11900 /* clear IF, that popfq doesn't enable interrupts early */
11901 andl $~0x200,EFLAGS-R11(%rsp)
11902 movl RIP-R11(%rsp),%edx /* User %eip */
11903 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11904 movl %eax,%esi /* 2nd arg: syscall number */
11905 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11906 call __audit_syscall_entry
11907 +
11908 + pax_erase_kstack
11909 +
11910 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11911 cmpq $(IA32_NR_syscalls-1),%rax
11912 ja ia32_badsys
11913 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11914 .endm
11915
11916 .macro auditsys_exit exit
11917 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11918 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11919 jnz ia32_ret_from_sys_call
11920 TRACE_IRQS_ON
11921 ENABLE_INTERRUPTS(CLBR_NONE)
11922 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11923 1: setbe %al /* 1 if error, 0 if not */
11924 movzbl %al,%edi /* zero-extend that into %edi */
11925 call __audit_syscall_exit
11926 + GET_THREAD_INFO(%r11)
11927 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11928 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11929 DISABLE_INTERRUPTS(CLBR_NONE)
11930 TRACE_IRQS_OFF
11931 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11932 + testl %edi,TI_flags(%r11)
11933 jz \exit
11934 CLEAR_RREGS -ARGOFFSET
11935 jmp int_with_check
11936 @@ -237,7 +286,7 @@ sysexit_audit:
11937
11938 sysenter_tracesys:
11939 #ifdef CONFIG_AUDITSYSCALL
11940 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11941 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11942 jz sysenter_auditsys
11943 #endif
11944 SAVE_REST
11945 @@ -249,6 +298,9 @@ sysenter_tracesys:
11946 RESTORE_REST
11947 cmpq $(IA32_NR_syscalls-1),%rax
11948 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11949 +
11950 + pax_erase_kstack
11951 +
11952 jmp sysenter_do_call
11953 CFI_ENDPROC
11954 ENDPROC(ia32_sysenter_target)
11955 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11956 ENTRY(ia32_cstar_target)
11957 CFI_STARTPROC32 simple
11958 CFI_SIGNAL_FRAME
11959 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11960 + CFI_DEF_CFA rsp,0
11961 CFI_REGISTER rip,rcx
11962 /*CFI_REGISTER rflags,r11*/
11963 SWAPGS_UNSAFE_STACK
11964 movl %esp,%r8d
11965 CFI_REGISTER rsp,r8
11966 movq PER_CPU_VAR(kernel_stack),%rsp
11967 + SAVE_ARGS 8*6,0,0
11968 + pax_enter_kernel_user
11969 +
11970 +#ifdef CONFIG_PAX_RANDKSTACK
11971 + pax_erase_kstack
11972 +#endif
11973 +
11974 /*
11975 * No need to follow this irqs on/off section: the syscall
11976 * disabled irqs and here we enable it straight after entry:
11977 */
11978 ENABLE_INTERRUPTS(CLBR_NONE)
11979 - SAVE_ARGS 8,0,0
11980 movl %eax,%eax /* zero extension */
11981 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11982 movq %rcx,RIP-ARGOFFSET(%rsp)
11983 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11984 /* no need to do an access_ok check here because r8 has been
11985 32bit zero extended */
11986 /* hardware stack frame is complete now */
11987 +
11988 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11989 + mov $PAX_USER_SHADOW_BASE,%r11
11990 + add %r11,%r8
11991 +#endif
11992 +
11993 ASM_STAC
11994 1: movl (%r8),%r9d
11995 _ASM_EXTABLE(1b,ia32_badarg)
11996 ASM_CLAC
11997 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11998 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11999 + GET_THREAD_INFO(%r11)
12000 + orl $TS_COMPAT,TI_status(%r11)
12001 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12002 CFI_REMEMBER_STATE
12003 jnz cstar_tracesys
12004 cmpq $IA32_NR_syscalls-1,%rax
12005 @@ -319,12 +384,15 @@ cstar_do_call:
12006 cstar_dispatch:
12007 call *ia32_sys_call_table(,%rax,8)
12008 movq %rax,RAX-ARGOFFSET(%rsp)
12009 + GET_THREAD_INFO(%r11)
12010 DISABLE_INTERRUPTS(CLBR_NONE)
12011 TRACE_IRQS_OFF
12012 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12013 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12014 jnz sysretl_audit
12015 sysretl_from_sys_call:
12016 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12017 + pax_exit_kernel_user
12018 + pax_erase_kstack
12019 + andl $~TS_COMPAT,TI_status(%r11)
12020 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12021 movl RIP-ARGOFFSET(%rsp),%ecx
12022 CFI_REGISTER rip,rcx
12023 @@ -352,7 +420,7 @@ sysretl_audit:
12024
12025 cstar_tracesys:
12026 #ifdef CONFIG_AUDITSYSCALL
12027 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12028 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12029 jz cstar_auditsys
12030 #endif
12031 xchgl %r9d,%ebp
12032 @@ -366,6 +434,9 @@ cstar_tracesys:
12033 xchgl %ebp,%r9d
12034 cmpq $(IA32_NR_syscalls-1),%rax
12035 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12036 +
12037 + pax_erase_kstack
12038 +
12039 jmp cstar_do_call
12040 END(ia32_cstar_target)
12041
12042 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
12043 CFI_REL_OFFSET rip,RIP-RIP
12044 PARAVIRT_ADJUST_EXCEPTION_FRAME
12045 SWAPGS
12046 - /*
12047 - * No need to follow this irqs on/off section: the syscall
12048 - * disabled irqs and here we enable it straight after entry:
12049 - */
12050 - ENABLE_INTERRUPTS(CLBR_NONE)
12051 movl %eax,%eax
12052 pushq_cfi %rax
12053 cld
12054 /* note the registers are not zero extended to the sf.
12055 this could be a problem. */
12056 SAVE_ARGS 0,1,0
12057 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12058 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12059 + pax_enter_kernel_user
12060 +
12061 +#ifdef CONFIG_PAX_RANDKSTACK
12062 + pax_erase_kstack
12063 +#endif
12064 +
12065 + /*
12066 + * No need to follow this irqs on/off section: the syscall
12067 + * disabled irqs and here we enable it straight after entry:
12068 + */
12069 + ENABLE_INTERRUPTS(CLBR_NONE)
12070 + GET_THREAD_INFO(%r11)
12071 + orl $TS_COMPAT,TI_status(%r11)
12072 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12073 jnz ia32_tracesys
12074 cmpq $(IA32_NR_syscalls-1),%rax
12075 ja ia32_badsys
12076 @@ -442,6 +520,9 @@ ia32_tracesys:
12077 RESTORE_REST
12078 cmpq $(IA32_NR_syscalls-1),%rax
12079 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12080 +
12081 + pax_erase_kstack
12082 +
12083 jmp ia32_do_call
12084 END(ia32_syscall)
12085
12086 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12087 index d0b689b..6811ddc 100644
12088 --- a/arch/x86/ia32/sys_ia32.c
12089 +++ b/arch/x86/ia32/sys_ia32.c
12090 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12091 */
12092 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12093 {
12094 - typeof(ubuf->st_uid) uid = 0;
12095 - typeof(ubuf->st_gid) gid = 0;
12096 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12097 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12098 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12099 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12100 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12101 @@ -303,7 +303,7 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12102 mm_segment_t old_fs = get_fs();
12103
12104 set_fs(KERNEL_DS);
12105 - ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
12106 + ret = sys_sched_rr_get_interval(pid, (struct timespec __force_user *)&t);
12107 set_fs(old_fs);
12108 if (put_compat_timespec(&t, interval))
12109 return -EFAULT;
12110 @@ -313,13 +313,13 @@ asmlinkage long sys32_sched_rr_get_interval(compat_pid_t pid,
12111 asmlinkage long sys32_rt_sigpending(compat_sigset_t __user *set,
12112 compat_size_t sigsetsize)
12113 {
12114 - sigset_t s;
12115 + sigset_t s = { };
12116 compat_sigset_t s32;
12117 int ret;
12118 mm_segment_t old_fs = get_fs();
12119
12120 set_fs(KERNEL_DS);
12121 - ret = sys_rt_sigpending((sigset_t __user *)&s, sigsetsize);
12122 + ret = sys_rt_sigpending((sigset_t __force_user *)&s, sigsetsize);
12123 set_fs(old_fs);
12124 if (!ret) {
12125 switch (_NSIG_WORDS) {
12126 @@ -344,7 +344,7 @@ asmlinkage long sys32_rt_sigqueueinfo(int pid, int sig,
12127 if (copy_siginfo_from_user32(&info, uinfo))
12128 return -EFAULT;
12129 set_fs(KERNEL_DS);
12130 - ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __user *)&info);
12131 + ret = sys_rt_sigqueueinfo(pid, sig, (siginfo_t __force_user *)&info);
12132 set_fs(old_fs);
12133 return ret;
12134 }
12135 @@ -376,7 +376,7 @@ asmlinkage long sys32_sendfile(int out_fd, int in_fd,
12136 return -EFAULT;
12137
12138 set_fs(KERNEL_DS);
12139 - ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __user *)&of : NULL,
12140 + ret = sys_sendfile(out_fd, in_fd, offset ? (off_t __force_user *)&of : NULL,
12141 count);
12142 set_fs(old_fs);
12143
12144 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12145 index 372231c..a5aa1a1 100644
12146 --- a/arch/x86/include/asm/alternative-asm.h
12147 +++ b/arch/x86/include/asm/alternative-asm.h
12148 @@ -18,6 +18,45 @@
12149 .endm
12150 #endif
12151
12152 +#ifdef KERNEXEC_PLUGIN
12153 + .macro pax_force_retaddr_bts rip=0
12154 + btsq $63,\rip(%rsp)
12155 + .endm
12156 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12157 + .macro pax_force_retaddr rip=0, reload=0
12158 + btsq $63,\rip(%rsp)
12159 + .endm
12160 + .macro pax_force_fptr ptr
12161 + btsq $63,\ptr
12162 + .endm
12163 + .macro pax_set_fptr_mask
12164 + .endm
12165 +#endif
12166 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12167 + .macro pax_force_retaddr rip=0, reload=0
12168 + .if \reload
12169 + pax_set_fptr_mask
12170 + .endif
12171 + orq %r10,\rip(%rsp)
12172 + .endm
12173 + .macro pax_force_fptr ptr
12174 + orq %r10,\ptr
12175 + .endm
12176 + .macro pax_set_fptr_mask
12177 + movabs $0x8000000000000000,%r10
12178 + .endm
12179 +#endif
12180 +#else
12181 + .macro pax_force_retaddr rip=0, reload=0
12182 + .endm
12183 + .macro pax_force_fptr ptr
12184 + .endm
12185 + .macro pax_force_retaddr_bts rip=0
12186 + .endm
12187 + .macro pax_set_fptr_mask
12188 + .endm
12189 +#endif
12190 +
12191 .macro altinstruction_entry orig alt feature orig_len alt_len
12192 .long \orig - .
12193 .long \alt - .
12194 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12195 index 58ed6d9..f1cbe58 100644
12196 --- a/arch/x86/include/asm/alternative.h
12197 +++ b/arch/x86/include/asm/alternative.h
12198 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12199 ".pushsection .discard,\"aw\",@progbits\n" \
12200 DISCARD_ENTRY(1) \
12201 ".popsection\n" \
12202 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12203 + ".pushsection .altinstr_replacement, \"a\"\n" \
12204 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12205 ".popsection"
12206
12207 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12208 DISCARD_ENTRY(1) \
12209 DISCARD_ENTRY(2) \
12210 ".popsection\n" \
12211 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12212 + ".pushsection .altinstr_replacement, \"a\"\n" \
12213 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12214 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12215 ".popsection"
12216 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12217 index 3388034..050f0b9 100644
12218 --- a/arch/x86/include/asm/apic.h
12219 +++ b/arch/x86/include/asm/apic.h
12220 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12221
12222 #ifdef CONFIG_X86_LOCAL_APIC
12223
12224 -extern unsigned int apic_verbosity;
12225 +extern int apic_verbosity;
12226 extern int local_apic_timer_c2_ok;
12227
12228 extern int disable_apic;
12229 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12230 index 20370c6..a2eb9b0 100644
12231 --- a/arch/x86/include/asm/apm.h
12232 +++ b/arch/x86/include/asm/apm.h
12233 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12234 __asm__ __volatile__(APM_DO_ZERO_SEGS
12235 "pushl %%edi\n\t"
12236 "pushl %%ebp\n\t"
12237 - "lcall *%%cs:apm_bios_entry\n\t"
12238 + "lcall *%%ss:apm_bios_entry\n\t"
12239 "setc %%al\n\t"
12240 "popl %%ebp\n\t"
12241 "popl %%edi\n\t"
12242 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12243 __asm__ __volatile__(APM_DO_ZERO_SEGS
12244 "pushl %%edi\n\t"
12245 "pushl %%ebp\n\t"
12246 - "lcall *%%cs:apm_bios_entry\n\t"
12247 + "lcall *%%ss:apm_bios_entry\n\t"
12248 "setc %%bl\n\t"
12249 "popl %%ebp\n\t"
12250 "popl %%edi\n\t"
12251 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12252 index 722aa3b..3a0bb27 100644
12253 --- a/arch/x86/include/asm/atomic.h
12254 +++ b/arch/x86/include/asm/atomic.h
12255 @@ -22,7 +22,18 @@
12256 */
12257 static inline int atomic_read(const atomic_t *v)
12258 {
12259 - return (*(volatile int *)&(v)->counter);
12260 + return (*(volatile const int *)&(v)->counter);
12261 +}
12262 +
12263 +/**
12264 + * atomic_read_unchecked - read atomic variable
12265 + * @v: pointer of type atomic_unchecked_t
12266 + *
12267 + * Atomically reads the value of @v.
12268 + */
12269 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12270 +{
12271 + return (*(volatile const int *)&(v)->counter);
12272 }
12273
12274 /**
12275 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12276 }
12277
12278 /**
12279 + * atomic_set_unchecked - set atomic variable
12280 + * @v: pointer of type atomic_unchecked_t
12281 + * @i: required value
12282 + *
12283 + * Atomically sets the value of @v to @i.
12284 + */
12285 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12286 +{
12287 + v->counter = i;
12288 +}
12289 +
12290 +/**
12291 * atomic_add - add integer to atomic variable
12292 * @i: integer value to add
12293 * @v: pointer of type atomic_t
12294 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12295 */
12296 static inline void atomic_add(int i, atomic_t *v)
12297 {
12298 - asm volatile(LOCK_PREFIX "addl %1,%0"
12299 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12300 +
12301 +#ifdef CONFIG_PAX_REFCOUNT
12302 + "jno 0f\n"
12303 + LOCK_PREFIX "subl %1,%0\n"
12304 + "int $4\n0:\n"
12305 + _ASM_EXTABLE(0b, 0b)
12306 +#endif
12307 +
12308 + : "+m" (v->counter)
12309 + : "ir" (i));
12310 +}
12311 +
12312 +/**
12313 + * atomic_add_unchecked - add integer to atomic variable
12314 + * @i: integer value to add
12315 + * @v: pointer of type atomic_unchecked_t
12316 + *
12317 + * Atomically adds @i to @v.
12318 + */
12319 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12320 +{
12321 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12322 : "+m" (v->counter)
12323 : "ir" (i));
12324 }
12325 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12326 */
12327 static inline void atomic_sub(int i, atomic_t *v)
12328 {
12329 - asm volatile(LOCK_PREFIX "subl %1,%0"
12330 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12331 +
12332 +#ifdef CONFIG_PAX_REFCOUNT
12333 + "jno 0f\n"
12334 + LOCK_PREFIX "addl %1,%0\n"
12335 + "int $4\n0:\n"
12336 + _ASM_EXTABLE(0b, 0b)
12337 +#endif
12338 +
12339 + : "+m" (v->counter)
12340 + : "ir" (i));
12341 +}
12342 +
12343 +/**
12344 + * atomic_sub_unchecked - subtract integer from atomic variable
12345 + * @i: integer value to subtract
12346 + * @v: pointer of type atomic_unchecked_t
12347 + *
12348 + * Atomically subtracts @i from @v.
12349 + */
12350 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12351 +{
12352 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12353 : "+m" (v->counter)
12354 : "ir" (i));
12355 }
12356 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12357 {
12358 unsigned char c;
12359
12360 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12361 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12362 +
12363 +#ifdef CONFIG_PAX_REFCOUNT
12364 + "jno 0f\n"
12365 + LOCK_PREFIX "addl %2,%0\n"
12366 + "int $4\n0:\n"
12367 + _ASM_EXTABLE(0b, 0b)
12368 +#endif
12369 +
12370 + "sete %1\n"
12371 : "+m" (v->counter), "=qm" (c)
12372 : "ir" (i) : "memory");
12373 return c;
12374 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12375 */
12376 static inline void atomic_inc(atomic_t *v)
12377 {
12378 - asm volatile(LOCK_PREFIX "incl %0"
12379 + asm volatile(LOCK_PREFIX "incl %0\n"
12380 +
12381 +#ifdef CONFIG_PAX_REFCOUNT
12382 + "jno 0f\n"
12383 + LOCK_PREFIX "decl %0\n"
12384 + "int $4\n0:\n"
12385 + _ASM_EXTABLE(0b, 0b)
12386 +#endif
12387 +
12388 + : "+m" (v->counter));
12389 +}
12390 +
12391 +/**
12392 + * atomic_inc_unchecked - increment atomic variable
12393 + * @v: pointer of type atomic_unchecked_t
12394 + *
12395 + * Atomically increments @v by 1.
12396 + */
12397 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12398 +{
12399 + asm volatile(LOCK_PREFIX "incl %0\n"
12400 : "+m" (v->counter));
12401 }
12402
12403 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12404 */
12405 static inline void atomic_dec(atomic_t *v)
12406 {
12407 - asm volatile(LOCK_PREFIX "decl %0"
12408 + asm volatile(LOCK_PREFIX "decl %0\n"
12409 +
12410 +#ifdef CONFIG_PAX_REFCOUNT
12411 + "jno 0f\n"
12412 + LOCK_PREFIX "incl %0\n"
12413 + "int $4\n0:\n"
12414 + _ASM_EXTABLE(0b, 0b)
12415 +#endif
12416 +
12417 + : "+m" (v->counter));
12418 +}
12419 +
12420 +/**
12421 + * atomic_dec_unchecked - decrement atomic variable
12422 + * @v: pointer of type atomic_unchecked_t
12423 + *
12424 + * Atomically decrements @v by 1.
12425 + */
12426 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12427 +{
12428 + asm volatile(LOCK_PREFIX "decl %0\n"
12429 : "+m" (v->counter));
12430 }
12431
12432 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12433 {
12434 unsigned char c;
12435
12436 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12437 + asm volatile(LOCK_PREFIX "decl %0\n"
12438 +
12439 +#ifdef CONFIG_PAX_REFCOUNT
12440 + "jno 0f\n"
12441 + LOCK_PREFIX "incl %0\n"
12442 + "int $4\n0:\n"
12443 + _ASM_EXTABLE(0b, 0b)
12444 +#endif
12445 +
12446 + "sete %1\n"
12447 : "+m" (v->counter), "=qm" (c)
12448 : : "memory");
12449 return c != 0;
12450 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12451 {
12452 unsigned char c;
12453
12454 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12455 + asm volatile(LOCK_PREFIX "incl %0\n"
12456 +
12457 +#ifdef CONFIG_PAX_REFCOUNT
12458 + "jno 0f\n"
12459 + LOCK_PREFIX "decl %0\n"
12460 + "int $4\n0:\n"
12461 + _ASM_EXTABLE(0b, 0b)
12462 +#endif
12463 +
12464 + "sete %1\n"
12465 + : "+m" (v->counter), "=qm" (c)
12466 + : : "memory");
12467 + return c != 0;
12468 +}
12469 +
12470 +/**
12471 + * atomic_inc_and_test_unchecked - increment and test
12472 + * @v: pointer of type atomic_unchecked_t
12473 + *
12474 + * Atomically increments @v by 1
12475 + * and returns true if the result is zero, or false for all
12476 + * other cases.
12477 + */
12478 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12479 +{
12480 + unsigned char c;
12481 +
12482 + asm volatile(LOCK_PREFIX "incl %0\n"
12483 + "sete %1\n"
12484 : "+m" (v->counter), "=qm" (c)
12485 : : "memory");
12486 return c != 0;
12487 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12488 {
12489 unsigned char c;
12490
12491 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12492 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12493 +
12494 +#ifdef CONFIG_PAX_REFCOUNT
12495 + "jno 0f\n"
12496 + LOCK_PREFIX "subl %2,%0\n"
12497 + "int $4\n0:\n"
12498 + _ASM_EXTABLE(0b, 0b)
12499 +#endif
12500 +
12501 + "sets %1\n"
12502 : "+m" (v->counter), "=qm" (c)
12503 : "ir" (i) : "memory");
12504 return c;
12505 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12506 */
12507 static inline int atomic_add_return(int i, atomic_t *v)
12508 {
12509 + return i + xadd_check_overflow(&v->counter, i);
12510 +}
12511 +
12512 +/**
12513 + * atomic_add_return_unchecked - add integer and return
12514 + * @i: integer value to add
12515 + * @v: pointer of type atomic_unchecked_t
12516 + *
12517 + * Atomically adds @i to @v and returns @i + @v
12518 + */
12519 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12520 +{
12521 return i + xadd(&v->counter, i);
12522 }
12523
12524 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12525 }
12526
12527 #define atomic_inc_return(v) (atomic_add_return(1, v))
12528 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12529 +{
12530 + return atomic_add_return_unchecked(1, v);
12531 +}
12532 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12533
12534 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12535 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12536 return cmpxchg(&v->counter, old, new);
12537 }
12538
12539 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12540 +{
12541 + return cmpxchg(&v->counter, old, new);
12542 +}
12543 +
12544 static inline int atomic_xchg(atomic_t *v, int new)
12545 {
12546 return xchg(&v->counter, new);
12547 }
12548
12549 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12550 +{
12551 + return xchg(&v->counter, new);
12552 +}
12553 +
12554 /**
12555 * __atomic_add_unless - add unless the number is already a given value
12556 * @v: pointer of type atomic_t
12557 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12558 */
12559 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12560 {
12561 - int c, old;
12562 + int c, old, new;
12563 c = atomic_read(v);
12564 for (;;) {
12565 - if (unlikely(c == (u)))
12566 + if (unlikely(c == u))
12567 break;
12568 - old = atomic_cmpxchg((v), c, c + (a));
12569 +
12570 + asm volatile("addl %2,%0\n"
12571 +
12572 +#ifdef CONFIG_PAX_REFCOUNT
12573 + "jno 0f\n"
12574 + "subl %2,%0\n"
12575 + "int $4\n0:\n"
12576 + _ASM_EXTABLE(0b, 0b)
12577 +#endif
12578 +
12579 + : "=r" (new)
12580 + : "0" (c), "ir" (a));
12581 +
12582 + old = atomic_cmpxchg(v, c, new);
12583 if (likely(old == c))
12584 break;
12585 c = old;
12586 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12587 }
12588
12589 /**
12590 + * atomic_inc_not_zero_hint - increment if not null
12591 + * @v: pointer of type atomic_t
12592 + * @hint: probable value of the atomic before the increment
12593 + *
12594 + * This version of atomic_inc_not_zero() gives a hint of probable
12595 + * value of the atomic. This helps processor to not read the memory
12596 + * before doing the atomic read/modify/write cycle, lowering
12597 + * number of bus transactions on some arches.
12598 + *
12599 + * Returns: 0 if increment was not done, 1 otherwise.
12600 + */
12601 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12602 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12603 +{
12604 + int val, c = hint, new;
12605 +
12606 + /* sanity test, should be removed by compiler if hint is a constant */
12607 + if (!hint)
12608 + return __atomic_add_unless(v, 1, 0);
12609 +
12610 + do {
12611 + asm volatile("incl %0\n"
12612 +
12613 +#ifdef CONFIG_PAX_REFCOUNT
12614 + "jno 0f\n"
12615 + "decl %0\n"
12616 + "int $4\n0:\n"
12617 + _ASM_EXTABLE(0b, 0b)
12618 +#endif
12619 +
12620 + : "=r" (new)
12621 + : "0" (c));
12622 +
12623 + val = atomic_cmpxchg(v, c, new);
12624 + if (val == c)
12625 + return 1;
12626 + c = val;
12627 + } while (c);
12628 +
12629 + return 0;
12630 +}
12631 +
12632 +/**
12633 * atomic_inc_short - increment of a short integer
12634 * @v: pointer to type int
12635 *
12636 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12637 #endif
12638
12639 /* These are x86-specific, used by some header files */
12640 -#define atomic_clear_mask(mask, addr) \
12641 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12642 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12643 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12644 +{
12645 + asm volatile(LOCK_PREFIX "andl %1,%0"
12646 + : "+m" (v->counter)
12647 + : "r" (~(mask))
12648 + : "memory");
12649 +}
12650
12651 -#define atomic_set_mask(mask, addr) \
12652 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12653 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12654 - : "memory")
12655 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12656 +{
12657 + asm volatile(LOCK_PREFIX "andl %1,%0"
12658 + : "+m" (v->counter)
12659 + : "r" (~(mask))
12660 + : "memory");
12661 +}
12662 +
12663 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12664 +{
12665 + asm volatile(LOCK_PREFIX "orl %1,%0"
12666 + : "+m" (v->counter)
12667 + : "r" (mask)
12668 + : "memory");
12669 +}
12670 +
12671 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12672 +{
12673 + asm volatile(LOCK_PREFIX "orl %1,%0"
12674 + : "+m" (v->counter)
12675 + : "r" (mask)
12676 + : "memory");
12677 +}
12678
12679 /* Atomic operations are already serializing on x86 */
12680 #define smp_mb__before_atomic_dec() barrier()
12681 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12682 index b154de7..aadebd8 100644
12683 --- a/arch/x86/include/asm/atomic64_32.h
12684 +++ b/arch/x86/include/asm/atomic64_32.h
12685 @@ -12,6 +12,14 @@ typedef struct {
12686 u64 __aligned(8) counter;
12687 } atomic64_t;
12688
12689 +#ifdef CONFIG_PAX_REFCOUNT
12690 +typedef struct {
12691 + u64 __aligned(8) counter;
12692 +} atomic64_unchecked_t;
12693 +#else
12694 +typedef atomic64_t atomic64_unchecked_t;
12695 +#endif
12696 +
12697 #define ATOMIC64_INIT(val) { (val) }
12698
12699 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12700 @@ -37,21 +45,31 @@ typedef struct {
12701 ATOMIC64_DECL_ONE(sym##_386)
12702
12703 ATOMIC64_DECL_ONE(add_386);
12704 +ATOMIC64_DECL_ONE(add_unchecked_386);
12705 ATOMIC64_DECL_ONE(sub_386);
12706 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12707 ATOMIC64_DECL_ONE(inc_386);
12708 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12709 ATOMIC64_DECL_ONE(dec_386);
12710 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12711 #endif
12712
12713 #define alternative_atomic64(f, out, in...) \
12714 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12715
12716 ATOMIC64_DECL(read);
12717 +ATOMIC64_DECL(read_unchecked);
12718 ATOMIC64_DECL(set);
12719 +ATOMIC64_DECL(set_unchecked);
12720 ATOMIC64_DECL(xchg);
12721 ATOMIC64_DECL(add_return);
12722 +ATOMIC64_DECL(add_return_unchecked);
12723 ATOMIC64_DECL(sub_return);
12724 +ATOMIC64_DECL(sub_return_unchecked);
12725 ATOMIC64_DECL(inc_return);
12726 +ATOMIC64_DECL(inc_return_unchecked);
12727 ATOMIC64_DECL(dec_return);
12728 +ATOMIC64_DECL(dec_return_unchecked);
12729 ATOMIC64_DECL(dec_if_positive);
12730 ATOMIC64_DECL(inc_not_zero);
12731 ATOMIC64_DECL(add_unless);
12732 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12733 }
12734
12735 /**
12736 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12737 + * @p: pointer to type atomic64_unchecked_t
12738 + * @o: expected value
12739 + * @n: new value
12740 + *
12741 + * Atomically sets @v to @n if it was equal to @o and returns
12742 + * the old value.
12743 + */
12744 +
12745 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12746 +{
12747 + return cmpxchg64(&v->counter, o, n);
12748 +}
12749 +
12750 +/**
12751 * atomic64_xchg - xchg atomic64 variable
12752 * @v: pointer to type atomic64_t
12753 * @n: value to assign
12754 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12755 }
12756
12757 /**
12758 + * atomic64_set_unchecked - set atomic64 variable
12759 + * @v: pointer to type atomic64_unchecked_t
12760 + * @n: value to assign
12761 + *
12762 + * Atomically sets the value of @v to @n.
12763 + */
12764 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12765 +{
12766 + unsigned high = (unsigned)(i >> 32);
12767 + unsigned low = (unsigned)i;
12768 + alternative_atomic64(set, /* no output */,
12769 + "S" (v), "b" (low), "c" (high)
12770 + : "eax", "edx", "memory");
12771 +}
12772 +
12773 +/**
12774 * atomic64_read - read atomic64 variable
12775 * @v: pointer to type atomic64_t
12776 *
12777 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12778 }
12779
12780 /**
12781 + * atomic64_read_unchecked - read atomic64 variable
12782 + * @v: pointer to type atomic64_unchecked_t
12783 + *
12784 + * Atomically reads the value of @v and returns it.
12785 + */
12786 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12787 +{
12788 + long long r;
12789 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12790 + return r;
12791 + }
12792 +
12793 +/**
12794 * atomic64_add_return - add and return
12795 * @i: integer value to add
12796 * @v: pointer to type atomic64_t
12797 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12798 return i;
12799 }
12800
12801 +/**
12802 + * atomic64_add_return_unchecked - add and return
12803 + * @i: integer value to add
12804 + * @v: pointer to type atomic64_unchecked_t
12805 + *
12806 + * Atomically adds @i to @v and returns @i + *@v
12807 + */
12808 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12809 +{
12810 + alternative_atomic64(add_return_unchecked,
12811 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12812 + ASM_NO_INPUT_CLOBBER("memory"));
12813 + return i;
12814 +}
12815 +
12816 /*
12817 * Other variants with different arithmetic operators:
12818 */
12819 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12820 return a;
12821 }
12822
12823 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12824 +{
12825 + long long a;
12826 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12827 + "S" (v) : "memory", "ecx");
12828 + return a;
12829 +}
12830 +
12831 static inline long long atomic64_dec_return(atomic64_t *v)
12832 {
12833 long long a;
12834 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12835 }
12836
12837 /**
12838 + * atomic64_add_unchecked - add integer to atomic64 variable
12839 + * @i: integer value to add
12840 + * @v: pointer to type atomic64_unchecked_t
12841 + *
12842 + * Atomically adds @i to @v.
12843 + */
12844 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12845 +{
12846 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12847 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12848 + ASM_NO_INPUT_CLOBBER("memory"));
12849 + return i;
12850 +}
12851 +
12852 +/**
12853 * atomic64_sub - subtract the atomic64 variable
12854 * @i: integer value to subtract
12855 * @v: pointer to type atomic64_t
12856 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12857 index 0e1cbfc..5623683 100644
12858 --- a/arch/x86/include/asm/atomic64_64.h
12859 +++ b/arch/x86/include/asm/atomic64_64.h
12860 @@ -18,7 +18,19 @@
12861 */
12862 static inline long atomic64_read(const atomic64_t *v)
12863 {
12864 - return (*(volatile long *)&(v)->counter);
12865 + return (*(volatile const long *)&(v)->counter);
12866 +}
12867 +
12868 +/**
12869 + * atomic64_read_unchecked - read atomic64 variable
12870 + * @v: pointer of type atomic64_unchecked_t
12871 + *
12872 + * Atomically reads the value of @v.
12873 + * Doesn't imply a read memory barrier.
12874 + */
12875 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12876 +{
12877 + return (*(volatile const long *)&(v)->counter);
12878 }
12879
12880 /**
12881 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12882 }
12883
12884 /**
12885 + * atomic64_set_unchecked - set atomic64 variable
12886 + * @v: pointer to type atomic64_unchecked_t
12887 + * @i: required value
12888 + *
12889 + * Atomically sets the value of @v to @i.
12890 + */
12891 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12892 +{
12893 + v->counter = i;
12894 +}
12895 +
12896 +/**
12897 * atomic64_add - add integer to atomic64 variable
12898 * @i: integer value to add
12899 * @v: pointer to type atomic64_t
12900 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12901 */
12902 static inline void atomic64_add(long i, atomic64_t *v)
12903 {
12904 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12905 +
12906 +#ifdef CONFIG_PAX_REFCOUNT
12907 + "jno 0f\n"
12908 + LOCK_PREFIX "subq %1,%0\n"
12909 + "int $4\n0:\n"
12910 + _ASM_EXTABLE(0b, 0b)
12911 +#endif
12912 +
12913 + : "=m" (v->counter)
12914 + : "er" (i), "m" (v->counter));
12915 +}
12916 +
12917 +/**
12918 + * atomic64_add_unchecked - add integer to atomic64 variable
12919 + * @i: integer value to add
12920 + * @v: pointer to type atomic64_unchecked_t
12921 + *
12922 + * Atomically adds @i to @v.
12923 + */
12924 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12925 +{
12926 asm volatile(LOCK_PREFIX "addq %1,%0"
12927 : "=m" (v->counter)
12928 : "er" (i), "m" (v->counter));
12929 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12930 */
12931 static inline void atomic64_sub(long i, atomic64_t *v)
12932 {
12933 - asm volatile(LOCK_PREFIX "subq %1,%0"
12934 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12935 +
12936 +#ifdef CONFIG_PAX_REFCOUNT
12937 + "jno 0f\n"
12938 + LOCK_PREFIX "addq %1,%0\n"
12939 + "int $4\n0:\n"
12940 + _ASM_EXTABLE(0b, 0b)
12941 +#endif
12942 +
12943 + : "=m" (v->counter)
12944 + : "er" (i), "m" (v->counter));
12945 +}
12946 +
12947 +/**
12948 + * atomic64_sub_unchecked - subtract the atomic64 variable
12949 + * @i: integer value to subtract
12950 + * @v: pointer to type atomic64_unchecked_t
12951 + *
12952 + * Atomically subtracts @i from @v.
12953 + */
12954 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12955 +{
12956 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12957 : "=m" (v->counter)
12958 : "er" (i), "m" (v->counter));
12959 }
12960 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12961 {
12962 unsigned char c;
12963
12964 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12965 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12966 +
12967 +#ifdef CONFIG_PAX_REFCOUNT
12968 + "jno 0f\n"
12969 + LOCK_PREFIX "addq %2,%0\n"
12970 + "int $4\n0:\n"
12971 + _ASM_EXTABLE(0b, 0b)
12972 +#endif
12973 +
12974 + "sete %1\n"
12975 : "=m" (v->counter), "=qm" (c)
12976 : "er" (i), "m" (v->counter) : "memory");
12977 return c;
12978 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12979 */
12980 static inline void atomic64_inc(atomic64_t *v)
12981 {
12982 + asm volatile(LOCK_PREFIX "incq %0\n"
12983 +
12984 +#ifdef CONFIG_PAX_REFCOUNT
12985 + "jno 0f\n"
12986 + LOCK_PREFIX "decq %0\n"
12987 + "int $4\n0:\n"
12988 + _ASM_EXTABLE(0b, 0b)
12989 +#endif
12990 +
12991 + : "=m" (v->counter)
12992 + : "m" (v->counter));
12993 +}
12994 +
12995 +/**
12996 + * atomic64_inc_unchecked - increment atomic64 variable
12997 + * @v: pointer to type atomic64_unchecked_t
12998 + *
12999 + * Atomically increments @v by 1.
13000 + */
13001 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13002 +{
13003 asm volatile(LOCK_PREFIX "incq %0"
13004 : "=m" (v->counter)
13005 : "m" (v->counter));
13006 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13007 */
13008 static inline void atomic64_dec(atomic64_t *v)
13009 {
13010 - asm volatile(LOCK_PREFIX "decq %0"
13011 + asm volatile(LOCK_PREFIX "decq %0\n"
13012 +
13013 +#ifdef CONFIG_PAX_REFCOUNT
13014 + "jno 0f\n"
13015 + LOCK_PREFIX "incq %0\n"
13016 + "int $4\n0:\n"
13017 + _ASM_EXTABLE(0b, 0b)
13018 +#endif
13019 +
13020 + : "=m" (v->counter)
13021 + : "m" (v->counter));
13022 +}
13023 +
13024 +/**
13025 + * atomic64_dec_unchecked - decrement atomic64 variable
13026 + * @v: pointer to type atomic64_t
13027 + *
13028 + * Atomically decrements @v by 1.
13029 + */
13030 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13031 +{
13032 + asm volatile(LOCK_PREFIX "decq %0\n"
13033 : "=m" (v->counter)
13034 : "m" (v->counter));
13035 }
13036 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13037 {
13038 unsigned char c;
13039
13040 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13041 + asm volatile(LOCK_PREFIX "decq %0\n"
13042 +
13043 +#ifdef CONFIG_PAX_REFCOUNT
13044 + "jno 0f\n"
13045 + LOCK_PREFIX "incq %0\n"
13046 + "int $4\n0:\n"
13047 + _ASM_EXTABLE(0b, 0b)
13048 +#endif
13049 +
13050 + "sete %1\n"
13051 : "=m" (v->counter), "=qm" (c)
13052 : "m" (v->counter) : "memory");
13053 return c != 0;
13054 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13055 {
13056 unsigned char c;
13057
13058 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13059 + asm volatile(LOCK_PREFIX "incq %0\n"
13060 +
13061 +#ifdef CONFIG_PAX_REFCOUNT
13062 + "jno 0f\n"
13063 + LOCK_PREFIX "decq %0\n"
13064 + "int $4\n0:\n"
13065 + _ASM_EXTABLE(0b, 0b)
13066 +#endif
13067 +
13068 + "sete %1\n"
13069 : "=m" (v->counter), "=qm" (c)
13070 : "m" (v->counter) : "memory");
13071 return c != 0;
13072 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13073 {
13074 unsigned char c;
13075
13076 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13077 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13078 +
13079 +#ifdef CONFIG_PAX_REFCOUNT
13080 + "jno 0f\n"
13081 + LOCK_PREFIX "subq %2,%0\n"
13082 + "int $4\n0:\n"
13083 + _ASM_EXTABLE(0b, 0b)
13084 +#endif
13085 +
13086 + "sets %1\n"
13087 : "=m" (v->counter), "=qm" (c)
13088 : "er" (i), "m" (v->counter) : "memory");
13089 return c;
13090 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13091 */
13092 static inline long atomic64_add_return(long i, atomic64_t *v)
13093 {
13094 + return i + xadd_check_overflow(&v->counter, i);
13095 +}
13096 +
13097 +/**
13098 + * atomic64_add_return_unchecked - add and return
13099 + * @i: integer value to add
13100 + * @v: pointer to type atomic64_unchecked_t
13101 + *
13102 + * Atomically adds @i to @v and returns @i + @v
13103 + */
13104 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13105 +{
13106 return i + xadd(&v->counter, i);
13107 }
13108
13109 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13110 }
13111
13112 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13113 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13114 +{
13115 + return atomic64_add_return_unchecked(1, v);
13116 +}
13117 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13118
13119 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13120 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13121 return cmpxchg(&v->counter, old, new);
13122 }
13123
13124 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13125 +{
13126 + return cmpxchg(&v->counter, old, new);
13127 +}
13128 +
13129 static inline long atomic64_xchg(atomic64_t *v, long new)
13130 {
13131 return xchg(&v->counter, new);
13132 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13133 */
13134 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13135 {
13136 - long c, old;
13137 + long c, old, new;
13138 c = atomic64_read(v);
13139 for (;;) {
13140 - if (unlikely(c == (u)))
13141 + if (unlikely(c == u))
13142 break;
13143 - old = atomic64_cmpxchg((v), c, c + (a));
13144 +
13145 + asm volatile("add %2,%0\n"
13146 +
13147 +#ifdef CONFIG_PAX_REFCOUNT
13148 + "jno 0f\n"
13149 + "sub %2,%0\n"
13150 + "int $4\n0:\n"
13151 + _ASM_EXTABLE(0b, 0b)
13152 +#endif
13153 +
13154 + : "=r" (new)
13155 + : "0" (c), "ir" (a));
13156 +
13157 + old = atomic64_cmpxchg(v, c, new);
13158 if (likely(old == c))
13159 break;
13160 c = old;
13161 }
13162 - return c != (u);
13163 + return c != u;
13164 }
13165
13166 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13167 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13168 index 6dfd019..28e188d 100644
13169 --- a/arch/x86/include/asm/bitops.h
13170 +++ b/arch/x86/include/asm/bitops.h
13171 @@ -40,7 +40,7 @@
13172 * a mask operation on a byte.
13173 */
13174 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13175 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13176 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13177 #define CONST_MASK(nr) (1 << ((nr) & 7))
13178
13179 /**
13180 @@ -486,7 +486,7 @@ static inline int fls(int x)
13181 * at position 64.
13182 */
13183 #ifdef CONFIG_X86_64
13184 -static __always_inline int fls64(__u64 x)
13185 +static __always_inline long fls64(__u64 x)
13186 {
13187 int bitpos = -1;
13188 /*
13189 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13190 index 4fa687a..60f2d39 100644
13191 --- a/arch/x86/include/asm/boot.h
13192 +++ b/arch/x86/include/asm/boot.h
13193 @@ -6,10 +6,15 @@
13194 #include <uapi/asm/boot.h>
13195
13196 /* Physical address where kernel should be loaded. */
13197 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13198 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13199 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13200 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13201
13202 +#ifndef __ASSEMBLY__
13203 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13204 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13205 +#endif
13206 +
13207 /* Minimum kernel alignment, as a power of two */
13208 #ifdef CONFIG_X86_64
13209 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13210 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13211 index 48f99f1..d78ebf9 100644
13212 --- a/arch/x86/include/asm/cache.h
13213 +++ b/arch/x86/include/asm/cache.h
13214 @@ -5,12 +5,13 @@
13215
13216 /* L1 cache line size */
13217 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13218 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13219 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13220
13221 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13222 +#define __read_only __attribute__((__section__(".data..read_only")))
13223
13224 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13225 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13226 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13227
13228 #ifdef CONFIG_X86_VSMP
13229 #ifdef CONFIG_SMP
13230 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13231 index 9863ee3..4a1f8e1 100644
13232 --- a/arch/x86/include/asm/cacheflush.h
13233 +++ b/arch/x86/include/asm/cacheflush.h
13234 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13235 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13236
13237 if (pg_flags == _PGMT_DEFAULT)
13238 - return -1;
13239 + return ~0UL;
13240 else if (pg_flags == _PGMT_WC)
13241 return _PAGE_CACHE_WC;
13242 else if (pg_flags == _PGMT_UC_MINUS)
13243 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13244 index 46fc474..b02b0f9 100644
13245 --- a/arch/x86/include/asm/checksum_32.h
13246 +++ b/arch/x86/include/asm/checksum_32.h
13247 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13248 int len, __wsum sum,
13249 int *src_err_ptr, int *dst_err_ptr);
13250
13251 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13252 + int len, __wsum sum,
13253 + int *src_err_ptr, int *dst_err_ptr);
13254 +
13255 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13256 + int len, __wsum sum,
13257 + int *src_err_ptr, int *dst_err_ptr);
13258 +
13259 /*
13260 * Note: when you get a NULL pointer exception here this means someone
13261 * passed in an incorrect kernel address to one of these functions.
13262 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13263 int *err_ptr)
13264 {
13265 might_sleep();
13266 - return csum_partial_copy_generic((__force void *)src, dst,
13267 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13268 len, sum, err_ptr, NULL);
13269 }
13270
13271 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13272 {
13273 might_sleep();
13274 if (access_ok(VERIFY_WRITE, dst, len))
13275 - return csum_partial_copy_generic(src, (__force void *)dst,
13276 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13277 len, sum, NULL, err_ptr);
13278
13279 if (len)
13280 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13281 index 8d871ea..c1a0dc9 100644
13282 --- a/arch/x86/include/asm/cmpxchg.h
13283 +++ b/arch/x86/include/asm/cmpxchg.h
13284 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13285 __compiletime_error("Bad argument size for cmpxchg");
13286 extern void __xadd_wrong_size(void)
13287 __compiletime_error("Bad argument size for xadd");
13288 +extern void __xadd_check_overflow_wrong_size(void)
13289 + __compiletime_error("Bad argument size for xadd_check_overflow");
13290 extern void __add_wrong_size(void)
13291 __compiletime_error("Bad argument size for add");
13292 +extern void __add_check_overflow_wrong_size(void)
13293 + __compiletime_error("Bad argument size for add_check_overflow");
13294
13295 /*
13296 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13297 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13298 __ret; \
13299 })
13300
13301 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13302 + ({ \
13303 + __typeof__ (*(ptr)) __ret = (arg); \
13304 + switch (sizeof(*(ptr))) { \
13305 + case __X86_CASE_L: \
13306 + asm volatile (lock #op "l %0, %1\n" \
13307 + "jno 0f\n" \
13308 + "mov %0,%1\n" \
13309 + "int $4\n0:\n" \
13310 + _ASM_EXTABLE(0b, 0b) \
13311 + : "+r" (__ret), "+m" (*(ptr)) \
13312 + : : "memory", "cc"); \
13313 + break; \
13314 + case __X86_CASE_Q: \
13315 + asm volatile (lock #op "q %q0, %1\n" \
13316 + "jno 0f\n" \
13317 + "mov %0,%1\n" \
13318 + "int $4\n0:\n" \
13319 + _ASM_EXTABLE(0b, 0b) \
13320 + : "+r" (__ret), "+m" (*(ptr)) \
13321 + : : "memory", "cc"); \
13322 + break; \
13323 + default: \
13324 + __ ## op ## _check_overflow_wrong_size(); \
13325 + } \
13326 + __ret; \
13327 + })
13328 +
13329 /*
13330 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13331 * Since this is generally used to protect other memory information, we
13332 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13333 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13334 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13335
13336 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13337 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13338 +
13339 #define __add(ptr, inc, lock) \
13340 ({ \
13341 __typeof__ (*(ptr)) __ret = (inc); \
13342 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13343 index 59c6c40..5e0b22c 100644
13344 --- a/arch/x86/include/asm/compat.h
13345 +++ b/arch/x86/include/asm/compat.h
13346 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13347 typedef u32 compat_uint_t;
13348 typedef u32 compat_ulong_t;
13349 typedef u64 __attribute__((aligned(4))) compat_u64;
13350 -typedef u32 compat_uptr_t;
13351 +typedef u32 __user compat_uptr_t;
13352
13353 struct compat_timespec {
13354 compat_time_t tv_sec;
13355 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13356 index 2d9075e..b75a844 100644
13357 --- a/arch/x86/include/asm/cpufeature.h
13358 +++ b/arch/x86/include/asm/cpufeature.h
13359 @@ -206,7 +206,7 @@
13360 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13361 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13362 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13363 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13364 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13365 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13366 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13367 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13368 @@ -375,7 +375,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13369 ".section .discard,\"aw\",@progbits\n"
13370 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13371 ".previous\n"
13372 - ".section .altinstr_replacement,\"ax\"\n"
13373 + ".section .altinstr_replacement,\"a\"\n"
13374 "3: movb $1,%0\n"
13375 "4:\n"
13376 ".previous\n"
13377 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13378 index 8bf1c06..b6ae785 100644
13379 --- a/arch/x86/include/asm/desc.h
13380 +++ b/arch/x86/include/asm/desc.h
13381 @@ -4,6 +4,7 @@
13382 #include <asm/desc_defs.h>
13383 #include <asm/ldt.h>
13384 #include <asm/mmu.h>
13385 +#include <asm/pgtable.h>
13386
13387 #include <linux/smp.h>
13388 #include <linux/percpu.h>
13389 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13390
13391 desc->type = (info->read_exec_only ^ 1) << 1;
13392 desc->type |= info->contents << 2;
13393 + desc->type |= info->seg_not_present ^ 1;
13394
13395 desc->s = 1;
13396 desc->dpl = 0x3;
13397 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13398 }
13399
13400 extern struct desc_ptr idt_descr;
13401 -extern gate_desc idt_table[];
13402 extern struct desc_ptr nmi_idt_descr;
13403 -extern gate_desc nmi_idt_table[];
13404 -
13405 -struct gdt_page {
13406 - struct desc_struct gdt[GDT_ENTRIES];
13407 -} __attribute__((aligned(PAGE_SIZE)));
13408 -
13409 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13410 +extern gate_desc idt_table[256];
13411 +extern gate_desc nmi_idt_table[256];
13412
13413 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13414 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13415 {
13416 - return per_cpu(gdt_page, cpu).gdt;
13417 + return cpu_gdt_table[cpu];
13418 }
13419
13420 #ifdef CONFIG_X86_64
13421 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13422 unsigned long base, unsigned dpl, unsigned flags,
13423 unsigned short seg)
13424 {
13425 - gate->a = (seg << 16) | (base & 0xffff);
13426 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13427 + gate->gate.offset_low = base;
13428 + gate->gate.seg = seg;
13429 + gate->gate.reserved = 0;
13430 + gate->gate.type = type;
13431 + gate->gate.s = 0;
13432 + gate->gate.dpl = dpl;
13433 + gate->gate.p = 1;
13434 + gate->gate.offset_high = base >> 16;
13435 }
13436
13437 #endif
13438 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13439
13440 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13441 {
13442 + pax_open_kernel();
13443 memcpy(&idt[entry], gate, sizeof(*gate));
13444 + pax_close_kernel();
13445 }
13446
13447 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13448 {
13449 + pax_open_kernel();
13450 memcpy(&ldt[entry], desc, 8);
13451 + pax_close_kernel();
13452 }
13453
13454 static inline void
13455 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13456 default: size = sizeof(*gdt); break;
13457 }
13458
13459 + pax_open_kernel();
13460 memcpy(&gdt[entry], desc, size);
13461 + pax_close_kernel();
13462 }
13463
13464 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13465 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13466
13467 static inline void native_load_tr_desc(void)
13468 {
13469 + pax_open_kernel();
13470 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13471 + pax_close_kernel();
13472 }
13473
13474 static inline void native_load_gdt(const struct desc_ptr *dtr)
13475 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13476 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13477 unsigned int i;
13478
13479 + pax_open_kernel();
13480 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13481 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13482 + pax_close_kernel();
13483 }
13484
13485 #define _LDT_empty(info) \
13486 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13487 preempt_enable();
13488 }
13489
13490 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13491 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13492 {
13493 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13494 }
13495 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13496 }
13497
13498 #ifdef CONFIG_X86_64
13499 -static inline void set_nmi_gate(int gate, void *addr)
13500 +static inline void set_nmi_gate(int gate, const void *addr)
13501 {
13502 gate_desc s;
13503
13504 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13505 }
13506 #endif
13507
13508 -static inline void _set_gate(int gate, unsigned type, void *addr,
13509 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13510 unsigned dpl, unsigned ist, unsigned seg)
13511 {
13512 gate_desc s;
13513 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13514 * Pentium F0 0F bugfix can have resulted in the mapped
13515 * IDT being write-protected.
13516 */
13517 -static inline void set_intr_gate(unsigned int n, void *addr)
13518 +static inline void set_intr_gate(unsigned int n, const void *addr)
13519 {
13520 BUG_ON((unsigned)n > 0xFF);
13521 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13522 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13523 /*
13524 * This routine sets up an interrupt gate at directory privilege level 3.
13525 */
13526 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13527 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13528 {
13529 BUG_ON((unsigned)n > 0xFF);
13530 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13531 }
13532
13533 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13534 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13535 {
13536 BUG_ON((unsigned)n > 0xFF);
13537 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13538 }
13539
13540 -static inline void set_trap_gate(unsigned int n, void *addr)
13541 +static inline void set_trap_gate(unsigned int n, const void *addr)
13542 {
13543 BUG_ON((unsigned)n > 0xFF);
13544 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13545 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13546 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13547 {
13548 BUG_ON((unsigned)n > 0xFF);
13549 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13550 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13551 }
13552
13553 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13554 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13555 {
13556 BUG_ON((unsigned)n > 0xFF);
13557 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13558 }
13559
13560 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13561 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13562 {
13563 BUG_ON((unsigned)n > 0xFF);
13564 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13565 }
13566
13567 +#ifdef CONFIG_X86_32
13568 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13569 +{
13570 + struct desc_struct d;
13571 +
13572 + if (likely(limit))
13573 + limit = (limit - 1UL) >> PAGE_SHIFT;
13574 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13575 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13576 +}
13577 +#endif
13578 +
13579 #endif /* _ASM_X86_DESC_H */
13580 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13581 index 278441f..b95a174 100644
13582 --- a/arch/x86/include/asm/desc_defs.h
13583 +++ b/arch/x86/include/asm/desc_defs.h
13584 @@ -31,6 +31,12 @@ struct desc_struct {
13585 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13586 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13587 };
13588 + struct {
13589 + u16 offset_low;
13590 + u16 seg;
13591 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13592 + unsigned offset_high: 16;
13593 + } gate;
13594 };
13595 } __attribute__((packed));
13596
13597 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13598 index ced283a..ffe04cc 100644
13599 --- a/arch/x86/include/asm/div64.h
13600 +++ b/arch/x86/include/asm/div64.h
13601 @@ -39,7 +39,7 @@
13602 __mod; \
13603 })
13604
13605 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13606 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13607 {
13608 union {
13609 u64 v64;
13610 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13611 index 9c999c1..3860cb8 100644
13612 --- a/arch/x86/include/asm/elf.h
13613 +++ b/arch/x86/include/asm/elf.h
13614 @@ -243,7 +243,25 @@ extern int force_personality32;
13615 the loader. We need to make sure that it is out of the way of the program
13616 that it will "exec", and that there is sufficient room for the brk. */
13617
13618 +#ifdef CONFIG_PAX_SEGMEXEC
13619 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13620 +#else
13621 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13622 +#endif
13623 +
13624 +#ifdef CONFIG_PAX_ASLR
13625 +#ifdef CONFIG_X86_32
13626 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13627 +
13628 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13629 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13630 +#else
13631 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13632 +
13633 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13634 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13635 +#endif
13636 +#endif
13637
13638 /* This yields a mask that user programs can use to figure out what
13639 instruction set this CPU supports. This could be done in user space,
13640 @@ -296,16 +314,12 @@ do { \
13641
13642 #define ARCH_DLINFO \
13643 do { \
13644 - if (vdso_enabled) \
13645 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13646 - (unsigned long)current->mm->context.vdso); \
13647 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13648 } while (0)
13649
13650 #define ARCH_DLINFO_X32 \
13651 do { \
13652 - if (vdso_enabled) \
13653 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13654 - (unsigned long)current->mm->context.vdso); \
13655 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13656 } while (0)
13657
13658 #define AT_SYSINFO 32
13659 @@ -320,7 +334,7 @@ else \
13660
13661 #endif /* !CONFIG_X86_32 */
13662
13663 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13664 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13665
13666 #define VDSO_ENTRY \
13667 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13668 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13669 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13670 #define compat_arch_setup_additional_pages syscall32_setup_pages
13671
13672 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13673 -#define arch_randomize_brk arch_randomize_brk
13674 -
13675 /*
13676 * True on X86_32 or when emulating IA32 on X86_64
13677 */
13678 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13679 index 75ce3f4..882e801 100644
13680 --- a/arch/x86/include/asm/emergency-restart.h
13681 +++ b/arch/x86/include/asm/emergency-restart.h
13682 @@ -13,6 +13,6 @@ enum reboot_type {
13683
13684 extern enum reboot_type reboot_type;
13685
13686 -extern void machine_emergency_restart(void);
13687 +extern void machine_emergency_restart(void) __noreturn;
13688
13689 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13690 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13691 index 41ab26e..a88c9e6 100644
13692 --- a/arch/x86/include/asm/fpu-internal.h
13693 +++ b/arch/x86/include/asm/fpu-internal.h
13694 @@ -126,7 +126,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13695 ({ \
13696 int err; \
13697 asm volatile(ASM_STAC "\n" \
13698 - "1:" #insn "\n\t" \
13699 + "1:" \
13700 + __copyuser_seg \
13701 + #insn "\n\t" \
13702 "2: " ASM_CLAC "\n" \
13703 ".section .fixup,\"ax\"\n" \
13704 "3: movl $-1,%[err]\n" \
13705 @@ -299,7 +301,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13706 "emms\n\t" /* clear stack tags */
13707 "fildl %P[addr]", /* set F?P to defined value */
13708 X86_FEATURE_FXSAVE_LEAK,
13709 - [addr] "m" (tsk->thread.fpu.has_fpu));
13710 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13711
13712 return fpu_restore_checking(&tsk->thread.fpu);
13713 }
13714 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13715 index be27ba1..8f13ff9 100644
13716 --- a/arch/x86/include/asm/futex.h
13717 +++ b/arch/x86/include/asm/futex.h
13718 @@ -12,6 +12,7 @@
13719 #include <asm/smap.h>
13720
13721 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13722 + typecheck(u32 __user *, uaddr); \
13723 asm volatile("\t" ASM_STAC "\n" \
13724 "1:\t" insn "\n" \
13725 "2:\t" ASM_CLAC "\n" \
13726 @@ -20,15 +21,16 @@
13727 "\tjmp\t2b\n" \
13728 "\t.previous\n" \
13729 _ASM_EXTABLE(1b, 3b) \
13730 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13731 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13732 : "i" (-EFAULT), "0" (oparg), "1" (0))
13733
13734 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13735 + typecheck(u32 __user *, uaddr); \
13736 asm volatile("\t" ASM_STAC "\n" \
13737 "1:\tmovl %2, %0\n" \
13738 "\tmovl\t%0, %3\n" \
13739 "\t" insn "\n" \
13740 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13741 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13742 "\tjnz\t1b\n" \
13743 "3:\t" ASM_CLAC "\n" \
13744 "\t.section .fixup,\"ax\"\n" \
13745 @@ -38,7 +40,7 @@
13746 _ASM_EXTABLE(1b, 4b) \
13747 _ASM_EXTABLE(2b, 4b) \
13748 : "=&a" (oldval), "=&r" (ret), \
13749 - "+m" (*uaddr), "=&r" (tem) \
13750 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13751 : "r" (oparg), "i" (-EFAULT), "1" (0))
13752
13753 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13754 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13755
13756 switch (op) {
13757 case FUTEX_OP_SET:
13758 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13759 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13760 break;
13761 case FUTEX_OP_ADD:
13762 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13763 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13764 uaddr, oparg);
13765 break;
13766 case FUTEX_OP_OR:
13767 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13768 return -EFAULT;
13769
13770 asm volatile("\t" ASM_STAC "\n"
13771 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13772 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13773 "2:\t" ASM_CLAC "\n"
13774 "\t.section .fixup, \"ax\"\n"
13775 "3:\tmov %3, %0\n"
13776 "\tjmp 2b\n"
13777 "\t.previous\n"
13778 _ASM_EXTABLE(1b, 3b)
13779 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13780 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13781 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13782 : "memory"
13783 );
13784 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13785 index eb92a6e..b98b2f4 100644
13786 --- a/arch/x86/include/asm/hw_irq.h
13787 +++ b/arch/x86/include/asm/hw_irq.h
13788 @@ -136,8 +136,8 @@ extern void setup_ioapic_dest(void);
13789 extern void enable_IO_APIC(void);
13790
13791 /* Statistics */
13792 -extern atomic_t irq_err_count;
13793 -extern atomic_t irq_mis_count;
13794 +extern atomic_unchecked_t irq_err_count;
13795 +extern atomic_unchecked_t irq_mis_count;
13796
13797 /* EISA */
13798 extern void eisa_set_level_irq(unsigned int irq);
13799 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13800 index a203659..9889f1c 100644
13801 --- a/arch/x86/include/asm/i8259.h
13802 +++ b/arch/x86/include/asm/i8259.h
13803 @@ -62,7 +62,7 @@ struct legacy_pic {
13804 void (*init)(int auto_eoi);
13805 int (*irq_pending)(unsigned int irq);
13806 void (*make_irq)(unsigned int irq);
13807 -};
13808 +} __do_const;
13809
13810 extern struct legacy_pic *legacy_pic;
13811 extern struct legacy_pic null_legacy_pic;
13812 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13813 index d8e8eef..1765f78 100644
13814 --- a/arch/x86/include/asm/io.h
13815 +++ b/arch/x86/include/asm/io.h
13816 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13817 "m" (*(volatile type __force *)addr) barrier); }
13818
13819 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13820 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13821 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13822 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13823 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13824
13825 build_mmio_read(__readb, "b", unsigned char, "=q", )
13826 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13827 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13828 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13829 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13830
13831 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13832 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13833 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13834 return ioremap_nocache(offset, size);
13835 }
13836
13837 -extern void iounmap(volatile void __iomem *addr);
13838 +extern void iounmap(const volatile void __iomem *addr);
13839
13840 extern void set_iounmap_nonlazy(void);
13841
13842 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13843
13844 #include <linux/vmalloc.h>
13845
13846 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13847 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13848 +{
13849 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13850 +}
13851 +
13852 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13853 +{
13854 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13855 +}
13856 +
13857 /*
13858 * Convert a virtual cached pointer to an uncached pointer
13859 */
13860 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13861 index bba3cf8..06bc8da 100644
13862 --- a/arch/x86/include/asm/irqflags.h
13863 +++ b/arch/x86/include/asm/irqflags.h
13864 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13865 sti; \
13866 sysexit
13867
13868 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13869 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13870 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13871 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13872 +
13873 #else
13874 #define INTERRUPT_RETURN iret
13875 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13876 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13877 index d3ddd17..c9fb0cc 100644
13878 --- a/arch/x86/include/asm/kprobes.h
13879 +++ b/arch/x86/include/asm/kprobes.h
13880 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13881 #define RELATIVEJUMP_SIZE 5
13882 #define RELATIVECALL_OPCODE 0xe8
13883 #define RELATIVE_ADDR_SIZE 4
13884 -#define MAX_STACK_SIZE 64
13885 -#define MIN_STACK_SIZE(ADDR) \
13886 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13887 - THREAD_SIZE - (unsigned long)(ADDR))) \
13888 - ? (MAX_STACK_SIZE) \
13889 - : (((unsigned long)current_thread_info()) + \
13890 - THREAD_SIZE - (unsigned long)(ADDR)))
13891 +#define MAX_STACK_SIZE 64UL
13892 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13893
13894 #define flush_insn_slot(p) do { } while (0)
13895
13896 diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
13897 index dc87b65..85039f9 100644
13898 --- a/arch/x86/include/asm/kvm_host.h
13899 +++ b/arch/x86/include/asm/kvm_host.h
13900 @@ -419,8 +419,8 @@ struct kvm_vcpu_arch {
13901 gpa_t time;
13902 struct pvclock_vcpu_time_info hv_clock;
13903 unsigned int hw_tsc_khz;
13904 - unsigned int time_offset;
13905 - struct page *time_page;
13906 + struct gfn_to_hva_cache pv_time;
13907 + bool pv_time_enabled;
13908 /* set guest stopped flag in pvclock flags field */
13909 bool pvclock_set_guest_stopped_request;
13910
13911 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13912 index 2d89e39..baee879 100644
13913 --- a/arch/x86/include/asm/local.h
13914 +++ b/arch/x86/include/asm/local.h
13915 @@ -10,33 +10,97 @@ typedef struct {
13916 atomic_long_t a;
13917 } local_t;
13918
13919 +typedef struct {
13920 + atomic_long_unchecked_t a;
13921 +} local_unchecked_t;
13922 +
13923 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13924
13925 #define local_read(l) atomic_long_read(&(l)->a)
13926 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13927 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13928 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13929
13930 static inline void local_inc(local_t *l)
13931 {
13932 - asm volatile(_ASM_INC "%0"
13933 + asm volatile(_ASM_INC "%0\n"
13934 +
13935 +#ifdef CONFIG_PAX_REFCOUNT
13936 + "jno 0f\n"
13937 + _ASM_DEC "%0\n"
13938 + "int $4\n0:\n"
13939 + _ASM_EXTABLE(0b, 0b)
13940 +#endif
13941 +
13942 + : "+m" (l->a.counter));
13943 +}
13944 +
13945 +static inline void local_inc_unchecked(local_unchecked_t *l)
13946 +{
13947 + asm volatile(_ASM_INC "%0\n"
13948 : "+m" (l->a.counter));
13949 }
13950
13951 static inline void local_dec(local_t *l)
13952 {
13953 - asm volatile(_ASM_DEC "%0"
13954 + asm volatile(_ASM_DEC "%0\n"
13955 +
13956 +#ifdef CONFIG_PAX_REFCOUNT
13957 + "jno 0f\n"
13958 + _ASM_INC "%0\n"
13959 + "int $4\n0:\n"
13960 + _ASM_EXTABLE(0b, 0b)
13961 +#endif
13962 +
13963 + : "+m" (l->a.counter));
13964 +}
13965 +
13966 +static inline void local_dec_unchecked(local_unchecked_t *l)
13967 +{
13968 + asm volatile(_ASM_DEC "%0\n"
13969 : "+m" (l->a.counter));
13970 }
13971
13972 static inline void local_add(long i, local_t *l)
13973 {
13974 - asm volatile(_ASM_ADD "%1,%0"
13975 + asm volatile(_ASM_ADD "%1,%0\n"
13976 +
13977 +#ifdef CONFIG_PAX_REFCOUNT
13978 + "jno 0f\n"
13979 + _ASM_SUB "%1,%0\n"
13980 + "int $4\n0:\n"
13981 + _ASM_EXTABLE(0b, 0b)
13982 +#endif
13983 +
13984 + : "+m" (l->a.counter)
13985 + : "ir" (i));
13986 +}
13987 +
13988 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13989 +{
13990 + asm volatile(_ASM_ADD "%1,%0\n"
13991 : "+m" (l->a.counter)
13992 : "ir" (i));
13993 }
13994
13995 static inline void local_sub(long i, local_t *l)
13996 {
13997 - asm volatile(_ASM_SUB "%1,%0"
13998 + asm volatile(_ASM_SUB "%1,%0\n"
13999 +
14000 +#ifdef CONFIG_PAX_REFCOUNT
14001 + "jno 0f\n"
14002 + _ASM_ADD "%1,%0\n"
14003 + "int $4\n0:\n"
14004 + _ASM_EXTABLE(0b, 0b)
14005 +#endif
14006 +
14007 + : "+m" (l->a.counter)
14008 + : "ir" (i));
14009 +}
14010 +
14011 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14012 +{
14013 + asm volatile(_ASM_SUB "%1,%0\n"
14014 : "+m" (l->a.counter)
14015 : "ir" (i));
14016 }
14017 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14018 {
14019 unsigned char c;
14020
14021 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14022 + asm volatile(_ASM_SUB "%2,%0\n"
14023 +
14024 +#ifdef CONFIG_PAX_REFCOUNT
14025 + "jno 0f\n"
14026 + _ASM_ADD "%2,%0\n"
14027 + "int $4\n0:\n"
14028 + _ASM_EXTABLE(0b, 0b)
14029 +#endif
14030 +
14031 + "sete %1\n"
14032 : "+m" (l->a.counter), "=qm" (c)
14033 : "ir" (i) : "memory");
14034 return c;
14035 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14036 {
14037 unsigned char c;
14038
14039 - asm volatile(_ASM_DEC "%0; sete %1"
14040 + asm volatile(_ASM_DEC "%0\n"
14041 +
14042 +#ifdef CONFIG_PAX_REFCOUNT
14043 + "jno 0f\n"
14044 + _ASM_INC "%0\n"
14045 + "int $4\n0:\n"
14046 + _ASM_EXTABLE(0b, 0b)
14047 +#endif
14048 +
14049 + "sete %1\n"
14050 : "+m" (l->a.counter), "=qm" (c)
14051 : : "memory");
14052 return c != 0;
14053 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14054 {
14055 unsigned char c;
14056
14057 - asm volatile(_ASM_INC "%0; sete %1"
14058 + asm volatile(_ASM_INC "%0\n"
14059 +
14060 +#ifdef CONFIG_PAX_REFCOUNT
14061 + "jno 0f\n"
14062 + _ASM_DEC "%0\n"
14063 + "int $4\n0:\n"
14064 + _ASM_EXTABLE(0b, 0b)
14065 +#endif
14066 +
14067 + "sete %1\n"
14068 : "+m" (l->a.counter), "=qm" (c)
14069 : : "memory");
14070 return c != 0;
14071 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14072 {
14073 unsigned char c;
14074
14075 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14076 + asm volatile(_ASM_ADD "%2,%0\n"
14077 +
14078 +#ifdef CONFIG_PAX_REFCOUNT
14079 + "jno 0f\n"
14080 + _ASM_SUB "%2,%0\n"
14081 + "int $4\n0:\n"
14082 + _ASM_EXTABLE(0b, 0b)
14083 +#endif
14084 +
14085 + "sets %1\n"
14086 : "+m" (l->a.counter), "=qm" (c)
14087 : "ir" (i) : "memory");
14088 return c;
14089 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14090 static inline long local_add_return(long i, local_t *l)
14091 {
14092 long __i = i;
14093 + asm volatile(_ASM_XADD "%0, %1\n"
14094 +
14095 +#ifdef CONFIG_PAX_REFCOUNT
14096 + "jno 0f\n"
14097 + _ASM_MOV "%0,%1\n"
14098 + "int $4\n0:\n"
14099 + _ASM_EXTABLE(0b, 0b)
14100 +#endif
14101 +
14102 + : "+r" (i), "+m" (l->a.counter)
14103 + : : "memory");
14104 + return i + __i;
14105 +}
14106 +
14107 +/**
14108 + * local_add_return_unchecked - add and return
14109 + * @i: integer value to add
14110 + * @l: pointer to type local_unchecked_t
14111 + *
14112 + * Atomically adds @i to @l and returns @i + @l
14113 + */
14114 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14115 +{
14116 + long __i = i;
14117 asm volatile(_ASM_XADD "%0, %1;"
14118 : "+r" (i), "+m" (l->a.counter)
14119 : : "memory");
14120 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14121
14122 #define local_cmpxchg(l, o, n) \
14123 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14124 +#define local_cmpxchg_unchecked(l, o, n) \
14125 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14126 /* Always has a lock prefix */
14127 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14128
14129 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14130 new file mode 100644
14131 index 0000000..2bfd3ba
14132 --- /dev/null
14133 +++ b/arch/x86/include/asm/mman.h
14134 @@ -0,0 +1,15 @@
14135 +#ifndef _X86_MMAN_H
14136 +#define _X86_MMAN_H
14137 +
14138 +#include <uapi/asm/mman.h>
14139 +
14140 +#ifdef __KERNEL__
14141 +#ifndef __ASSEMBLY__
14142 +#ifdef CONFIG_X86_32
14143 +#define arch_mmap_check i386_mmap_check
14144 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14145 +#endif
14146 +#endif
14147 +#endif
14148 +
14149 +#endif /* X86_MMAN_H */
14150 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14151 index 5f55e69..e20bfb1 100644
14152 --- a/arch/x86/include/asm/mmu.h
14153 +++ b/arch/x86/include/asm/mmu.h
14154 @@ -9,7 +9,7 @@
14155 * we put the segment information here.
14156 */
14157 typedef struct {
14158 - void *ldt;
14159 + struct desc_struct *ldt;
14160 int size;
14161
14162 #ifdef CONFIG_X86_64
14163 @@ -18,7 +18,19 @@ typedef struct {
14164 #endif
14165
14166 struct mutex lock;
14167 - void *vdso;
14168 + unsigned long vdso;
14169 +
14170 +#ifdef CONFIG_X86_32
14171 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14172 + unsigned long user_cs_base;
14173 + unsigned long user_cs_limit;
14174 +
14175 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14176 + cpumask_t cpu_user_cs_mask;
14177 +#endif
14178 +
14179 +#endif
14180 +#endif
14181 } mm_context_t;
14182
14183 #ifdef CONFIG_SMP
14184 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14185 index cdbf367..adb37ac 100644
14186 --- a/arch/x86/include/asm/mmu_context.h
14187 +++ b/arch/x86/include/asm/mmu_context.h
14188 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
14189
14190 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14191 {
14192 +
14193 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14194 + unsigned int i;
14195 + pgd_t *pgd;
14196 +
14197 + pax_open_kernel();
14198 + pgd = get_cpu_pgd(smp_processor_id());
14199 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14200 + set_pgd_batched(pgd+i, native_make_pgd(0));
14201 + pax_close_kernel();
14202 +#endif
14203 +
14204 #ifdef CONFIG_SMP
14205 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14206 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14207 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14208 struct task_struct *tsk)
14209 {
14210 unsigned cpu = smp_processor_id();
14211 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14212 + int tlbstate = TLBSTATE_OK;
14213 +#endif
14214
14215 if (likely(prev != next)) {
14216 #ifdef CONFIG_SMP
14217 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14218 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14219 +#endif
14220 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14221 this_cpu_write(cpu_tlbstate.active_mm, next);
14222 #endif
14223 cpumask_set_cpu(cpu, mm_cpumask(next));
14224
14225 /* Re-load page tables */
14226 +#ifdef CONFIG_PAX_PER_CPU_PGD
14227 + pax_open_kernel();
14228 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14229 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14230 + pax_close_kernel();
14231 + load_cr3(get_cpu_pgd(cpu));
14232 +#else
14233 load_cr3(next->pgd);
14234 +#endif
14235
14236 /* stop flush ipis for the previous mm */
14237 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14238 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14239 */
14240 if (unlikely(prev->context.ldt != next->context.ldt))
14241 load_LDT_nolock(&next->context);
14242 - }
14243 +
14244 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14245 + if (!(__supported_pte_mask & _PAGE_NX)) {
14246 + smp_mb__before_clear_bit();
14247 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14248 + smp_mb__after_clear_bit();
14249 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14250 + }
14251 +#endif
14252 +
14253 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14254 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14255 + prev->context.user_cs_limit != next->context.user_cs_limit))
14256 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14257 #ifdef CONFIG_SMP
14258 + else if (unlikely(tlbstate != TLBSTATE_OK))
14259 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14260 +#endif
14261 +#endif
14262 +
14263 + }
14264 else {
14265 +
14266 +#ifdef CONFIG_PAX_PER_CPU_PGD
14267 + pax_open_kernel();
14268 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
14269 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
14270 + pax_close_kernel();
14271 + load_cr3(get_cpu_pgd(cpu));
14272 +#endif
14273 +
14274 +#ifdef CONFIG_SMP
14275 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14276 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14277
14278 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14279 * tlb flush IPI delivery. We must reload CR3
14280 * to make sure to use no freed page tables.
14281 */
14282 +
14283 +#ifndef CONFIG_PAX_PER_CPU_PGD
14284 load_cr3(next->pgd);
14285 +#endif
14286 +
14287 load_LDT_nolock(&next->context);
14288 +
14289 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14290 + if (!(__supported_pte_mask & _PAGE_NX))
14291 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14292 +#endif
14293 +
14294 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14295 +#ifdef CONFIG_PAX_PAGEEXEC
14296 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14297 +#endif
14298 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14299 +#endif
14300 +
14301 }
14302 +#endif
14303 }
14304 -#endif
14305 }
14306
14307 #define activate_mm(prev, next) \
14308 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14309 index e3b7819..b257c64 100644
14310 --- a/arch/x86/include/asm/module.h
14311 +++ b/arch/x86/include/asm/module.h
14312 @@ -5,6 +5,7 @@
14313
14314 #ifdef CONFIG_X86_64
14315 /* X86_64 does not define MODULE_PROC_FAMILY */
14316 +#define MODULE_PROC_FAMILY ""
14317 #elif defined CONFIG_M486
14318 #define MODULE_PROC_FAMILY "486 "
14319 #elif defined CONFIG_M586
14320 @@ -57,8 +58,20 @@
14321 #error unknown processor family
14322 #endif
14323
14324 -#ifdef CONFIG_X86_32
14325 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14326 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14327 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14328 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14329 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14330 +#else
14331 +#define MODULE_PAX_KERNEXEC ""
14332 #endif
14333
14334 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14335 +#define MODULE_PAX_UDEREF "UDEREF "
14336 +#else
14337 +#define MODULE_PAX_UDEREF ""
14338 +#endif
14339 +
14340 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14341 +
14342 #endif /* _ASM_X86_MODULE_H */
14343 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14344 index c0fa356..07a498a 100644
14345 --- a/arch/x86/include/asm/nmi.h
14346 +++ b/arch/x86/include/asm/nmi.h
14347 @@ -42,11 +42,11 @@ struct nmiaction {
14348 nmi_handler_t handler;
14349 unsigned long flags;
14350 const char *name;
14351 -};
14352 +} __do_const;
14353
14354 #define register_nmi_handler(t, fn, fg, n, init...) \
14355 ({ \
14356 - static struct nmiaction init fn##_na = { \
14357 + static const struct nmiaction init fn##_na = { \
14358 .handler = (fn), \
14359 .name = (n), \
14360 .flags = (fg), \
14361 @@ -54,7 +54,7 @@ struct nmiaction {
14362 __register_nmi_handler((t), &fn##_na); \
14363 })
14364
14365 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14366 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14367
14368 void unregister_nmi_handler(unsigned int, const char *);
14369
14370 diff --git a/arch/x86/include/asm/page_64_types.h b/arch/x86/include/asm/page_64_types.h
14371 index 320f7bb..e89f8f8 100644
14372 --- a/arch/x86/include/asm/page_64_types.h
14373 +++ b/arch/x86/include/asm/page_64_types.h
14374 @@ -56,7 +56,7 @@ void copy_page(void *to, void *from);
14375
14376 /* duplicated to the one in bootmem.h */
14377 extern unsigned long max_pfn;
14378 -extern unsigned long phys_base;
14379 +extern const unsigned long phys_base;
14380
14381 extern unsigned long __phys_addr(unsigned long);
14382 #define __phys_reloc_hide(x) (x)
14383 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14384 index 5edd174..c395822 100644
14385 --- a/arch/x86/include/asm/paravirt.h
14386 +++ b/arch/x86/include/asm/paravirt.h
14387 @@ -564,7 +564,7 @@ static inline pmd_t __pmd(pmdval_t val)
14388 return (pmd_t) { ret };
14389 }
14390
14391 -static inline pmdval_t pmd_val(pmd_t pmd)
14392 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14393 {
14394 pmdval_t ret;
14395
14396 @@ -630,6 +630,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14397 val);
14398 }
14399
14400 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14401 +{
14402 + pgdval_t val = native_pgd_val(pgd);
14403 +
14404 + if (sizeof(pgdval_t) > sizeof(long))
14405 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14406 + val, (u64)val >> 32);
14407 + else
14408 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14409 + val);
14410 +}
14411 +
14412 static inline void pgd_clear(pgd_t *pgdp)
14413 {
14414 set_pgd(pgdp, __pgd(0));
14415 @@ -711,6 +723,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14416 pv_mmu_ops.set_fixmap(idx, phys, flags);
14417 }
14418
14419 +#ifdef CONFIG_PAX_KERNEXEC
14420 +static inline unsigned long pax_open_kernel(void)
14421 +{
14422 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14423 +}
14424 +
14425 +static inline unsigned long pax_close_kernel(void)
14426 +{
14427 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14428 +}
14429 +#else
14430 +static inline unsigned long pax_open_kernel(void) { return 0; }
14431 +static inline unsigned long pax_close_kernel(void) { return 0; }
14432 +#endif
14433 +
14434 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14435
14436 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14437 @@ -927,7 +954,7 @@ extern void default_banner(void);
14438
14439 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14440 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14441 -#define PARA_INDIRECT(addr) *%cs:addr
14442 +#define PARA_INDIRECT(addr) *%ss:addr
14443 #endif
14444
14445 #define INTERRUPT_RETURN \
14446 @@ -1002,6 +1029,21 @@ extern void default_banner(void);
14447 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14448 CLBR_NONE, \
14449 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14450 +
14451 +#define GET_CR0_INTO_RDI \
14452 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14453 + mov %rax,%rdi
14454 +
14455 +#define SET_RDI_INTO_CR0 \
14456 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14457 +
14458 +#define GET_CR3_INTO_RDI \
14459 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14460 + mov %rax,%rdi
14461 +
14462 +#define SET_RDI_INTO_CR3 \
14463 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14464 +
14465 #endif /* CONFIG_X86_32 */
14466
14467 #endif /* __ASSEMBLY__ */
14468 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14469 index 142236e..5446ffbc 100644
14470 --- a/arch/x86/include/asm/paravirt_types.h
14471 +++ b/arch/x86/include/asm/paravirt_types.h
14472 @@ -84,7 +84,7 @@ struct pv_init_ops {
14473 */
14474 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14475 unsigned long addr, unsigned len);
14476 -};
14477 +} __no_const;
14478
14479
14480 struct pv_lazy_ops {
14481 @@ -97,7 +97,7 @@ struct pv_time_ops {
14482 unsigned long long (*sched_clock)(void);
14483 unsigned long long (*steal_clock)(int cpu);
14484 unsigned long (*get_tsc_khz)(void);
14485 -};
14486 +} __no_const;
14487
14488 struct pv_cpu_ops {
14489 /* hooks for various privileged instructions */
14490 @@ -191,7 +191,7 @@ struct pv_cpu_ops {
14491
14492 void (*start_context_switch)(struct task_struct *prev);
14493 void (*end_context_switch)(struct task_struct *next);
14494 -};
14495 +} __no_const;
14496
14497 struct pv_irq_ops {
14498 /*
14499 @@ -222,7 +222,7 @@ struct pv_apic_ops {
14500 unsigned long start_eip,
14501 unsigned long start_esp);
14502 #endif
14503 -};
14504 +} __no_const;
14505
14506 struct pv_mmu_ops {
14507 unsigned long (*read_cr2)(void);
14508 @@ -312,6 +312,7 @@ struct pv_mmu_ops {
14509 struct paravirt_callee_save make_pud;
14510
14511 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14512 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14513 #endif /* PAGETABLE_LEVELS == 4 */
14514 #endif /* PAGETABLE_LEVELS >= 3 */
14515
14516 @@ -323,6 +324,12 @@ struct pv_mmu_ops {
14517 an mfn. We can tell which is which from the index. */
14518 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14519 phys_addr_t phys, pgprot_t flags);
14520 +
14521 +#ifdef CONFIG_PAX_KERNEXEC
14522 + unsigned long (*pax_open_kernel)(void);
14523 + unsigned long (*pax_close_kernel)(void);
14524 +#endif
14525 +
14526 };
14527
14528 struct arch_spinlock;
14529 @@ -333,7 +340,7 @@ struct pv_lock_ops {
14530 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14531 int (*spin_trylock)(struct arch_spinlock *lock);
14532 void (*spin_unlock)(struct arch_spinlock *lock);
14533 -};
14534 +} __no_const;
14535
14536 /* This contains all the paravirt structures: we get a convenient
14537 * number for each function using the offset which we use to indicate
14538 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14539 index b4389a4..7024269 100644
14540 --- a/arch/x86/include/asm/pgalloc.h
14541 +++ b/arch/x86/include/asm/pgalloc.h
14542 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14543 pmd_t *pmd, pte_t *pte)
14544 {
14545 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14546 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14547 +}
14548 +
14549 +static inline void pmd_populate_user(struct mm_struct *mm,
14550 + pmd_t *pmd, pte_t *pte)
14551 +{
14552 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14553 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14554 }
14555
14556 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14557
14558 #ifdef CONFIG_X86_PAE
14559 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14560 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14561 +{
14562 + pud_populate(mm, pudp, pmd);
14563 +}
14564 #else /* !CONFIG_X86_PAE */
14565 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14566 {
14567 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14568 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14569 }
14570 +
14571 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14572 +{
14573 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14574 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14575 +}
14576 #endif /* CONFIG_X86_PAE */
14577
14578 #if PAGETABLE_LEVELS > 3
14579 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14580 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14581 }
14582
14583 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14584 +{
14585 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14586 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14587 +}
14588 +
14589 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14590 {
14591 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14592 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14593 index f2b489c..4f7e2e5 100644
14594 --- a/arch/x86/include/asm/pgtable-2level.h
14595 +++ b/arch/x86/include/asm/pgtable-2level.h
14596 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14597
14598 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14599 {
14600 + pax_open_kernel();
14601 *pmdp = pmd;
14602 + pax_close_kernel();
14603 }
14604
14605 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14606 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14607 index 4cc9f2b..5fd9226 100644
14608 --- a/arch/x86/include/asm/pgtable-3level.h
14609 +++ b/arch/x86/include/asm/pgtable-3level.h
14610 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14611
14612 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14613 {
14614 + pax_open_kernel();
14615 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14616 + pax_close_kernel();
14617 }
14618
14619 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14620 {
14621 + pax_open_kernel();
14622 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14623 + pax_close_kernel();
14624 }
14625
14626 /*
14627 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14628 index 1c1a955..50f828c 100644
14629 --- a/arch/x86/include/asm/pgtable.h
14630 +++ b/arch/x86/include/asm/pgtable.h
14631 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14632
14633 #ifndef __PAGETABLE_PUD_FOLDED
14634 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14635 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14636 #define pgd_clear(pgd) native_pgd_clear(pgd)
14637 #endif
14638
14639 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14640
14641 #define arch_end_context_switch(prev) do {} while(0)
14642
14643 +#define pax_open_kernel() native_pax_open_kernel()
14644 +#define pax_close_kernel() native_pax_close_kernel()
14645 #endif /* CONFIG_PARAVIRT */
14646
14647 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14648 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14649 +
14650 +#ifdef CONFIG_PAX_KERNEXEC
14651 +static inline unsigned long native_pax_open_kernel(void)
14652 +{
14653 + unsigned long cr0;
14654 +
14655 + preempt_disable();
14656 + barrier();
14657 + cr0 = read_cr0() ^ X86_CR0_WP;
14658 + BUG_ON(cr0 & X86_CR0_WP);
14659 + write_cr0(cr0);
14660 + return cr0 ^ X86_CR0_WP;
14661 +}
14662 +
14663 +static inline unsigned long native_pax_close_kernel(void)
14664 +{
14665 + unsigned long cr0;
14666 +
14667 + cr0 = read_cr0() ^ X86_CR0_WP;
14668 + BUG_ON(!(cr0 & X86_CR0_WP));
14669 + write_cr0(cr0);
14670 + barrier();
14671 + preempt_enable_no_resched();
14672 + return cr0 ^ X86_CR0_WP;
14673 +}
14674 +#else
14675 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14676 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14677 +#endif
14678 +
14679 /*
14680 * The following only work if pte_present() is true.
14681 * Undefined behaviour if not..
14682 */
14683 +static inline int pte_user(pte_t pte)
14684 +{
14685 + return pte_val(pte) & _PAGE_USER;
14686 +}
14687 +
14688 static inline int pte_dirty(pte_t pte)
14689 {
14690 return pte_flags(pte) & _PAGE_DIRTY;
14691 @@ -200,9 +240,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14692 return pte_clear_flags(pte, _PAGE_RW);
14693 }
14694
14695 +static inline pte_t pte_mkread(pte_t pte)
14696 +{
14697 + return __pte(pte_val(pte) | _PAGE_USER);
14698 +}
14699 +
14700 static inline pte_t pte_mkexec(pte_t pte)
14701 {
14702 - return pte_clear_flags(pte, _PAGE_NX);
14703 +#ifdef CONFIG_X86_PAE
14704 + if (__supported_pte_mask & _PAGE_NX)
14705 + return pte_clear_flags(pte, _PAGE_NX);
14706 + else
14707 +#endif
14708 + return pte_set_flags(pte, _PAGE_USER);
14709 +}
14710 +
14711 +static inline pte_t pte_exprotect(pte_t pte)
14712 +{
14713 +#ifdef CONFIG_X86_PAE
14714 + if (__supported_pte_mask & _PAGE_NX)
14715 + return pte_set_flags(pte, _PAGE_NX);
14716 + else
14717 +#endif
14718 + return pte_clear_flags(pte, _PAGE_USER);
14719 }
14720
14721 static inline pte_t pte_mkdirty(pte_t pte)
14722 @@ -394,6 +454,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14723 #endif
14724
14725 #ifndef __ASSEMBLY__
14726 +
14727 +#ifdef CONFIG_PAX_PER_CPU_PGD
14728 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14729 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14730 +{
14731 + return cpu_pgd[cpu];
14732 +}
14733 +#endif
14734 +
14735 #include <linux/mm_types.h>
14736
14737 static inline int pte_none(pte_t pte)
14738 @@ -583,7 +652,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14739
14740 static inline int pgd_bad(pgd_t pgd)
14741 {
14742 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14743 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14744 }
14745
14746 static inline int pgd_none(pgd_t pgd)
14747 @@ -606,7 +675,12 @@ static inline int pgd_none(pgd_t pgd)
14748 * pgd_offset() returns a (pgd_t *)
14749 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14750 */
14751 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14752 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14753 +
14754 +#ifdef CONFIG_PAX_PER_CPU_PGD
14755 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14756 +#endif
14757 +
14758 /*
14759 * a shortcut which implies the use of the kernel's pgd, instead
14760 * of a process's
14761 @@ -617,6 +691,20 @@ static inline int pgd_none(pgd_t pgd)
14762 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14763 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14764
14765 +#ifdef CONFIG_X86_32
14766 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14767 +#else
14768 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14769 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14770 +
14771 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14772 +#define PAX_USER_SHADOW_BASE (_AC(1,UL) << TASK_SIZE_MAX_SHIFT)
14773 +#else
14774 +#define PAX_USER_SHADOW_BASE (_AC(0,UL))
14775 +#endif
14776 +
14777 +#endif
14778 +
14779 #ifndef __ASSEMBLY__
14780
14781 extern int direct_gbpages;
14782 @@ -781,11 +869,23 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14783 * dst and src can be on the same page, but the range must not overlap,
14784 * and must not cross a page boundary.
14785 */
14786 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14787 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14788 {
14789 - memcpy(dst, src, count * sizeof(pgd_t));
14790 + pax_open_kernel();
14791 + while (count--)
14792 + *dst++ = *src++;
14793 + pax_close_kernel();
14794 }
14795
14796 +#ifdef CONFIG_PAX_PER_CPU_PGD
14797 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14798 +#endif
14799 +
14800 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14801 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14802 +#else
14803 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14804 +#endif
14805
14806 #include <asm-generic/pgtable.h>
14807 #endif /* __ASSEMBLY__ */
14808 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14809 index 8faa215..a8a17ea 100644
14810 --- a/arch/x86/include/asm/pgtable_32.h
14811 +++ b/arch/x86/include/asm/pgtable_32.h
14812 @@ -25,9 +25,6 @@
14813 struct mm_struct;
14814 struct vm_area_struct;
14815
14816 -extern pgd_t swapper_pg_dir[1024];
14817 -extern pgd_t initial_page_table[1024];
14818 -
14819 static inline void pgtable_cache_init(void) { }
14820 static inline void check_pgt_cache(void) { }
14821 void paging_init(void);
14822 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14823 # include <asm/pgtable-2level.h>
14824 #endif
14825
14826 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14827 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14828 +#ifdef CONFIG_X86_PAE
14829 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14830 +#endif
14831 +
14832 #if defined(CONFIG_HIGHPTE)
14833 #define pte_offset_map(dir, address) \
14834 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14835 @@ -62,7 +65,9 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14836 /* Clear a kernel PTE and flush it from the TLB */
14837 #define kpte_clear_flush(ptep, vaddr) \
14838 do { \
14839 + pax_open_kernel(); \
14840 pte_clear(&init_mm, (vaddr), (ptep)); \
14841 + pax_close_kernel(); \
14842 __flush_tlb_one((vaddr)); \
14843 } while (0)
14844
14845 @@ -75,6 +80,9 @@ do { \
14846
14847 #endif /* !__ASSEMBLY__ */
14848
14849 +#define HAVE_ARCH_UNMAPPED_AREA
14850 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14851 +
14852 /*
14853 * kern_addr_valid() is (1) for FLATMEM and (0) for
14854 * SPARSEMEM and DISCONTIGMEM
14855 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14856 index ed5903b..c7fe163 100644
14857 --- a/arch/x86/include/asm/pgtable_32_types.h
14858 +++ b/arch/x86/include/asm/pgtable_32_types.h
14859 @@ -8,7 +8,7 @@
14860 */
14861 #ifdef CONFIG_X86_PAE
14862 # include <asm/pgtable-3level_types.h>
14863 -# define PMD_SIZE (1UL << PMD_SHIFT)
14864 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14865 # define PMD_MASK (~(PMD_SIZE - 1))
14866 #else
14867 # include <asm/pgtable-2level_types.h>
14868 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14869 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14870 #endif
14871
14872 +#ifdef CONFIG_PAX_KERNEXEC
14873 +#ifndef __ASSEMBLY__
14874 +extern unsigned char MODULES_EXEC_VADDR[];
14875 +extern unsigned char MODULES_EXEC_END[];
14876 +#endif
14877 +#include <asm/boot.h>
14878 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14879 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14880 +#else
14881 +#define ktla_ktva(addr) (addr)
14882 +#define ktva_ktla(addr) (addr)
14883 +#endif
14884 +
14885 #define MODULES_VADDR VMALLOC_START
14886 #define MODULES_END VMALLOC_END
14887 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14888 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14889 index 47356f9..deb94a2 100644
14890 --- a/arch/x86/include/asm/pgtable_64.h
14891 +++ b/arch/x86/include/asm/pgtable_64.h
14892 @@ -16,10 +16,14 @@
14893
14894 extern pud_t level3_kernel_pgt[512];
14895 extern pud_t level3_ident_pgt[512];
14896 +extern pud_t level3_vmalloc_start_pgt[512];
14897 +extern pud_t level3_vmalloc_end_pgt[512];
14898 +extern pud_t level3_vmemmap_pgt[512];
14899 +extern pud_t level2_vmemmap_pgt[512];
14900 extern pmd_t level2_kernel_pgt[512];
14901 extern pmd_t level2_fixmap_pgt[512];
14902 -extern pmd_t level2_ident_pgt[512];
14903 -extern pgd_t init_level4_pgt[];
14904 +extern pmd_t level2_ident_pgt[512*2];
14905 +extern pgd_t init_level4_pgt[512];
14906
14907 #define swapper_pg_dir init_level4_pgt
14908
14909 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14910
14911 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14912 {
14913 + pax_open_kernel();
14914 *pmdp = pmd;
14915 + pax_close_kernel();
14916 }
14917
14918 static inline void native_pmd_clear(pmd_t *pmd)
14919 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14920
14921 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14922 {
14923 + pax_open_kernel();
14924 *pudp = pud;
14925 + pax_close_kernel();
14926 }
14927
14928 static inline void native_pud_clear(pud_t *pud)
14929 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14930
14931 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14932 {
14933 + pax_open_kernel();
14934 + *pgdp = pgd;
14935 + pax_close_kernel();
14936 +}
14937 +
14938 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14939 +{
14940 *pgdp = pgd;
14941 }
14942
14943 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14944 index 766ea16..5b96cb3 100644
14945 --- a/arch/x86/include/asm/pgtable_64_types.h
14946 +++ b/arch/x86/include/asm/pgtable_64_types.h
14947 @@ -59,5 +59,10 @@ typedef struct { pteval_t pte; } pte_t;
14948 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14949 #define MODULES_END _AC(0xffffffffff000000, UL)
14950 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14951 +#define MODULES_EXEC_VADDR MODULES_VADDR
14952 +#define MODULES_EXEC_END MODULES_END
14953 +
14954 +#define ktla_ktva(addr) (addr)
14955 +#define ktva_ktla(addr) (addr)
14956
14957 #endif /* _ASM_X86_PGTABLE_64_DEFS_H */
14958 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14959 index 3c32db8..1ddccf5 100644
14960 --- a/arch/x86/include/asm/pgtable_types.h
14961 +++ b/arch/x86/include/asm/pgtable_types.h
14962 @@ -16,13 +16,12 @@
14963 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14964 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14965 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14966 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14967 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14968 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14969 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14970 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14971 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14972 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14973 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14974 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14975 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14976 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14977
14978 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14979 @@ -40,7 +39,6 @@
14980 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14981 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14982 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14983 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14984 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14985 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14986 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14987 @@ -57,8 +55,10 @@
14988
14989 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14990 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14991 -#else
14992 +#elif defined(CONFIG_KMEMCHECK)
14993 #define _PAGE_NX (_AT(pteval_t, 0))
14994 +#else
14995 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14996 #endif
14997
14998 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14999 @@ -116,6 +116,9 @@
15000 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15001 _PAGE_ACCESSED)
15002
15003 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15004 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15005 +
15006 #define __PAGE_KERNEL_EXEC \
15007 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15008 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15009 @@ -126,7 +129,7 @@
15010 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15011 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15012 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15013 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15014 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15015 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15016 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15017 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15018 @@ -188,8 +191,8 @@
15019 * bits are combined, this will alow user to access the high address mapped
15020 * VDSO in the presence of CONFIG_COMPAT_VDSO
15021 */
15022 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15023 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15024 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15025 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15026 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15027 #endif
15028
15029 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15030 {
15031 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15032 }
15033 +#endif
15034
15035 +#if PAGETABLE_LEVELS == 3
15036 +#include <asm-generic/pgtable-nopud.h>
15037 +#endif
15038 +
15039 +#if PAGETABLE_LEVELS == 2
15040 +#include <asm-generic/pgtable-nopmd.h>
15041 +#endif
15042 +
15043 +#ifndef __ASSEMBLY__
15044 #if PAGETABLE_LEVELS > 3
15045 typedef struct { pudval_t pud; } pud_t;
15046
15047 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15048 return pud.pud;
15049 }
15050 #else
15051 -#include <asm-generic/pgtable-nopud.h>
15052 -
15053 static inline pudval_t native_pud_val(pud_t pud)
15054 {
15055 return native_pgd_val(pud.pgd);
15056 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15057 return pmd.pmd;
15058 }
15059 #else
15060 -#include <asm-generic/pgtable-nopmd.h>
15061 -
15062 static inline pmdval_t native_pmd_val(pmd_t pmd)
15063 {
15064 return native_pgd_val(pmd.pud.pgd);
15065 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15066
15067 extern pteval_t __supported_pte_mask;
15068 extern void set_nx(void);
15069 -extern int nx_enabled;
15070
15071 #define pgprot_writecombine pgprot_writecombine
15072 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15073 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15074 index 888184b..a07ac89 100644
15075 --- a/arch/x86/include/asm/processor.h
15076 +++ b/arch/x86/include/asm/processor.h
15077 @@ -287,7 +287,7 @@ struct tss_struct {
15078
15079 } ____cacheline_aligned;
15080
15081 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15082 +extern struct tss_struct init_tss[NR_CPUS];
15083
15084 /*
15085 * Save the original ist values for checking stack pointers during debugging
15086 @@ -827,11 +827,18 @@ static inline void spin_lock_prefetch(const void *x)
15087 */
15088 #define TASK_SIZE PAGE_OFFSET
15089 #define TASK_SIZE_MAX TASK_SIZE
15090 +
15091 +#ifdef CONFIG_PAX_SEGMEXEC
15092 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15093 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15094 +#else
15095 #define STACK_TOP TASK_SIZE
15096 -#define STACK_TOP_MAX STACK_TOP
15097 +#endif
15098 +
15099 +#define STACK_TOP_MAX TASK_SIZE
15100
15101 #define INIT_THREAD { \
15102 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15103 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15104 .vm86_info = NULL, \
15105 .sysenter_cs = __KERNEL_CS, \
15106 .io_bitmap_ptr = NULL, \
15107 @@ -845,7 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
15108 */
15109 #define INIT_TSS { \
15110 .x86_tss = { \
15111 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15112 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15113 .ss0 = __KERNEL_DS, \
15114 .ss1 = __KERNEL_CS, \
15115 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15116 @@ -856,11 +863,7 @@ static inline void spin_lock_prefetch(const void *x)
15117 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15118
15119 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15120 -#define KSTK_TOP(info) \
15121 -({ \
15122 - unsigned long *__ptr = (unsigned long *)(info); \
15123 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15124 -})
15125 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15126
15127 /*
15128 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15129 @@ -875,7 +878,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15130 #define task_pt_regs(task) \
15131 ({ \
15132 struct pt_regs *__regs__; \
15133 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15134 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15135 __regs__ - 1; \
15136 })
15137
15138 @@ -885,13 +888,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15139 /*
15140 * User space process size. 47bits minus one guard page.
15141 */
15142 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15143 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15144
15145 /* This decides where the kernel will search for a free chunk of vm
15146 * space during mmap's.
15147 */
15148 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15149 - 0xc0000000 : 0xFFFFe000)
15150 + 0xc0000000 : 0xFFFFf000)
15151
15152 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15153 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15154 @@ -902,11 +905,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15155 #define STACK_TOP_MAX TASK_SIZE_MAX
15156
15157 #define INIT_THREAD { \
15158 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15159 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15160 }
15161
15162 #define INIT_TSS { \
15163 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15164 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15165 }
15166
15167 /*
15168 @@ -934,6 +937,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15169 */
15170 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15171
15172 +#ifdef CONFIG_PAX_SEGMEXEC
15173 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15174 +#endif
15175 +
15176 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15177
15178 /* Get/set a process' ability to use the timestamp counter instruction */
15179 @@ -994,12 +1001,12 @@ extern bool cpu_has_amd_erratum(const int *);
15180 #define cpu_has_amd_erratum(x) (false)
15181 #endif /* CONFIG_CPU_SUP_AMD */
15182
15183 -extern unsigned long arch_align_stack(unsigned long sp);
15184 +#define arch_align_stack(x) ((x) & ~0xfUL)
15185 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15186
15187 void default_idle(void);
15188 bool set_pm_idle_to_default(void);
15189
15190 -void stop_this_cpu(void *dummy);
15191 +void stop_this_cpu(void *dummy) __noreturn;
15192
15193 #endif /* _ASM_X86_PROCESSOR_H */
15194 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15195 index 942a086..6c26446 100644
15196 --- a/arch/x86/include/asm/ptrace.h
15197 +++ b/arch/x86/include/asm/ptrace.h
15198 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15199 }
15200
15201 /*
15202 - * user_mode_vm(regs) determines whether a register set came from user mode.
15203 + * user_mode(regs) determines whether a register set came from user mode.
15204 * This is true if V8086 mode was enabled OR if the register set was from
15205 * protected mode with RPL-3 CS value. This tricky test checks that with
15206 * one comparison. Many places in the kernel can bypass this full check
15207 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15208 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15209 + * be used.
15210 */
15211 -static inline int user_mode(struct pt_regs *regs)
15212 +static inline int user_mode_novm(struct pt_regs *regs)
15213 {
15214 #ifdef CONFIG_X86_32
15215 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15216 #else
15217 - return !!(regs->cs & 3);
15218 + return !!(regs->cs & SEGMENT_RPL_MASK);
15219 #endif
15220 }
15221
15222 -static inline int user_mode_vm(struct pt_regs *regs)
15223 +static inline int user_mode(struct pt_regs *regs)
15224 {
15225 #ifdef CONFIG_X86_32
15226 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
15227 USER_RPL;
15228 #else
15229 - return user_mode(regs);
15230 + return user_mode_novm(regs);
15231 #endif
15232 }
15233
15234 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
15235 #ifdef CONFIG_X86_64
15236 static inline bool user_64bit_mode(struct pt_regs *regs)
15237 {
15238 + unsigned long cs = regs->cs & 0xffff;
15239 #ifndef CONFIG_PARAVIRT
15240 /*
15241 * On non-paravirt systems, this is the only long mode CPL 3
15242 * selector. We do not allow long mode selectors in the LDT.
15243 */
15244 - return regs->cs == __USER_CS;
15245 + return cs == __USER_CS;
15246 #else
15247 /* Headers are too twisted for this to go in paravirt.h. */
15248 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
15249 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
15250 #endif
15251 }
15252
15253 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
15254 * Traps from the kernel do not save sp and ss.
15255 * Use the helper function to retrieve sp.
15256 */
15257 - if (offset == offsetof(struct pt_regs, sp) &&
15258 - regs->cs == __KERNEL_CS)
15259 - return kernel_stack_pointer(regs);
15260 + if (offset == offsetof(struct pt_regs, sp)) {
15261 + unsigned long cs = regs->cs & 0xffff;
15262 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
15263 + return kernel_stack_pointer(regs);
15264 + }
15265 #endif
15266 return *(unsigned long *)((unsigned long)regs + offset);
15267 }
15268 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
15269 index fe1ec5b..dc5c3fe 100644
15270 --- a/arch/x86/include/asm/realmode.h
15271 +++ b/arch/x86/include/asm/realmode.h
15272 @@ -22,16 +22,14 @@ struct real_mode_header {
15273 #endif
15274 /* APM/BIOS reboot */
15275 u32 machine_real_restart_asm;
15276 -#ifdef CONFIG_X86_64
15277 u32 machine_real_restart_seg;
15278 -#endif
15279 };
15280
15281 /* This must match data at trampoline_32/64.S */
15282 struct trampoline_header {
15283 #ifdef CONFIG_X86_32
15284 u32 start;
15285 - u16 gdt_pad;
15286 + u16 boot_cs;
15287 u16 gdt_limit;
15288 u32 gdt_base;
15289 #else
15290 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15291 index a82c4f1..ac45053 100644
15292 --- a/arch/x86/include/asm/reboot.h
15293 +++ b/arch/x86/include/asm/reboot.h
15294 @@ -6,13 +6,13 @@
15295 struct pt_regs;
15296
15297 struct machine_ops {
15298 - void (*restart)(char *cmd);
15299 - void (*halt)(void);
15300 - void (*power_off)(void);
15301 + void (* __noreturn restart)(char *cmd);
15302 + void (* __noreturn halt)(void);
15303 + void (* __noreturn power_off)(void);
15304 void (*shutdown)(void);
15305 void (*crash_shutdown)(struct pt_regs *);
15306 - void (*emergency_restart)(void);
15307 -};
15308 + void (* __noreturn emergency_restart)(void);
15309 +} __no_const;
15310
15311 extern struct machine_ops machine_ops;
15312
15313 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15314 index 2dbe4a7..ce1db00 100644
15315 --- a/arch/x86/include/asm/rwsem.h
15316 +++ b/arch/x86/include/asm/rwsem.h
15317 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15318 {
15319 asm volatile("# beginning down_read\n\t"
15320 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15321 +
15322 +#ifdef CONFIG_PAX_REFCOUNT
15323 + "jno 0f\n"
15324 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15325 + "int $4\n0:\n"
15326 + _ASM_EXTABLE(0b, 0b)
15327 +#endif
15328 +
15329 /* adds 0x00000001 */
15330 " jns 1f\n"
15331 " call call_rwsem_down_read_failed\n"
15332 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15333 "1:\n\t"
15334 " mov %1,%2\n\t"
15335 " add %3,%2\n\t"
15336 +
15337 +#ifdef CONFIG_PAX_REFCOUNT
15338 + "jno 0f\n"
15339 + "sub %3,%2\n"
15340 + "int $4\n0:\n"
15341 + _ASM_EXTABLE(0b, 0b)
15342 +#endif
15343 +
15344 " jle 2f\n\t"
15345 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15346 " jnz 1b\n\t"
15347 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15348 long tmp;
15349 asm volatile("# beginning down_write\n\t"
15350 LOCK_PREFIX " xadd %1,(%2)\n\t"
15351 +
15352 +#ifdef CONFIG_PAX_REFCOUNT
15353 + "jno 0f\n"
15354 + "mov %1,(%2)\n"
15355 + "int $4\n0:\n"
15356 + _ASM_EXTABLE(0b, 0b)
15357 +#endif
15358 +
15359 /* adds 0xffff0001, returns the old value */
15360 " test %1,%1\n\t"
15361 /* was the count 0 before? */
15362 @@ -141,6 +165,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15363 long tmp;
15364 asm volatile("# beginning __up_read\n\t"
15365 LOCK_PREFIX " xadd %1,(%2)\n\t"
15366 +
15367 +#ifdef CONFIG_PAX_REFCOUNT
15368 + "jno 0f\n"
15369 + "mov %1,(%2)\n"
15370 + "int $4\n0:\n"
15371 + _ASM_EXTABLE(0b, 0b)
15372 +#endif
15373 +
15374 /* subtracts 1, returns the old value */
15375 " jns 1f\n\t"
15376 " call call_rwsem_wake\n" /* expects old value in %edx */
15377 @@ -159,6 +191,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15378 long tmp;
15379 asm volatile("# beginning __up_write\n\t"
15380 LOCK_PREFIX " xadd %1,(%2)\n\t"
15381 +
15382 +#ifdef CONFIG_PAX_REFCOUNT
15383 + "jno 0f\n"
15384 + "mov %1,(%2)\n"
15385 + "int $4\n0:\n"
15386 + _ASM_EXTABLE(0b, 0b)
15387 +#endif
15388 +
15389 /* subtracts 0xffff0001, returns the old value */
15390 " jns 1f\n\t"
15391 " call call_rwsem_wake\n" /* expects old value in %edx */
15392 @@ -176,6 +216,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15393 {
15394 asm volatile("# beginning __downgrade_write\n\t"
15395 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15396 +
15397 +#ifdef CONFIG_PAX_REFCOUNT
15398 + "jno 0f\n"
15399 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15400 + "int $4\n0:\n"
15401 + _ASM_EXTABLE(0b, 0b)
15402 +#endif
15403 +
15404 /*
15405 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15406 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15407 @@ -194,7 +242,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15408 */
15409 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15410 {
15411 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15412 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15413 +
15414 +#ifdef CONFIG_PAX_REFCOUNT
15415 + "jno 0f\n"
15416 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15417 + "int $4\n0:\n"
15418 + _ASM_EXTABLE(0b, 0b)
15419 +#endif
15420 +
15421 : "+m" (sem->count)
15422 : "er" (delta));
15423 }
15424 @@ -204,7 +260,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15425 */
15426 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15427 {
15428 - return delta + xadd(&sem->count, delta);
15429 + return delta + xadd_check_overflow(&sem->count, delta);
15430 }
15431
15432 #endif /* __KERNEL__ */
15433 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15434 index c48a950..c6d7468 100644
15435 --- a/arch/x86/include/asm/segment.h
15436 +++ b/arch/x86/include/asm/segment.h
15437 @@ -64,10 +64,15 @@
15438 * 26 - ESPFIX small SS
15439 * 27 - per-cpu [ offset to per-cpu data area ]
15440 * 28 - stack_canary-20 [ for stack protector ]
15441 - * 29 - unused
15442 - * 30 - unused
15443 + * 29 - PCI BIOS CS
15444 + * 30 - PCI BIOS DS
15445 * 31 - TSS for double fault handler
15446 */
15447 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15448 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15449 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15450 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15451 +
15452 #define GDT_ENTRY_TLS_MIN 6
15453 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15454
15455 @@ -79,6 +84,8 @@
15456
15457 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15458
15459 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15460 +
15461 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15462
15463 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15464 @@ -104,6 +111,12 @@
15465 #define __KERNEL_STACK_CANARY 0
15466 #endif
15467
15468 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15469 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15470 +
15471 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15472 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15473 +
15474 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15475
15476 /*
15477 @@ -141,7 +154,7 @@
15478 */
15479
15480 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15481 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15482 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15483
15484
15485 #else
15486 @@ -165,6 +178,8 @@
15487 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15488 #define __USER32_DS __USER_DS
15489
15490 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15491 +
15492 #define GDT_ENTRY_TSS 8 /* needs two entries */
15493 #define GDT_ENTRY_LDT 10 /* needs two entries */
15494 #define GDT_ENTRY_TLS_MIN 12
15495 @@ -185,6 +200,7 @@
15496 #endif
15497
15498 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15499 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15500 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15501 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15502 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15503 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15504 {
15505 unsigned long __limit;
15506 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15507 - return __limit + 1;
15508 + return __limit;
15509 }
15510
15511 #endif /* !__ASSEMBLY__ */
15512 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15513 index b073aae..39f9bdd 100644
15514 --- a/arch/x86/include/asm/smp.h
15515 +++ b/arch/x86/include/asm/smp.h
15516 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15517 /* cpus sharing the last level cache: */
15518 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15519 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15520 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15521 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15522
15523 static inline struct cpumask *cpu_sibling_mask(int cpu)
15524 {
15525 @@ -79,7 +79,7 @@ struct smp_ops {
15526
15527 void (*send_call_func_ipi)(const struct cpumask *mask);
15528 void (*send_call_func_single_ipi)(int cpu);
15529 -};
15530 +} __no_const;
15531
15532 /* Globals due to paravirt */
15533 extern void set_cpu_sibling_map(int cpu);
15534 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15535 extern int safe_smp_processor_id(void);
15536
15537 #elif defined(CONFIG_X86_64_SMP)
15538 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15539 -
15540 -#define stack_smp_processor_id() \
15541 -({ \
15542 - struct thread_info *ti; \
15543 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15544 - ti->cpu; \
15545 -})
15546 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15547 +#define stack_smp_processor_id() raw_smp_processor_id()
15548 #define safe_smp_processor_id() smp_processor_id()
15549
15550 #endif
15551 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15552 index 33692ea..350a534 100644
15553 --- a/arch/x86/include/asm/spinlock.h
15554 +++ b/arch/x86/include/asm/spinlock.h
15555 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15556 static inline void arch_read_lock(arch_rwlock_t *rw)
15557 {
15558 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15559 +
15560 +#ifdef CONFIG_PAX_REFCOUNT
15561 + "jno 0f\n"
15562 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15563 + "int $4\n0:\n"
15564 + _ASM_EXTABLE(0b, 0b)
15565 +#endif
15566 +
15567 "jns 1f\n"
15568 "call __read_lock_failed\n\t"
15569 "1:\n"
15570 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15571 static inline void arch_write_lock(arch_rwlock_t *rw)
15572 {
15573 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15574 +
15575 +#ifdef CONFIG_PAX_REFCOUNT
15576 + "jno 0f\n"
15577 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15578 + "int $4\n0:\n"
15579 + _ASM_EXTABLE(0b, 0b)
15580 +#endif
15581 +
15582 "jz 1f\n"
15583 "call __write_lock_failed\n\t"
15584 "1:\n"
15585 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15586
15587 static inline void arch_read_unlock(arch_rwlock_t *rw)
15588 {
15589 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15590 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15591 +
15592 +#ifdef CONFIG_PAX_REFCOUNT
15593 + "jno 0f\n"
15594 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15595 + "int $4\n0:\n"
15596 + _ASM_EXTABLE(0b, 0b)
15597 +#endif
15598 +
15599 :"+m" (rw->lock) : : "memory");
15600 }
15601
15602 static inline void arch_write_unlock(arch_rwlock_t *rw)
15603 {
15604 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15605 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15606 +
15607 +#ifdef CONFIG_PAX_REFCOUNT
15608 + "jno 0f\n"
15609 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15610 + "int $4\n0:\n"
15611 + _ASM_EXTABLE(0b, 0b)
15612 +#endif
15613 +
15614 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15615 }
15616
15617 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15618 index 6a99859..03cb807 100644
15619 --- a/arch/x86/include/asm/stackprotector.h
15620 +++ b/arch/x86/include/asm/stackprotector.h
15621 @@ -47,7 +47,7 @@
15622 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15623 */
15624 #define GDT_STACK_CANARY_INIT \
15625 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15626 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15627
15628 /*
15629 * Initialize the stackprotector canary value.
15630 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15631
15632 static inline void load_stack_canary_segment(void)
15633 {
15634 -#ifdef CONFIG_X86_32
15635 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15636 asm volatile ("mov %0, %%gs" : : "r" (0));
15637 #endif
15638 }
15639 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15640 index 70bbe39..4ae2bd4 100644
15641 --- a/arch/x86/include/asm/stacktrace.h
15642 +++ b/arch/x86/include/asm/stacktrace.h
15643 @@ -11,28 +11,20 @@
15644
15645 extern int kstack_depth_to_print;
15646
15647 -struct thread_info;
15648 +struct task_struct;
15649 struct stacktrace_ops;
15650
15651 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15652 - unsigned long *stack,
15653 - unsigned long bp,
15654 - const struct stacktrace_ops *ops,
15655 - void *data,
15656 - unsigned long *end,
15657 - int *graph);
15658 +typedef unsigned long walk_stack_t(struct task_struct *task,
15659 + void *stack_start,
15660 + unsigned long *stack,
15661 + unsigned long bp,
15662 + const struct stacktrace_ops *ops,
15663 + void *data,
15664 + unsigned long *end,
15665 + int *graph);
15666
15667 -extern unsigned long
15668 -print_context_stack(struct thread_info *tinfo,
15669 - unsigned long *stack, unsigned long bp,
15670 - const struct stacktrace_ops *ops, void *data,
15671 - unsigned long *end, int *graph);
15672 -
15673 -extern unsigned long
15674 -print_context_stack_bp(struct thread_info *tinfo,
15675 - unsigned long *stack, unsigned long bp,
15676 - const struct stacktrace_ops *ops, void *data,
15677 - unsigned long *end, int *graph);
15678 +extern walk_stack_t print_context_stack;
15679 +extern walk_stack_t print_context_stack_bp;
15680
15681 /* Generic stack tracer with callbacks */
15682
15683 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15684 void (*address)(void *data, unsigned long address, int reliable);
15685 /* On negative return stop dumping */
15686 int (*stack)(void *data, char *name);
15687 - walk_stack_t walk_stack;
15688 + walk_stack_t *walk_stack;
15689 };
15690
15691 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15692 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15693 index 4ec45b3..a4f0a8a 100644
15694 --- a/arch/x86/include/asm/switch_to.h
15695 +++ b/arch/x86/include/asm/switch_to.h
15696 @@ -108,7 +108,7 @@ do { \
15697 "call __switch_to\n\t" \
15698 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15699 __switch_canary \
15700 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15701 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15702 "movq %%rax,%%rdi\n\t" \
15703 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15704 "jnz ret_from_fork\n\t" \
15705 @@ -119,7 +119,7 @@ do { \
15706 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15707 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15708 [_tif_fork] "i" (_TIF_FORK), \
15709 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15710 + [thread_info] "m" (current_tinfo), \
15711 [current_task] "m" (current_task) \
15712 __switch_canary_iparam \
15713 : "memory", "cc" __EXTRA_CLOBBER)
15714 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15715 index 2d946e6..e453ec4 100644
15716 --- a/arch/x86/include/asm/thread_info.h
15717 +++ b/arch/x86/include/asm/thread_info.h
15718 @@ -10,6 +10,7 @@
15719 #include <linux/compiler.h>
15720 #include <asm/page.h>
15721 #include <asm/types.h>
15722 +#include <asm/percpu.h>
15723
15724 /*
15725 * low level task data that entry.S needs immediate access to
15726 @@ -24,7 +25,6 @@ struct exec_domain;
15727 #include <linux/atomic.h>
15728
15729 struct thread_info {
15730 - struct task_struct *task; /* main task structure */
15731 struct exec_domain *exec_domain; /* execution domain */
15732 __u32 flags; /* low level flags */
15733 __u32 status; /* thread synchronous flags */
15734 @@ -34,19 +34,13 @@ struct thread_info {
15735 mm_segment_t addr_limit;
15736 struct restart_block restart_block;
15737 void __user *sysenter_return;
15738 -#ifdef CONFIG_X86_32
15739 - unsigned long previous_esp; /* ESP of the previous stack in
15740 - case of nested (IRQ) stacks
15741 - */
15742 - __u8 supervisor_stack[0];
15743 -#endif
15744 + unsigned long lowest_stack;
15745 unsigned int sig_on_uaccess_error:1;
15746 unsigned int uaccess_err:1; /* uaccess failed */
15747 };
15748
15749 -#define INIT_THREAD_INFO(tsk) \
15750 +#define INIT_THREAD_INFO \
15751 { \
15752 - .task = &tsk, \
15753 .exec_domain = &default_exec_domain, \
15754 .flags = 0, \
15755 .cpu = 0, \
15756 @@ -57,7 +51,7 @@ struct thread_info {
15757 }, \
15758 }
15759
15760 -#define init_thread_info (init_thread_union.thread_info)
15761 +#define init_thread_info (init_thread_union.stack)
15762 #define init_stack (init_thread_union.stack)
15763
15764 #else /* !__ASSEMBLY__ */
15765 @@ -98,6 +92,7 @@ struct thread_info {
15766 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15767 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15768 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15769 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15770
15771 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15772 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15773 @@ -122,17 +117,18 @@ struct thread_info {
15774 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15775 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15776 #define _TIF_X32 (1 << TIF_X32)
15777 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15778
15779 /* work to do in syscall_trace_enter() */
15780 #define _TIF_WORK_SYSCALL_ENTRY \
15781 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15782 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15783 - _TIF_NOHZ)
15784 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15785
15786 /* work to do in syscall_trace_leave() */
15787 #define _TIF_WORK_SYSCALL_EXIT \
15788 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15789 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15790 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15791
15792 /* work to do on interrupt/exception return */
15793 #define _TIF_WORK_MASK \
15794 @@ -143,7 +139,7 @@ struct thread_info {
15795 /* work to do on any return to user space */
15796 #define _TIF_ALLWORK_MASK \
15797 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15798 - _TIF_NOHZ)
15799 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15800
15801 /* Only used for 64 bit */
15802 #define _TIF_DO_NOTIFY_MASK \
15803 @@ -159,45 +155,40 @@ struct thread_info {
15804
15805 #define PREEMPT_ACTIVE 0x10000000
15806
15807 -#ifdef CONFIG_X86_32
15808 -
15809 -#define STACK_WARN (THREAD_SIZE/8)
15810 -/*
15811 - * macros/functions for gaining access to the thread information structure
15812 - *
15813 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15814 - */
15815 -#ifndef __ASSEMBLY__
15816 -
15817 -
15818 -/* how to get the current stack pointer from C */
15819 -register unsigned long current_stack_pointer asm("esp") __used;
15820 -
15821 -/* how to get the thread information struct from C */
15822 -static inline struct thread_info *current_thread_info(void)
15823 -{
15824 - return (struct thread_info *)
15825 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15826 -}
15827 -
15828 -#else /* !__ASSEMBLY__ */
15829 -
15830 +#ifdef __ASSEMBLY__
15831 /* how to get the thread information struct from ASM */
15832 #define GET_THREAD_INFO(reg) \
15833 - movl $-THREAD_SIZE, reg; \
15834 - andl %esp, reg
15835 + mov PER_CPU_VAR(current_tinfo), reg
15836
15837 /* use this one if reg already contains %esp */
15838 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15839 - andl $-THREAD_SIZE, reg
15840 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15841 +#else
15842 +/* how to get the thread information struct from C */
15843 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15844 +
15845 +static __always_inline struct thread_info *current_thread_info(void)
15846 +{
15847 + return this_cpu_read_stable(current_tinfo);
15848 +}
15849 +#endif
15850 +
15851 +#ifdef CONFIG_X86_32
15852 +
15853 +#define STACK_WARN (THREAD_SIZE/8)
15854 +/*
15855 + * macros/functions for gaining access to the thread information structure
15856 + *
15857 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15858 + */
15859 +#ifndef __ASSEMBLY__
15860 +
15861 +/* how to get the current stack pointer from C */
15862 +register unsigned long current_stack_pointer asm("esp") __used;
15863
15864 #endif
15865
15866 #else /* X86_32 */
15867
15868 -#include <asm/percpu.h>
15869 -#define KERNEL_STACK_OFFSET (5*8)
15870 -
15871 /*
15872 * macros/functions for gaining access to the thread information structure
15873 * preempt_count needs to be 1 initially, until the scheduler is functional.
15874 @@ -205,27 +196,8 @@ static inline struct thread_info *current_thread_info(void)
15875 #ifndef __ASSEMBLY__
15876 DECLARE_PER_CPU(unsigned long, kernel_stack);
15877
15878 -static inline struct thread_info *current_thread_info(void)
15879 -{
15880 - struct thread_info *ti;
15881 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15882 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15883 - return ti;
15884 -}
15885 -
15886 -#else /* !__ASSEMBLY__ */
15887 -
15888 -/* how to get the thread information struct from ASM */
15889 -#define GET_THREAD_INFO(reg) \
15890 - movq PER_CPU_VAR(kernel_stack),reg ; \
15891 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15892 -
15893 -/*
15894 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15895 - * a certain register (to be used in assembler memory operands).
15896 - */
15897 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15898 -
15899 +/* how to get the current stack pointer from C */
15900 +register unsigned long current_stack_pointer asm("rsp") __used;
15901 #endif
15902
15903 #endif /* !X86_32 */
15904 @@ -286,5 +258,12 @@ static inline bool is_ia32_task(void)
15905 extern void arch_task_cache_init(void);
15906 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15907 extern void arch_release_task_struct(struct task_struct *tsk);
15908 +
15909 +#define __HAVE_THREAD_FUNCTIONS
15910 +#define task_thread_info(task) (&(task)->tinfo)
15911 +#define task_stack_page(task) ((task)->stack)
15912 +#define setup_thread_stack(p, org) do {} while (0)
15913 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15914 +
15915 #endif
15916 #endif /* _ASM_X86_THREAD_INFO_H */
15917 diff --git a/arch/x86/include/asm/tlb.h b/arch/x86/include/asm/tlb.h
15918 index 4fef207..c779730 100644
15919 --- a/arch/x86/include/asm/tlb.h
15920 +++ b/arch/x86/include/asm/tlb.h
15921 @@ -7,7 +7,7 @@
15922
15923 #define tlb_flush(tlb) \
15924 { \
15925 - if (tlb->fullmm == 0) \
15926 + if (!tlb->fullmm && !tlb->need_flush_all) \
15927 flush_tlb_mm_range(tlb->mm, tlb->start, tlb->end, 0UL); \
15928 else \
15929 flush_tlb_mm_range(tlb->mm, 0UL, TLB_FLUSH_ALL, 0UL); \
15930 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15931 index 1709801..0a60f2f 100644
15932 --- a/arch/x86/include/asm/uaccess.h
15933 +++ b/arch/x86/include/asm/uaccess.h
15934 @@ -7,6 +7,7 @@
15935 #include <linux/compiler.h>
15936 #include <linux/thread_info.h>
15937 #include <linux/string.h>
15938 +#include <linux/sched.h>
15939 #include <asm/asm.h>
15940 #include <asm/page.h>
15941 #include <asm/smap.h>
15942 @@ -29,7 +30,12 @@
15943
15944 #define get_ds() (KERNEL_DS)
15945 #define get_fs() (current_thread_info()->addr_limit)
15946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15947 +void __set_fs(mm_segment_t x);
15948 +void set_fs(mm_segment_t x);
15949 +#else
15950 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15951 +#endif
15952
15953 #define segment_eq(a, b) ((a).seg == (b).seg)
15954
15955 @@ -77,8 +83,33 @@
15956 * checks that the pointer is in the user space range - after calling
15957 * this function, memory access functions may still return -EFAULT.
15958 */
15959 -#define access_ok(type, addr, size) \
15960 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15961 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15962 +#define access_ok(type, addr, size) \
15963 +({ \
15964 + long __size = size; \
15965 + unsigned long __addr = (unsigned long)addr; \
15966 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15967 + unsigned long __end_ao = __addr + __size - 1; \
15968 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15969 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15970 + while(__addr_ao <= __end_ao) { \
15971 + char __c_ao; \
15972 + __addr_ao += PAGE_SIZE; \
15973 + if (__size > PAGE_SIZE) \
15974 + cond_resched(); \
15975 + if (__get_user(__c_ao, (char __user *)__addr)) \
15976 + break; \
15977 + if (type != VERIFY_WRITE) { \
15978 + __addr = __addr_ao; \
15979 + continue; \
15980 + } \
15981 + if (__put_user(__c_ao, (char __user *)__addr)) \
15982 + break; \
15983 + __addr = __addr_ao; \
15984 + } \
15985 + } \
15986 + __ret_ao; \
15987 +})
15988
15989 /*
15990 * The exception table consists of pairs of addresses relative to the
15991 @@ -189,13 +220,21 @@ extern int __get_user_bad(void);
15992 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15993 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15994
15995 -
15996 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15997 +#define __copyuser_seg "gs;"
15998 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15999 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16000 +#else
16001 +#define __copyuser_seg
16002 +#define __COPYUSER_SET_ES
16003 +#define __COPYUSER_RESTORE_ES
16004 +#endif
16005
16006 #ifdef CONFIG_X86_32
16007 #define __put_user_asm_u64(x, addr, err, errret) \
16008 asm volatile(ASM_STAC "\n" \
16009 - "1: movl %%eax,0(%2)\n" \
16010 - "2: movl %%edx,4(%2)\n" \
16011 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16012 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16013 "3: " ASM_CLAC "\n" \
16014 ".section .fixup,\"ax\"\n" \
16015 "4: movl %3,%0\n" \
16016 @@ -208,8 +247,8 @@ extern int __get_user_bad(void);
16017
16018 #define __put_user_asm_ex_u64(x, addr) \
16019 asm volatile(ASM_STAC "\n" \
16020 - "1: movl %%eax,0(%1)\n" \
16021 - "2: movl %%edx,4(%1)\n" \
16022 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
16023 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
16024 "3: " ASM_CLAC "\n" \
16025 _ASM_EXTABLE_EX(1b, 2b) \
16026 _ASM_EXTABLE_EX(2b, 3b) \
16027 @@ -259,7 +298,7 @@ extern void __put_user_8(void);
16028 __typeof__(*(ptr)) __pu_val; \
16029 __chk_user_ptr(ptr); \
16030 might_fault(); \
16031 - __pu_val = x; \
16032 + __pu_val = (x); \
16033 switch (sizeof(*(ptr))) { \
16034 case 1: \
16035 __put_user_x(1, __pu_val, ptr, __ret_pu); \
16036 @@ -358,7 +397,7 @@ do { \
16037
16038 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16039 asm volatile(ASM_STAC "\n" \
16040 - "1: mov"itype" %2,%"rtype"1\n" \
16041 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
16042 "2: " ASM_CLAC "\n" \
16043 ".section .fixup,\"ax\"\n" \
16044 "3: mov %3,%0\n" \
16045 @@ -366,7 +405,7 @@ do { \
16046 " jmp 2b\n" \
16047 ".previous\n" \
16048 _ASM_EXTABLE(1b, 3b) \
16049 - : "=r" (err), ltype(x) \
16050 + : "=r" (err), ltype (x) \
16051 : "m" (__m(addr)), "i" (errret), "0" (err))
16052
16053 #define __get_user_size_ex(x, ptr, size) \
16054 @@ -391,7 +430,7 @@ do { \
16055 } while (0)
16056
16057 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
16058 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
16059 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
16060 "2:\n" \
16061 _ASM_EXTABLE_EX(1b, 2b) \
16062 : ltype(x) : "m" (__m(addr)))
16063 @@ -408,13 +447,24 @@ do { \
16064 int __gu_err; \
16065 unsigned long __gu_val; \
16066 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
16067 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
16068 + (x) = (__typeof__(*(ptr)))__gu_val; \
16069 __gu_err; \
16070 })
16071
16072 /* FIXME: this hack is definitely wrong -AK */
16073 struct __large_struct { unsigned long buf[100]; };
16074 -#define __m(x) (*(struct __large_struct __user *)(x))
16075 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16076 +#define ____m(x) \
16077 +({ \
16078 + unsigned long ____x = (unsigned long)(x); \
16079 + if (____x < PAX_USER_SHADOW_BASE) \
16080 + ____x += PAX_USER_SHADOW_BASE; \
16081 + (void __user *)____x; \
16082 +})
16083 +#else
16084 +#define ____m(x) (x)
16085 +#endif
16086 +#define __m(x) (*(struct __large_struct __user *)____m(x))
16087
16088 /*
16089 * Tell gcc we read from memory instead of writing: this is because
16090 @@ -423,7 +473,7 @@ struct __large_struct { unsigned long buf[100]; };
16091 */
16092 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
16093 asm volatile(ASM_STAC "\n" \
16094 - "1: mov"itype" %"rtype"1,%2\n" \
16095 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
16096 "2: " ASM_CLAC "\n" \
16097 ".section .fixup,\"ax\"\n" \
16098 "3: mov %3,%0\n" \
16099 @@ -431,10 +481,10 @@ struct __large_struct { unsigned long buf[100]; };
16100 ".previous\n" \
16101 _ASM_EXTABLE(1b, 3b) \
16102 : "=r"(err) \
16103 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
16104 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
16105
16106 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
16107 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
16108 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
16109 "2:\n" \
16110 _ASM_EXTABLE_EX(1b, 2b) \
16111 : : ltype(x), "m" (__m(addr)))
16112 @@ -473,8 +523,12 @@ struct __large_struct { unsigned long buf[100]; };
16113 * On error, the variable @x is set to zero.
16114 */
16115
16116 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16117 +#define __get_user(x, ptr) get_user((x), (ptr))
16118 +#else
16119 #define __get_user(x, ptr) \
16120 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
16121 +#endif
16122
16123 /**
16124 * __put_user: - Write a simple value into user space, with less checking.
16125 @@ -496,8 +550,12 @@ struct __large_struct { unsigned long buf[100]; };
16126 * Returns zero on success, or -EFAULT on error.
16127 */
16128
16129 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16130 +#define __put_user(x, ptr) put_user((x), (ptr))
16131 +#else
16132 #define __put_user(x, ptr) \
16133 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
16134 +#endif
16135
16136 #define __get_user_unaligned __get_user
16137 #define __put_user_unaligned __put_user
16138 @@ -515,7 +573,7 @@ struct __large_struct { unsigned long buf[100]; };
16139 #define get_user_ex(x, ptr) do { \
16140 unsigned long __gue_val; \
16141 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
16142 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
16143 + (x) = (__typeof__(*(ptr)))__gue_val; \
16144 } while (0)
16145
16146 #define put_user_try uaccess_try
16147 @@ -532,8 +590,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
16148 extern __must_check long strlen_user(const char __user *str);
16149 extern __must_check long strnlen_user(const char __user *str, long n);
16150
16151 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
16152 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
16153 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16154 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
16155
16156 /*
16157 * movsl can be slow when source and dest are not both 8-byte aligned
16158 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
16159 index 7f760a9..04b1c65 100644
16160 --- a/arch/x86/include/asm/uaccess_32.h
16161 +++ b/arch/x86/include/asm/uaccess_32.h
16162 @@ -11,15 +11,15 @@
16163 #include <asm/page.h>
16164
16165 unsigned long __must_check __copy_to_user_ll
16166 - (void __user *to, const void *from, unsigned long n);
16167 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
16168 unsigned long __must_check __copy_from_user_ll
16169 - (void *to, const void __user *from, unsigned long n);
16170 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16171 unsigned long __must_check __copy_from_user_ll_nozero
16172 - (void *to, const void __user *from, unsigned long n);
16173 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16174 unsigned long __must_check __copy_from_user_ll_nocache
16175 - (void *to, const void __user *from, unsigned long n);
16176 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16177 unsigned long __must_check __copy_from_user_ll_nocache_nozero
16178 - (void *to, const void __user *from, unsigned long n);
16179 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
16180
16181 /**
16182 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
16183 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
16184 static __always_inline unsigned long __must_check
16185 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
16186 {
16187 + if ((long)n < 0)
16188 + return n;
16189 +
16190 + check_object_size(from, n, true);
16191 +
16192 if (__builtin_constant_p(n)) {
16193 unsigned long ret;
16194
16195 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
16196 __copy_to_user(void __user *to, const void *from, unsigned long n)
16197 {
16198 might_fault();
16199 +
16200 return __copy_to_user_inatomic(to, from, n);
16201 }
16202
16203 static __always_inline unsigned long
16204 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
16205 {
16206 + if ((long)n < 0)
16207 + return n;
16208 +
16209 /* Avoid zeroing the tail if the copy fails..
16210 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
16211 * but as the zeroing behaviour is only significant when n is not
16212 @@ -137,6 +146,12 @@ static __always_inline unsigned long
16213 __copy_from_user(void *to, const void __user *from, unsigned long n)
16214 {
16215 might_fault();
16216 +
16217 + if ((long)n < 0)
16218 + return n;
16219 +
16220 + check_object_size(to, n, false);
16221 +
16222 if (__builtin_constant_p(n)) {
16223 unsigned long ret;
16224
16225 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
16226 const void __user *from, unsigned long n)
16227 {
16228 might_fault();
16229 +
16230 + if ((long)n < 0)
16231 + return n;
16232 +
16233 if (__builtin_constant_p(n)) {
16234 unsigned long ret;
16235
16236 @@ -181,15 +200,19 @@ static __always_inline unsigned long
16237 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
16238 unsigned long n)
16239 {
16240 - return __copy_from_user_ll_nocache_nozero(to, from, n);
16241 + if ((long)n < 0)
16242 + return n;
16243 +
16244 + return __copy_from_user_ll_nocache_nozero(to, from, n);
16245 }
16246
16247 -unsigned long __must_check copy_to_user(void __user *to,
16248 - const void *from, unsigned long n);
16249 -unsigned long __must_check _copy_from_user(void *to,
16250 - const void __user *from,
16251 - unsigned long n);
16252 -
16253 +extern void copy_to_user_overflow(void)
16254 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16255 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16256 +#else
16257 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16258 +#endif
16259 +;
16260
16261 extern void copy_from_user_overflow(void)
16262 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16263 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
16264 #endif
16265 ;
16266
16267 -static inline unsigned long __must_check copy_from_user(void *to,
16268 - const void __user *from,
16269 - unsigned long n)
16270 +/**
16271 + * copy_to_user: - Copy a block of data into user space.
16272 + * @to: Destination address, in user space.
16273 + * @from: Source address, in kernel space.
16274 + * @n: Number of bytes to copy.
16275 + *
16276 + * Context: User context only. This function may sleep.
16277 + *
16278 + * Copy data from kernel space to user space.
16279 + *
16280 + * Returns number of bytes that could not be copied.
16281 + * On success, this will be zero.
16282 + */
16283 +static inline unsigned long __must_check
16284 +copy_to_user(void __user *to, const void *from, unsigned long n)
16285 {
16286 - int sz = __compiletime_object_size(to);
16287 + size_t sz = __compiletime_object_size(from);
16288
16289 - if (likely(sz == -1 || sz >= n))
16290 - n = _copy_from_user(to, from, n);
16291 - else
16292 + if (unlikely(sz != (size_t)-1 && sz < n))
16293 + copy_to_user_overflow();
16294 + else if (access_ok(VERIFY_WRITE, to, n))
16295 + n = __copy_to_user(to, from, n);
16296 + return n;
16297 +}
16298 +
16299 +/**
16300 + * copy_from_user: - Copy a block of data from user space.
16301 + * @to: Destination address, in kernel space.
16302 + * @from: Source address, in user space.
16303 + * @n: Number of bytes to copy.
16304 + *
16305 + * Context: User context only. This function may sleep.
16306 + *
16307 + * Copy data from user space to kernel space.
16308 + *
16309 + * Returns number of bytes that could not be copied.
16310 + * On success, this will be zero.
16311 + *
16312 + * If some data could not be copied, this function will pad the copied
16313 + * data to the requested size using zero bytes.
16314 + */
16315 +static inline unsigned long __must_check
16316 +copy_from_user(void *to, const void __user *from, unsigned long n)
16317 +{
16318 + size_t sz = __compiletime_object_size(to);
16319 +
16320 + check_object_size(to, n, false);
16321 +
16322 + if (unlikely(sz != (size_t)-1 && sz < n))
16323 copy_from_user_overflow();
16324 -
16325 + else if (access_ok(VERIFY_READ, from, n))
16326 + n = __copy_from_user(to, from, n);
16327 + else if ((long)n > 0)
16328 + memset(to, 0, n);
16329 return n;
16330 }
16331
16332 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16333 index 142810c..1f2a0a7 100644
16334 --- a/arch/x86/include/asm/uaccess_64.h
16335 +++ b/arch/x86/include/asm/uaccess_64.h
16336 @@ -10,6 +10,9 @@
16337 #include <asm/alternative.h>
16338 #include <asm/cpufeature.h>
16339 #include <asm/page.h>
16340 +#include <asm/pgtable.h>
16341 +
16342 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16343
16344 /*
16345 * Copy To/From Userspace
16346 @@ -17,13 +20,13 @@
16347
16348 /* Handles exceptions in both to and from, but doesn't do access_ok */
16349 __must_check unsigned long
16350 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16351 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16352 __must_check unsigned long
16353 -copy_user_generic_string(void *to, const void *from, unsigned len);
16354 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16355 __must_check unsigned long
16356 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16357 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16358
16359 -static __always_inline __must_check unsigned long
16360 +static __always_inline __must_check __size_overflow(3) unsigned long
16361 copy_user_generic(void *to, const void *from, unsigned len)
16362 {
16363 unsigned ret;
16364 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16365 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16366 "=d" (len)),
16367 "1" (to), "2" (from), "3" (len)
16368 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16369 + : "memory", "rcx", "r8", "r9", "r11");
16370 return ret;
16371 }
16372
16373 +static __always_inline __must_check unsigned long
16374 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16375 +static __always_inline __must_check unsigned long
16376 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16377 __must_check unsigned long
16378 -_copy_to_user(void __user *to, const void *from, unsigned len);
16379 -__must_check unsigned long
16380 -_copy_from_user(void *to, const void __user *from, unsigned len);
16381 -__must_check unsigned long
16382 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16383 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16384 +
16385 +extern void copy_to_user_overflow(void)
16386 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16387 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16388 +#else
16389 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16390 +#endif
16391 +;
16392 +
16393 +extern void copy_from_user_overflow(void)
16394 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16395 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16396 +#else
16397 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16398 +#endif
16399 +;
16400
16401 static inline unsigned long __must_check copy_from_user(void *to,
16402 const void __user *from,
16403 unsigned long n)
16404 {
16405 - int sz = __compiletime_object_size(to);
16406 -
16407 might_fault();
16408 - if (likely(sz == -1 || sz >= n))
16409 - n = _copy_from_user(to, from, n);
16410 -#ifdef CONFIG_DEBUG_VM
16411 - else
16412 - WARN(1, "Buffer overflow detected!\n");
16413 -#endif
16414 +
16415 + check_object_size(to, n, false);
16416 +
16417 + if (access_ok(VERIFY_READ, from, n))
16418 + n = __copy_from_user(to, from, n);
16419 + else if (n < INT_MAX)
16420 + memset(to, 0, n);
16421 return n;
16422 }
16423
16424 static __always_inline __must_check
16425 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16426 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16427 {
16428 might_fault();
16429
16430 - return _copy_to_user(dst, src, size);
16431 + if (access_ok(VERIFY_WRITE, dst, size))
16432 + size = __copy_to_user(dst, src, size);
16433 + return size;
16434 }
16435
16436 static __always_inline __must_check
16437 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16438 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16439 {
16440 - int ret = 0;
16441 + size_t sz = __compiletime_object_size(dst);
16442 + unsigned ret = 0;
16443
16444 might_fault();
16445 +
16446 + if (size > INT_MAX)
16447 + return size;
16448 +
16449 + check_object_size(dst, size, false);
16450 +
16451 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16452 + if (!__access_ok(VERIFY_READ, src, size))
16453 + return size;
16454 +#endif
16455 +
16456 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16457 + copy_from_user_overflow();
16458 + return size;
16459 + }
16460 +
16461 if (!__builtin_constant_p(size))
16462 - return copy_user_generic(dst, (__force void *)src, size);
16463 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16464 switch (size) {
16465 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16466 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16467 ret, "b", "b", "=q", 1);
16468 return ret;
16469 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16470 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16471 ret, "w", "w", "=r", 2);
16472 return ret;
16473 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16474 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16475 ret, "l", "k", "=r", 4);
16476 return ret;
16477 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16478 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16479 ret, "q", "", "=r", 8);
16480 return ret;
16481 case 10:
16482 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16483 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16484 ret, "q", "", "=r", 10);
16485 if (unlikely(ret))
16486 return ret;
16487 __get_user_asm(*(u16 *)(8 + (char *)dst),
16488 - (u16 __user *)(8 + (char __user *)src),
16489 + (const u16 __user *)(8 + (const char __user *)src),
16490 ret, "w", "w", "=r", 2);
16491 return ret;
16492 case 16:
16493 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16494 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16495 ret, "q", "", "=r", 16);
16496 if (unlikely(ret))
16497 return ret;
16498 __get_user_asm(*(u64 *)(8 + (char *)dst),
16499 - (u64 __user *)(8 + (char __user *)src),
16500 + (const u64 __user *)(8 + (const char __user *)src),
16501 ret, "q", "", "=r", 8);
16502 return ret;
16503 default:
16504 - return copy_user_generic(dst, (__force void *)src, size);
16505 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16506 }
16507 }
16508
16509 static __always_inline __must_check
16510 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16511 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16512 {
16513 - int ret = 0;
16514 + size_t sz = __compiletime_object_size(src);
16515 + unsigned ret = 0;
16516
16517 might_fault();
16518 +
16519 + if (size > INT_MAX)
16520 + return size;
16521 +
16522 + check_object_size(src, size, true);
16523 +
16524 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16525 + if (!__access_ok(VERIFY_WRITE, dst, size))
16526 + return size;
16527 +#endif
16528 +
16529 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16530 + copy_to_user_overflow();
16531 + return size;
16532 + }
16533 +
16534 if (!__builtin_constant_p(size))
16535 - return copy_user_generic((__force void *)dst, src, size);
16536 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16537 switch (size) {
16538 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16539 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16540 ret, "b", "b", "iq", 1);
16541 return ret;
16542 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16543 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16544 ret, "w", "w", "ir", 2);
16545 return ret;
16546 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16547 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16548 ret, "l", "k", "ir", 4);
16549 return ret;
16550 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16551 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16552 ret, "q", "", "er", 8);
16553 return ret;
16554 case 10:
16555 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16556 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16557 ret, "q", "", "er", 10);
16558 if (unlikely(ret))
16559 return ret;
16560 asm("":::"memory");
16561 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16562 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16563 ret, "w", "w", "ir", 2);
16564 return ret;
16565 case 16:
16566 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16567 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16568 ret, "q", "", "er", 16);
16569 if (unlikely(ret))
16570 return ret;
16571 asm("":::"memory");
16572 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16573 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16574 ret, "q", "", "er", 8);
16575 return ret;
16576 default:
16577 - return copy_user_generic((__force void *)dst, src, size);
16578 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16579 }
16580 }
16581
16582 static __always_inline __must_check
16583 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16584 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16585 {
16586 - int ret = 0;
16587 + unsigned ret = 0;
16588
16589 might_fault();
16590 +
16591 + if (size > INT_MAX)
16592 + return size;
16593 +
16594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16595 + if (!__access_ok(VERIFY_READ, src, size))
16596 + return size;
16597 + if (!__access_ok(VERIFY_WRITE, dst, size))
16598 + return size;
16599 +#endif
16600 +
16601 if (!__builtin_constant_p(size))
16602 - return copy_user_generic((__force void *)dst,
16603 - (__force void *)src, size);
16604 + return copy_user_generic((__force_kernel void *)____m(dst),
16605 + (__force_kernel const void *)____m(src), size);
16606 switch (size) {
16607 case 1: {
16608 u8 tmp;
16609 - __get_user_asm(tmp, (u8 __user *)src,
16610 + __get_user_asm(tmp, (const u8 __user *)src,
16611 ret, "b", "b", "=q", 1);
16612 if (likely(!ret))
16613 __put_user_asm(tmp, (u8 __user *)dst,
16614 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16615 }
16616 case 2: {
16617 u16 tmp;
16618 - __get_user_asm(tmp, (u16 __user *)src,
16619 + __get_user_asm(tmp, (const u16 __user *)src,
16620 ret, "w", "w", "=r", 2);
16621 if (likely(!ret))
16622 __put_user_asm(tmp, (u16 __user *)dst,
16623 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16624
16625 case 4: {
16626 u32 tmp;
16627 - __get_user_asm(tmp, (u32 __user *)src,
16628 + __get_user_asm(tmp, (const u32 __user *)src,
16629 ret, "l", "k", "=r", 4);
16630 if (likely(!ret))
16631 __put_user_asm(tmp, (u32 __user *)dst,
16632 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16633 }
16634 case 8: {
16635 u64 tmp;
16636 - __get_user_asm(tmp, (u64 __user *)src,
16637 + __get_user_asm(tmp, (const u64 __user *)src,
16638 ret, "q", "", "=r", 8);
16639 if (likely(!ret))
16640 __put_user_asm(tmp, (u64 __user *)dst,
16641 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16642 return ret;
16643 }
16644 default:
16645 - return copy_user_generic((__force void *)dst,
16646 - (__force void *)src, size);
16647 + return copy_user_generic((__force_kernel void *)____m(dst),
16648 + (__force_kernel const void *)____m(src), size);
16649 }
16650 }
16651
16652 static __must_check __always_inline int
16653 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16654 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16655 {
16656 - return copy_user_generic(dst, (__force const void *)src, size);
16657 + if (size > INT_MAX)
16658 + return size;
16659 +
16660 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16661 + if (!__access_ok(VERIFY_READ, src, size))
16662 + return size;
16663 +#endif
16664 +
16665 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16666 }
16667
16668 -static __must_check __always_inline int
16669 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16670 +static __must_check __always_inline unsigned long
16671 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16672 {
16673 - return copy_user_generic((__force void *)dst, src, size);
16674 + if (size > INT_MAX)
16675 + return size;
16676 +
16677 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16678 + if (!__access_ok(VERIFY_WRITE, dst, size))
16679 + return size;
16680 +#endif
16681 +
16682 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16683 }
16684
16685 -extern long __copy_user_nocache(void *dst, const void __user *src,
16686 - unsigned size, int zerorest);
16687 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16688 + unsigned long size, int zerorest) __size_overflow(3);
16689
16690 -static inline int
16691 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16692 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16693 {
16694 might_sleep();
16695 +
16696 + if (size > INT_MAX)
16697 + return size;
16698 +
16699 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16700 + if (!__access_ok(VERIFY_READ, src, size))
16701 + return size;
16702 +#endif
16703 +
16704 return __copy_user_nocache(dst, src, size, 1);
16705 }
16706
16707 -static inline int
16708 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16709 - unsigned size)
16710 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16711 + unsigned long size)
16712 {
16713 + if (size > INT_MAX)
16714 + return size;
16715 +
16716 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16717 + if (!__access_ok(VERIFY_READ, src, size))
16718 + return size;
16719 +#endif
16720 +
16721 return __copy_user_nocache(dst, src, size, 0);
16722 }
16723
16724 -unsigned long
16725 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16726 +extern unsigned long
16727 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16728
16729 #endif /* _ASM_X86_UACCESS_64_H */
16730 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16731 index 5b238981..77fdd78 100644
16732 --- a/arch/x86/include/asm/word-at-a-time.h
16733 +++ b/arch/x86/include/asm/word-at-a-time.h
16734 @@ -11,7 +11,7 @@
16735 * and shift, for example.
16736 */
16737 struct word_at_a_time {
16738 - const unsigned long one_bits, high_bits;
16739 + unsigned long one_bits, high_bits;
16740 };
16741
16742 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16743 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16744 index 5769349..a3d3e2a 100644
16745 --- a/arch/x86/include/asm/x86_init.h
16746 +++ b/arch/x86/include/asm/x86_init.h
16747 @@ -141,7 +141,7 @@ struct x86_init_ops {
16748 struct x86_init_timers timers;
16749 struct x86_init_iommu iommu;
16750 struct x86_init_pci pci;
16751 -};
16752 +} __no_const;
16753
16754 /**
16755 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16756 @@ -152,7 +152,7 @@ struct x86_cpuinit_ops {
16757 void (*setup_percpu_clockev)(void);
16758 void (*early_percpu_clock_init)(void);
16759 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16760 -};
16761 +} __no_const;
16762
16763 /**
16764 * struct x86_platform_ops - platform specific runtime functions
16765 @@ -178,7 +178,7 @@ struct x86_platform_ops {
16766 void (*save_sched_clock_state)(void);
16767 void (*restore_sched_clock_state)(void);
16768 void (*apic_post_init)(void);
16769 -};
16770 +} __no_const;
16771
16772 struct pci_dev;
16773
16774 @@ -187,14 +187,14 @@ struct x86_msi_ops {
16775 void (*teardown_msi_irq)(unsigned int irq);
16776 void (*teardown_msi_irqs)(struct pci_dev *dev);
16777 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16778 -};
16779 +} __no_const;
16780
16781 struct x86_io_apic_ops {
16782 void (*init) (void);
16783 unsigned int (*read) (unsigned int apic, unsigned int reg);
16784 void (*write) (unsigned int apic, unsigned int reg, unsigned int value);
16785 void (*modify)(unsigned int apic, unsigned int reg, unsigned int value);
16786 -};
16787 +} __no_const;
16788
16789 extern struct x86_init_ops x86_init;
16790 extern struct x86_cpuinit_ops x86_cpuinit;
16791 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16792 index 0415cda..b43d877 100644
16793 --- a/arch/x86/include/asm/xsave.h
16794 +++ b/arch/x86/include/asm/xsave.h
16795 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16796 return -EFAULT;
16797
16798 __asm__ __volatile__(ASM_STAC "\n"
16799 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16800 + "1:"
16801 + __copyuser_seg
16802 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16803 "2: " ASM_CLAC "\n"
16804 ".section .fixup,\"ax\"\n"
16805 "3: movl $-1,%[err]\n"
16806 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16807 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16808 {
16809 int err;
16810 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16811 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16812 u32 lmask = mask;
16813 u32 hmask = mask >> 32;
16814
16815 __asm__ __volatile__(ASM_STAC "\n"
16816 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16817 + "1:"
16818 + __copyuser_seg
16819 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16820 "2: " ASM_CLAC "\n"
16821 ".section .fixup,\"ax\"\n"
16822 "3: movl $-1,%[err]\n"
16823 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16824 index bbae024..e1528f9 100644
16825 --- a/arch/x86/include/uapi/asm/e820.h
16826 +++ b/arch/x86/include/uapi/asm/e820.h
16827 @@ -63,7 +63,7 @@ struct e820map {
16828 #define ISA_START_ADDRESS 0xa0000
16829 #define ISA_END_ADDRESS 0x100000
16830
16831 -#define BIOS_BEGIN 0x000a0000
16832 +#define BIOS_BEGIN 0x000c0000
16833 #define BIOS_END 0x00100000
16834
16835 #define BIOS_ROM_BASE 0xffe00000
16836 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16837 index 34e923a..0c6bb6e 100644
16838 --- a/arch/x86/kernel/Makefile
16839 +++ b/arch/x86/kernel/Makefile
16840 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16841 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16842 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16843 obj-y += probe_roms.o
16844 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16845 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16846 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16847 obj-y += syscall_$(BITS).o
16848 obj-$(CONFIG_X86_64) += vsyscall_64.o
16849 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16850 index bacf4b0..4ede72e 100644
16851 --- a/arch/x86/kernel/acpi/boot.c
16852 +++ b/arch/x86/kernel/acpi/boot.c
16853 @@ -1358,7 +1358,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16854 * If your system is blacklisted here, but you find that acpi=force
16855 * works for you, please contact linux-acpi@vger.kernel.org
16856 */
16857 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16858 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16859 /*
16860 * Boxes that need ACPI disabled
16861 */
16862 @@ -1433,7 +1433,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16863 };
16864
16865 /* second table for DMI checks that should run after early-quirks */
16866 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16867 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16868 /*
16869 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16870 * which includes some code which overrides all temperature
16871 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16872 index d5e0d71..6533e08 100644
16873 --- a/arch/x86/kernel/acpi/sleep.c
16874 +++ b/arch/x86/kernel/acpi/sleep.c
16875 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16876 #else /* CONFIG_64BIT */
16877 #ifdef CONFIG_SMP
16878 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16879 +
16880 + pax_open_kernel();
16881 early_gdt_descr.address =
16882 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16883 + pax_close_kernel();
16884 +
16885 initial_gs = per_cpu_offset(smp_processor_id());
16886 #endif
16887 initial_code = (unsigned long)wakeup_long64;
16888 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16889 index 13ab720..95d5442 100644
16890 --- a/arch/x86/kernel/acpi/wakeup_32.S
16891 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16892 @@ -30,13 +30,11 @@ wakeup_pmode_return:
16893 # and restore the stack ... but you need gdt for this to work
16894 movl saved_context_esp, %esp
16895
16896 - movl %cs:saved_magic, %eax
16897 - cmpl $0x12345678, %eax
16898 + cmpl $0x12345678, saved_magic
16899 jne bogus_magic
16900
16901 # jump to place where we left off
16902 - movl saved_eip, %eax
16903 - jmp *%eax
16904 + jmp *(saved_eip)
16905
16906 bogus_magic:
16907 jmp bogus_magic
16908 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16909 index ef5ccca..bd83949 100644
16910 --- a/arch/x86/kernel/alternative.c
16911 +++ b/arch/x86/kernel/alternative.c
16912 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16913 */
16914 for (a = start; a < end; a++) {
16915 instr = (u8 *)&a->instr_offset + a->instr_offset;
16916 +
16917 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16918 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16919 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16920 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16921 +#endif
16922 +
16923 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16924 BUG_ON(a->replacementlen > a->instrlen);
16925 BUG_ON(a->instrlen > sizeof(insnbuf));
16926 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16927 for (poff = start; poff < end; poff++) {
16928 u8 *ptr = (u8 *)poff + *poff;
16929
16930 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16931 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16932 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16933 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16934 +#endif
16935 +
16936 if (!*poff || ptr < text || ptr >= text_end)
16937 continue;
16938 /* turn DS segment override prefix into lock prefix */
16939 - if (*ptr == 0x3e)
16940 + if (*ktla_ktva(ptr) == 0x3e)
16941 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16942 }
16943 mutex_unlock(&text_mutex);
16944 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16945 for (poff = start; poff < end; poff++) {
16946 u8 *ptr = (u8 *)poff + *poff;
16947
16948 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16949 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16950 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16951 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16952 +#endif
16953 +
16954 if (!*poff || ptr < text || ptr >= text_end)
16955 continue;
16956 /* turn lock prefix into DS segment override prefix */
16957 - if (*ptr == 0xf0)
16958 + if (*ktla_ktva(ptr) == 0xf0)
16959 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16960 }
16961 mutex_unlock(&text_mutex);
16962 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16963
16964 BUG_ON(p->len > MAX_PATCH_LEN);
16965 /* prep the buffer with the original instructions */
16966 - memcpy(insnbuf, p->instr, p->len);
16967 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16968 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16969 (unsigned long)p->instr, p->len);
16970
16971 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16972 if (!uniproc_patched || num_possible_cpus() == 1)
16973 free_init_pages("SMP alternatives",
16974 (unsigned long)__smp_locks,
16975 - (unsigned long)__smp_locks_end);
16976 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16977 #endif
16978
16979 apply_paravirt(__parainstructions, __parainstructions_end);
16980 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16981 * instructions. And on the local CPU you need to be protected again NMI or MCE
16982 * handlers seeing an inconsistent instruction while you patch.
16983 */
16984 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16985 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16986 size_t len)
16987 {
16988 unsigned long flags;
16989 local_irq_save(flags);
16990 - memcpy(addr, opcode, len);
16991 +
16992 + pax_open_kernel();
16993 + memcpy(ktla_ktva(addr), opcode, len);
16994 sync_core();
16995 + pax_close_kernel();
16996 +
16997 local_irq_restore(flags);
16998 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16999 that causes hangs on some VIA CPUs. */
17000 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
17001 */
17002 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
17003 {
17004 - unsigned long flags;
17005 - char *vaddr;
17006 + unsigned char *vaddr = ktla_ktva(addr);
17007 struct page *pages[2];
17008 - int i;
17009 + size_t i;
17010
17011 if (!core_kernel_text((unsigned long)addr)) {
17012 - pages[0] = vmalloc_to_page(addr);
17013 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
17014 + pages[0] = vmalloc_to_page(vaddr);
17015 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
17016 } else {
17017 - pages[0] = virt_to_page(addr);
17018 + pages[0] = virt_to_page(vaddr);
17019 WARN_ON(!PageReserved(pages[0]));
17020 - pages[1] = virt_to_page(addr + PAGE_SIZE);
17021 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
17022 }
17023 BUG_ON(!pages[0]);
17024 - local_irq_save(flags);
17025 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
17026 - if (pages[1])
17027 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
17028 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
17029 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
17030 - clear_fixmap(FIX_TEXT_POKE0);
17031 - if (pages[1])
17032 - clear_fixmap(FIX_TEXT_POKE1);
17033 - local_flush_tlb();
17034 - sync_core();
17035 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
17036 - that causes hangs on some VIA CPUs. */
17037 + text_poke_early(addr, opcode, len);
17038 for (i = 0; i < len; i++)
17039 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
17040 - local_irq_restore(flags);
17041 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
17042 return addr;
17043 }
17044
17045 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
17046 index cbf5121..812b537 100644
17047 --- a/arch/x86/kernel/apic/apic.c
17048 +++ b/arch/x86/kernel/apic/apic.c
17049 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
17050 /*
17051 * Debug level, exported for io_apic.c
17052 */
17053 -unsigned int apic_verbosity;
17054 +int apic_verbosity;
17055
17056 int pic_mode;
17057
17058 @@ -1956,7 +1956,7 @@ void smp_error_interrupt(struct pt_regs *regs)
17059 apic_write(APIC_ESR, 0);
17060 v1 = apic_read(APIC_ESR);
17061 ack_APIC_irq();
17062 - atomic_inc(&irq_err_count);
17063 + atomic_inc_unchecked(&irq_err_count);
17064
17065 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
17066 smp_processor_id(), v0 , v1);
17067 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
17068 index 00c77cf..2dc6a2d 100644
17069 --- a/arch/x86/kernel/apic/apic_flat_64.c
17070 +++ b/arch/x86/kernel/apic/apic_flat_64.c
17071 @@ -157,7 +157,7 @@ static int flat_probe(void)
17072 return 1;
17073 }
17074
17075 -static struct apic apic_flat = {
17076 +static struct apic apic_flat __read_only = {
17077 .name = "flat",
17078 .probe = flat_probe,
17079 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
17080 @@ -271,7 +271,7 @@ static int physflat_probe(void)
17081 return 0;
17082 }
17083
17084 -static struct apic apic_physflat = {
17085 +static struct apic apic_physflat __read_only = {
17086
17087 .name = "physical flat",
17088 .probe = physflat_probe,
17089 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
17090 index e145f28..2752888 100644
17091 --- a/arch/x86/kernel/apic/apic_noop.c
17092 +++ b/arch/x86/kernel/apic/apic_noop.c
17093 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
17094 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
17095 }
17096
17097 -struct apic apic_noop = {
17098 +struct apic apic_noop __read_only = {
17099 .name = "noop",
17100 .probe = noop_probe,
17101 .acpi_madt_oem_check = NULL,
17102 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
17103 index d50e364..543bee3 100644
17104 --- a/arch/x86/kernel/apic/bigsmp_32.c
17105 +++ b/arch/x86/kernel/apic/bigsmp_32.c
17106 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
17107 return dmi_bigsmp;
17108 }
17109
17110 -static struct apic apic_bigsmp = {
17111 +static struct apic apic_bigsmp __read_only = {
17112
17113 .name = "bigsmp",
17114 .probe = probe_bigsmp,
17115 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
17116 index 0874799..a7a7892 100644
17117 --- a/arch/x86/kernel/apic/es7000_32.c
17118 +++ b/arch/x86/kernel/apic/es7000_32.c
17119 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
17120 return ret && es7000_apic_is_cluster();
17121 }
17122
17123 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
17124 -static struct apic __refdata apic_es7000_cluster = {
17125 +static struct apic apic_es7000_cluster __read_only = {
17126
17127 .name = "es7000",
17128 .probe = probe_es7000,
17129 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
17130 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
17131 };
17132
17133 -static struct apic __refdata apic_es7000 = {
17134 +static struct apic apic_es7000 __read_only = {
17135
17136 .name = "es7000",
17137 .probe = probe_es7000,
17138 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
17139 index b739d39..aebc14c 100644
17140 --- a/arch/x86/kernel/apic/io_apic.c
17141 +++ b/arch/x86/kernel/apic/io_apic.c
17142 @@ -1084,7 +1084,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
17143 }
17144 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
17145
17146 -void lock_vector_lock(void)
17147 +void lock_vector_lock(void) __acquires(vector_lock)
17148 {
17149 /* Used to the online set of cpus does not change
17150 * during assign_irq_vector.
17151 @@ -1092,7 +1092,7 @@ void lock_vector_lock(void)
17152 raw_spin_lock(&vector_lock);
17153 }
17154
17155 -void unlock_vector_lock(void)
17156 +void unlock_vector_lock(void) __releases(vector_lock)
17157 {
17158 raw_spin_unlock(&vector_lock);
17159 }
17160 @@ -2399,7 +2399,7 @@ static void ack_apic_edge(struct irq_data *data)
17161 ack_APIC_irq();
17162 }
17163
17164 -atomic_t irq_mis_count;
17165 +atomic_unchecked_t irq_mis_count;
17166
17167 #ifdef CONFIG_GENERIC_PENDING_IRQ
17168 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
17169 @@ -2540,7 +2540,7 @@ static void ack_apic_level(struct irq_data *data)
17170 * at the cpu.
17171 */
17172 if (!(v & (1 << (i & 0x1f)))) {
17173 - atomic_inc(&irq_mis_count);
17174 + atomic_inc_unchecked(&irq_mis_count);
17175
17176 eoi_ioapic_irq(irq, cfg);
17177 }
17178 @@ -2567,11 +2567,13 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
17179
17180 static void irq_remap_modify_chip_defaults(struct irq_chip *chip)
17181 {
17182 - chip->irq_print_chip = ir_print_prefix;
17183 - chip->irq_ack = ir_ack_apic_edge;
17184 - chip->irq_eoi = ir_ack_apic_level;
17185 + pax_open_kernel();
17186 + *(void **)&chip->irq_print_chip = ir_print_prefix;
17187 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
17188 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
17189
17190 - chip->irq_set_affinity = set_remapped_irq_affinity;
17191 + *(void **)&chip->irq_set_affinity = set_remapped_irq_affinity;
17192 + pax_close_kernel();
17193 }
17194 #endif /* CONFIG_IRQ_REMAP */
17195
17196 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
17197 index d661ee9..791fd33 100644
17198 --- a/arch/x86/kernel/apic/numaq_32.c
17199 +++ b/arch/x86/kernel/apic/numaq_32.c
17200 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
17201 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
17202 }
17203
17204 -/* Use __refdata to keep false positive warning calm. */
17205 -static struct apic __refdata apic_numaq = {
17206 +static struct apic apic_numaq __read_only = {
17207
17208 .name = "NUMAQ",
17209 .probe = probe_numaq,
17210 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
17211 index eb35ef9..f184a21 100644
17212 --- a/arch/x86/kernel/apic/probe_32.c
17213 +++ b/arch/x86/kernel/apic/probe_32.c
17214 @@ -72,7 +72,7 @@ static int probe_default(void)
17215 return 1;
17216 }
17217
17218 -static struct apic apic_default = {
17219 +static struct apic apic_default __read_only = {
17220
17221 .name = "default",
17222 .probe = probe_default,
17223 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
17224 index 77c95c0..434f8a4 100644
17225 --- a/arch/x86/kernel/apic/summit_32.c
17226 +++ b/arch/x86/kernel/apic/summit_32.c
17227 @@ -486,7 +486,7 @@ void setup_summit(void)
17228 }
17229 #endif
17230
17231 -static struct apic apic_summit = {
17232 +static struct apic apic_summit __read_only = {
17233
17234 .name = "summit",
17235 .probe = probe_summit,
17236 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
17237 index c88baa4..757aee1 100644
17238 --- a/arch/x86/kernel/apic/x2apic_cluster.c
17239 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
17240 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
17241 return notifier_from_errno(err);
17242 }
17243
17244 -static struct notifier_block __refdata x2apic_cpu_notifier = {
17245 +static struct notifier_block x2apic_cpu_notifier = {
17246 .notifier_call = update_clusterinfo,
17247 };
17248
17249 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
17250 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
17251 }
17252
17253 -static struct apic apic_x2apic_cluster = {
17254 +static struct apic apic_x2apic_cluster __read_only = {
17255
17256 .name = "cluster x2apic",
17257 .probe = x2apic_cluster_probe,
17258 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
17259 index 562a76d..a003c0f 100644
17260 --- a/arch/x86/kernel/apic/x2apic_phys.c
17261 +++ b/arch/x86/kernel/apic/x2apic_phys.c
17262 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
17263 return apic == &apic_x2apic_phys;
17264 }
17265
17266 -static struct apic apic_x2apic_phys = {
17267 +static struct apic apic_x2apic_phys __read_only = {
17268
17269 .name = "physical x2apic",
17270 .probe = x2apic_phys_probe,
17271 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
17272 index 8cfade9..b9d04fc 100644
17273 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
17274 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
17275 @@ -333,7 +333,7 @@ static int uv_probe(void)
17276 return apic == &apic_x2apic_uv_x;
17277 }
17278
17279 -static struct apic __refdata apic_x2apic_uv_x = {
17280 +static struct apic apic_x2apic_uv_x __read_only = {
17281
17282 .name = "UV large system",
17283 .probe = uv_probe,
17284 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
17285 index d65464e..1035d31 100644
17286 --- a/arch/x86/kernel/apm_32.c
17287 +++ b/arch/x86/kernel/apm_32.c
17288 @@ -412,7 +412,7 @@ static DEFINE_MUTEX(apm_mutex);
17289 * This is for buggy BIOS's that refer to (real mode) segment 0x40
17290 * even though they are called in protected mode.
17291 */
17292 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
17293 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
17294 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
17295
17296 static const char driver_version[] = "1.16ac"; /* no spaces */
17297 @@ -590,7 +590,10 @@ static long __apm_bios_call(void *_call)
17298 BUG_ON(cpu != 0);
17299 gdt = get_cpu_gdt_table(cpu);
17300 save_desc_40 = gdt[0x40 / 8];
17301 +
17302 + pax_open_kernel();
17303 gdt[0x40 / 8] = bad_bios_desc;
17304 + pax_close_kernel();
17305
17306 apm_irq_save(flags);
17307 APM_DO_SAVE_SEGS;
17308 @@ -599,7 +602,11 @@ static long __apm_bios_call(void *_call)
17309 &call->esi);
17310 APM_DO_RESTORE_SEGS;
17311 apm_irq_restore(flags);
17312 +
17313 + pax_open_kernel();
17314 gdt[0x40 / 8] = save_desc_40;
17315 + pax_close_kernel();
17316 +
17317 put_cpu();
17318
17319 return call->eax & 0xff;
17320 @@ -666,7 +673,10 @@ static long __apm_bios_call_simple(void *_call)
17321 BUG_ON(cpu != 0);
17322 gdt = get_cpu_gdt_table(cpu);
17323 save_desc_40 = gdt[0x40 / 8];
17324 +
17325 + pax_open_kernel();
17326 gdt[0x40 / 8] = bad_bios_desc;
17327 + pax_close_kernel();
17328
17329 apm_irq_save(flags);
17330 APM_DO_SAVE_SEGS;
17331 @@ -674,7 +684,11 @@ static long __apm_bios_call_simple(void *_call)
17332 &call->eax);
17333 APM_DO_RESTORE_SEGS;
17334 apm_irq_restore(flags);
17335 +
17336 + pax_open_kernel();
17337 gdt[0x40 / 8] = save_desc_40;
17338 + pax_close_kernel();
17339 +
17340 put_cpu();
17341 return error;
17342 }
17343 @@ -2345,12 +2359,15 @@ static int __init apm_init(void)
17344 * code to that CPU.
17345 */
17346 gdt = get_cpu_gdt_table(0);
17347 +
17348 + pax_open_kernel();
17349 set_desc_base(&gdt[APM_CS >> 3],
17350 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17351 set_desc_base(&gdt[APM_CS_16 >> 3],
17352 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17353 set_desc_base(&gdt[APM_DS >> 3],
17354 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17355 + pax_close_kernel();
17356
17357 proc_create("apm", 0, NULL, &apm_file_ops);
17358
17359 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17360 index 2861082..6d4718e 100644
17361 --- a/arch/x86/kernel/asm-offsets.c
17362 +++ b/arch/x86/kernel/asm-offsets.c
17363 @@ -33,6 +33,8 @@ void common(void) {
17364 OFFSET(TI_status, thread_info, status);
17365 OFFSET(TI_addr_limit, thread_info, addr_limit);
17366 OFFSET(TI_preempt_count, thread_info, preempt_count);
17367 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17368 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17369
17370 BLANK();
17371 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17372 @@ -53,8 +55,26 @@ void common(void) {
17373 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17374 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17375 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17376 +
17377 +#ifdef CONFIG_PAX_KERNEXEC
17378 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17379 #endif
17380
17381 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17382 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17383 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17384 +#ifdef CONFIG_X86_64
17385 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17386 +#endif
17387 +#endif
17388 +
17389 +#endif
17390 +
17391 + BLANK();
17392 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17393 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17394 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17395 +
17396 #ifdef CONFIG_XEN
17397 BLANK();
17398 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17399 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17400 index 1b4754f..fbb4227 100644
17401 --- a/arch/x86/kernel/asm-offsets_64.c
17402 +++ b/arch/x86/kernel/asm-offsets_64.c
17403 @@ -76,6 +76,7 @@ int main(void)
17404 BLANK();
17405 #undef ENTRY
17406
17407 + DEFINE(TSS_size, sizeof(struct tss_struct));
17408 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17409 BLANK();
17410
17411 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17412 index a0e067d..9c7db16 100644
17413 --- a/arch/x86/kernel/cpu/Makefile
17414 +++ b/arch/x86/kernel/cpu/Makefile
17415 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17416 CFLAGS_REMOVE_perf_event.o = -pg
17417 endif
17418
17419 -# Make sure load_percpu_segment has no stackprotector
17420 -nostackp := $(call cc-option, -fno-stack-protector)
17421 -CFLAGS_common.o := $(nostackp)
17422 -
17423 obj-y := intel_cacheinfo.o scattered.o topology.o
17424 obj-y += proc.o capflags.o powerflags.o common.o
17425 obj-y += vmware.o hypervisor.o mshyperv.o
17426 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17427 index 15239ff..e23e04e 100644
17428 --- a/arch/x86/kernel/cpu/amd.c
17429 +++ b/arch/x86/kernel/cpu/amd.c
17430 @@ -733,7 +733,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17431 unsigned int size)
17432 {
17433 /* AMD errata T13 (order #21922) */
17434 - if ((c->x86 == 6)) {
17435 + if (c->x86 == 6) {
17436 /* Duron Rev A0 */
17437 if (c->x86_model == 3 && c->x86_mask == 0)
17438 size = 64;
17439 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17440 index 9c3ab43..51e6366 100644
17441 --- a/arch/x86/kernel/cpu/common.c
17442 +++ b/arch/x86/kernel/cpu/common.c
17443 @@ -86,60 +86,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17444
17445 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17446
17447 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17448 -#ifdef CONFIG_X86_64
17449 - /*
17450 - * We need valid kernel segments for data and code in long mode too
17451 - * IRET will check the segment types kkeil 2000/10/28
17452 - * Also sysret mandates a special GDT layout
17453 - *
17454 - * TLS descriptors are currently at a different place compared to i386.
17455 - * Hopefully nobody expects them at a fixed place (Wine?)
17456 - */
17457 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17458 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17459 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17460 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17461 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17462 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17463 -#else
17464 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17465 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17466 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17467 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17468 - /*
17469 - * Segments used for calling PnP BIOS have byte granularity.
17470 - * They code segments and data segments have fixed 64k limits,
17471 - * the transfer segment sizes are set at run time.
17472 - */
17473 - /* 32-bit code */
17474 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17475 - /* 16-bit code */
17476 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17477 - /* 16-bit data */
17478 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17479 - /* 16-bit data */
17480 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17481 - /* 16-bit data */
17482 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17483 - /*
17484 - * The APM segments have byte granularity and their bases
17485 - * are set at run time. All have 64k limits.
17486 - */
17487 - /* 32-bit code */
17488 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17489 - /* 16-bit code */
17490 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17491 - /* data */
17492 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17493 -
17494 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17495 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17496 - GDT_STACK_CANARY_INIT
17497 -#endif
17498 -} };
17499 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17500 -
17501 static int __init x86_xsave_setup(char *s)
17502 {
17503 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17504 @@ -389,7 +335,7 @@ void switch_to_new_gdt(int cpu)
17505 {
17506 struct desc_ptr gdt_descr;
17507
17508 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17509 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17510 gdt_descr.size = GDT_SIZE - 1;
17511 load_gdt(&gdt_descr);
17512 /* Reload the per-cpu base */
17513 @@ -885,6 +831,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17514 /* Filter out anything that depends on CPUID levels we don't have */
17515 filter_cpuid_features(c, true);
17516
17517 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17518 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17519 +#endif
17520 +
17521 /* If the model name is still unset, do table lookup. */
17522 if (!c->x86_model_id[0]) {
17523 const char *p;
17524 @@ -1068,10 +1018,12 @@ static __init int setup_disablecpuid(char *arg)
17525 }
17526 __setup("clearcpuid=", setup_disablecpuid);
17527
17528 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17529 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17530 +
17531 #ifdef CONFIG_X86_64
17532 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17533 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17534 - (unsigned long) nmi_idt_table };
17535 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17536
17537 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17538 irq_stack_union) __aligned(PAGE_SIZE);
17539 @@ -1085,7 +1037,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17540 EXPORT_PER_CPU_SYMBOL(current_task);
17541
17542 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17543 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17544 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17545 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17546
17547 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17548 @@ -1224,7 +1176,7 @@ void __cpuinit cpu_init(void)
17549 int i;
17550
17551 cpu = stack_smp_processor_id();
17552 - t = &per_cpu(init_tss, cpu);
17553 + t = init_tss + cpu;
17554 oist = &per_cpu(orig_ist, cpu);
17555
17556 #ifdef CONFIG_NUMA
17557 @@ -1250,7 +1202,7 @@ void __cpuinit cpu_init(void)
17558 switch_to_new_gdt(cpu);
17559 loadsegment(fs, 0);
17560
17561 - load_idt((const struct desc_ptr *)&idt_descr);
17562 + load_idt(&idt_descr);
17563
17564 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17565 syscall_init();
17566 @@ -1259,7 +1211,6 @@ void __cpuinit cpu_init(void)
17567 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17568 barrier();
17569
17570 - x86_configure_nx();
17571 enable_x2apic();
17572
17573 /*
17574 @@ -1311,7 +1262,7 @@ void __cpuinit cpu_init(void)
17575 {
17576 int cpu = smp_processor_id();
17577 struct task_struct *curr = current;
17578 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17579 + struct tss_struct *t = init_tss + cpu;
17580 struct thread_struct *thread = &curr->thread;
17581
17582 if (cpumask_test_and_set_cpu(cpu, cpu_initialized_mask)) {
17583 diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
17584 index fcaabd0..7b55a26 100644
17585 --- a/arch/x86/kernel/cpu/intel.c
17586 +++ b/arch/x86/kernel/cpu/intel.c
17587 @@ -174,7 +174,7 @@ static void __cpuinit trap_init_f00f_bug(void)
17588 * Update the IDT descriptor and reload the IDT so that
17589 * it uses the read-only mapped virtual address.
17590 */
17591 - idt_descr.address = fix_to_virt(FIX_F00F_IDT);
17592 + idt_descr.address = (struct desc_struct *)fix_to_virt(FIX_F00F_IDT);
17593 load_idt(&idt_descr);
17594 }
17595 #endif
17596 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17597 index 84c1309..39b7224 100644
17598 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17599 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17600 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17601 };
17602
17603 #ifdef CONFIG_AMD_NB
17604 +static struct attribute *default_attrs_amd_nb[] = {
17605 + &type.attr,
17606 + &level.attr,
17607 + &coherency_line_size.attr,
17608 + &physical_line_partition.attr,
17609 + &ways_of_associativity.attr,
17610 + &number_of_sets.attr,
17611 + &size.attr,
17612 + &shared_cpu_map.attr,
17613 + &shared_cpu_list.attr,
17614 + NULL,
17615 + NULL,
17616 + NULL,
17617 + NULL
17618 +};
17619 +
17620 static struct attribute ** __cpuinit amd_l3_attrs(void)
17621 {
17622 static struct attribute **attrs;
17623 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17624
17625 n = ARRAY_SIZE(default_attrs);
17626
17627 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17628 - n += 2;
17629 -
17630 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17631 - n += 1;
17632 -
17633 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17634 - if (attrs == NULL)
17635 - return attrs = default_attrs;
17636 -
17637 - for (n = 0; default_attrs[n]; n++)
17638 - attrs[n] = default_attrs[n];
17639 + attrs = default_attrs_amd_nb;
17640
17641 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17642 attrs[n++] = &cache_disable_0.attr;
17643 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17644 .default_attrs = default_attrs,
17645 };
17646
17647 +#ifdef CONFIG_AMD_NB
17648 +static struct kobj_type ktype_cache_amd_nb = {
17649 + .sysfs_ops = &sysfs_ops,
17650 + .default_attrs = default_attrs_amd_nb,
17651 +};
17652 +#endif
17653 +
17654 static struct kobj_type ktype_percpu_entry = {
17655 .sysfs_ops = &sysfs_ops,
17656 };
17657 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17658 return retval;
17659 }
17660
17661 +#ifdef CONFIG_AMD_NB
17662 + amd_l3_attrs();
17663 +#endif
17664 +
17665 for (i = 0; i < num_cache_leaves; i++) {
17666 + struct kobj_type *ktype;
17667 +
17668 this_object = INDEX_KOBJECT_PTR(cpu, i);
17669 this_object->cpu = cpu;
17670 this_object->index = i;
17671
17672 this_leaf = CPUID4_INFO_IDX(cpu, i);
17673
17674 - ktype_cache.default_attrs = default_attrs;
17675 + ktype = &ktype_cache;
17676 #ifdef CONFIG_AMD_NB
17677 if (this_leaf->base.nb)
17678 - ktype_cache.default_attrs = amd_l3_attrs();
17679 + ktype = &ktype_cache_amd_nb;
17680 #endif
17681 retval = kobject_init_and_add(&(this_object->kobj),
17682 - &ktype_cache,
17683 + ktype,
17684 per_cpu(ici_cache_kobject, cpu),
17685 "index%1lu", i);
17686 if (unlikely(retval)) {
17687 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17688 return NOTIFY_OK;
17689 }
17690
17691 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17692 +static struct notifier_block cacheinfo_cpu_notifier = {
17693 .notifier_call = cacheinfo_cpu_callback,
17694 };
17695
17696 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17697 index 80dbda8..be16652 100644
17698 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17699 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17700 @@ -45,6 +45,7 @@
17701 #include <asm/processor.h>
17702 #include <asm/mce.h>
17703 #include <asm/msr.h>
17704 +#include <asm/local.h>
17705
17706 #include "mce-internal.h"
17707
17708 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17709 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17710 m->cs, m->ip);
17711
17712 - if (m->cs == __KERNEL_CS)
17713 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17714 print_symbol("{%s}", m->ip);
17715 pr_cont("\n");
17716 }
17717 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17718
17719 #define PANIC_TIMEOUT 5 /* 5 seconds */
17720
17721 -static atomic_t mce_paniced;
17722 +static atomic_unchecked_t mce_paniced;
17723
17724 static int fake_panic;
17725 -static atomic_t mce_fake_paniced;
17726 +static atomic_unchecked_t mce_fake_paniced;
17727
17728 /* Panic in progress. Enable interrupts and wait for final IPI */
17729 static void wait_for_panic(void)
17730 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17731 /*
17732 * Make sure only one CPU runs in machine check panic
17733 */
17734 - if (atomic_inc_return(&mce_paniced) > 1)
17735 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17736 wait_for_panic();
17737 barrier();
17738
17739 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17740 console_verbose();
17741 } else {
17742 /* Don't log too much for fake panic */
17743 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17744 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17745 return;
17746 }
17747 /* First print corrected ones that are still unlogged */
17748 @@ -686,7 +687,7 @@ static int mce_timed_out(u64 *t)
17749 * might have been modified by someone else.
17750 */
17751 rmb();
17752 - if (atomic_read(&mce_paniced))
17753 + if (atomic_read_unchecked(&mce_paniced))
17754 wait_for_panic();
17755 if (!mca_cfg.monarch_timeout)
17756 goto out;
17757 @@ -1662,7 +1663,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17758 }
17759
17760 /* Call the installed machine check handler for this CPU setup. */
17761 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17762 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17763 unexpected_machine_check;
17764
17765 /*
17766 @@ -1685,7 +1686,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17767 return;
17768 }
17769
17770 + pax_open_kernel();
17771 machine_check_vector = do_machine_check;
17772 + pax_close_kernel();
17773
17774 __mcheck_cpu_init_generic();
17775 __mcheck_cpu_init_vendor(c);
17776 @@ -1699,7 +1702,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17777 */
17778
17779 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17780 -static int mce_chrdev_open_count; /* #times opened */
17781 +static local_t mce_chrdev_open_count; /* #times opened */
17782 static int mce_chrdev_open_exclu; /* already open exclusive? */
17783
17784 static int mce_chrdev_open(struct inode *inode, struct file *file)
17785 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17786 spin_lock(&mce_chrdev_state_lock);
17787
17788 if (mce_chrdev_open_exclu ||
17789 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17790 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17791 spin_unlock(&mce_chrdev_state_lock);
17792
17793 return -EBUSY;
17794 @@ -1715,7 +1718,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17795
17796 if (file->f_flags & O_EXCL)
17797 mce_chrdev_open_exclu = 1;
17798 - mce_chrdev_open_count++;
17799 + local_inc(&mce_chrdev_open_count);
17800
17801 spin_unlock(&mce_chrdev_state_lock);
17802
17803 @@ -1726,7 +1729,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17804 {
17805 spin_lock(&mce_chrdev_state_lock);
17806
17807 - mce_chrdev_open_count--;
17808 + local_dec(&mce_chrdev_open_count);
17809 mce_chrdev_open_exclu = 0;
17810
17811 spin_unlock(&mce_chrdev_state_lock);
17812 @@ -2372,7 +2375,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17813 return NOTIFY_OK;
17814 }
17815
17816 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17817 +static struct notifier_block mce_cpu_notifier = {
17818 .notifier_call = mce_cpu_callback,
17819 };
17820
17821 @@ -2382,7 +2385,7 @@ static __init void mce_init_banks(void)
17822
17823 for (i = 0; i < mca_cfg.banks; i++) {
17824 struct mce_bank *b = &mce_banks[i];
17825 - struct device_attribute *a = &b->attr;
17826 + device_attribute_no_const *a = &b->attr;
17827
17828 sysfs_attr_init(&a->attr);
17829 a->attr.name = b->attrname;
17830 @@ -2450,7 +2453,7 @@ struct dentry *mce_get_debugfs_dir(void)
17831 static void mce_reset(void)
17832 {
17833 cpu_missing = 0;
17834 - atomic_set(&mce_fake_paniced, 0);
17835 + atomic_set_unchecked(&mce_fake_paniced, 0);
17836 atomic_set(&mce_executing, 0);
17837 atomic_set(&mce_callin, 0);
17838 atomic_set(&global_nwo, 0);
17839 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17840 index 2d5454c..51987eb 100644
17841 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17842 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17843 @@ -11,6 +11,7 @@
17844 #include <asm/processor.h>
17845 #include <asm/mce.h>
17846 #include <asm/msr.h>
17847 +#include <asm/pgtable.h>
17848
17849 /* By default disabled */
17850 int mce_p5_enabled __read_mostly;
17851 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17852 if (!cpu_has(c, X86_FEATURE_MCE))
17853 return;
17854
17855 + pax_open_kernel();
17856 machine_check_vector = pentium_machine_check;
17857 + pax_close_kernel();
17858 /* Make sure the vector pointer is visible before we enable MCEs: */
17859 wmb();
17860
17861 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17862 index 47a1870..8c019a7 100644
17863 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17864 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17865 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17866 return notifier_from_errno(err);
17867 }
17868
17869 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17870 +static struct notifier_block thermal_throttle_cpu_notifier =
17871 {
17872 .notifier_call = thermal_throttle_cpu_callback,
17873 };
17874 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17875 index 2d7998f..17c9de1 100644
17876 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17877 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17878 @@ -10,6 +10,7 @@
17879 #include <asm/processor.h>
17880 #include <asm/mce.h>
17881 #include <asm/msr.h>
17882 +#include <asm/pgtable.h>
17883
17884 /* Machine check handler for WinChip C6: */
17885 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17886 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17887 {
17888 u32 lo, hi;
17889
17890 + pax_open_kernel();
17891 machine_check_vector = winchip_machine_check;
17892 + pax_close_kernel();
17893 /* Make sure the vector pointer is visible before we enable MCEs: */
17894 wmb();
17895
17896 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17897 index 726bf96..81f0526 100644
17898 --- a/arch/x86/kernel/cpu/mtrr/main.c
17899 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17900 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17901 u64 size_or_mask, size_and_mask;
17902 static bool mtrr_aps_delayed_init;
17903
17904 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17905 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17906
17907 const struct mtrr_ops *mtrr_if;
17908
17909 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17910 index df5e41f..816c719 100644
17911 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17912 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17913 @@ -25,7 +25,7 @@ struct mtrr_ops {
17914 int (*validate_add_page)(unsigned long base, unsigned long size,
17915 unsigned int type);
17916 int (*have_wrcomb)(void);
17917 -};
17918 +} __do_const;
17919
17920 extern int generic_get_free_region(unsigned long base, unsigned long size,
17921 int replace_reg);
17922 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17923 index 6774c17..72c1b22 100644
17924 --- a/arch/x86/kernel/cpu/perf_event.c
17925 +++ b/arch/x86/kernel/cpu/perf_event.c
17926 @@ -1305,7 +1305,7 @@ static void __init pmu_check_apic(void)
17927 pr_info("no hardware sampling interrupt available.\n");
17928 }
17929
17930 -static struct attribute_group x86_pmu_format_group = {
17931 +static attribute_group_no_const x86_pmu_format_group = {
17932 .name = "format",
17933 .attrs = NULL,
17934 };
17935 @@ -1313,7 +1313,7 @@ static struct attribute_group x86_pmu_format_group = {
17936 struct perf_pmu_events_attr {
17937 struct device_attribute attr;
17938 u64 id;
17939 -};
17940 +} __do_const;
17941
17942 /*
17943 * Remove all undefined events (x86_pmu.event_map(id) == 0)
17944 @@ -1381,7 +1381,7 @@ static struct attribute *events_attr[] = {
17945 NULL,
17946 };
17947
17948 -static struct attribute_group x86_pmu_events_group = {
17949 +static attribute_group_no_const x86_pmu_events_group = {
17950 .name = "events",
17951 .attrs = events_attr,
17952 };
17953 @@ -1880,7 +1880,7 @@ static unsigned long get_segment_base(unsigned int segment)
17954 if (idx > GDT_ENTRIES)
17955 return 0;
17956
17957 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17958 + desc = get_cpu_gdt_table(smp_processor_id());
17959 }
17960
17961 return get_desc_base(desc + idx);
17962 @@ -1970,7 +1970,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17963 break;
17964
17965 perf_callchain_store(entry, frame.return_address);
17966 - fp = frame.next_frame;
17967 + fp = (const void __force_user *)frame.next_frame;
17968 }
17969 }
17970
17971 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17972 index 4914e94..60b06e3 100644
17973 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17974 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17975 @@ -1958,10 +1958,10 @@ __init int intel_pmu_init(void)
17976 * v2 and above have a perf capabilities MSR
17977 */
17978 if (version > 1) {
17979 - u64 capabilities;
17980 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17981
17982 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17983 - x86_pmu.intel_cap.capabilities = capabilities;
17984 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17985 + x86_pmu.intel_cap.capabilities = capabilities;
17986 }
17987
17988 intel_ds_init();
17989 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17990 index b43200d..d235b3e 100644
17991 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17992 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17993 @@ -2428,7 +2428,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17994 static int __init uncore_type_init(struct intel_uncore_type *type)
17995 {
17996 struct intel_uncore_pmu *pmus;
17997 - struct attribute_group *events_group;
17998 + attribute_group_no_const *attr_group;
17999 struct attribute **attrs;
18000 int i, j;
18001
18002 @@ -2455,19 +2455,19 @@ static int __init uncore_type_init(struct intel_uncore_type *type)
18003 while (type->event_descs[i].attr.attr.name)
18004 i++;
18005
18006 - events_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18007 - sizeof(*events_group), GFP_KERNEL);
18008 - if (!events_group)
18009 + attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
18010 + sizeof(*attr_group), GFP_KERNEL);
18011 + if (!attr_group)
18012 goto fail;
18013
18014 - attrs = (struct attribute **)(events_group + 1);
18015 - events_group->name = "events";
18016 - events_group->attrs = attrs;
18017 + attrs = (struct attribute **)(attr_group + 1);
18018 + attr_group->name = "events";
18019 + attr_group->attrs = attrs;
18020
18021 for (j = 0; j < i; j++)
18022 attrs[j] = &type->event_descs[j].attr.attr;
18023
18024 - type->events_group = events_group;
18025 + type->events_group = attr_group;
18026 }
18027
18028 type->pmu_group = &uncore_pmu_attr_group;
18029 @@ -2826,7 +2826,7 @@ static int
18030 return NOTIFY_OK;
18031 }
18032
18033 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
18034 +static struct notifier_block uncore_cpu_nb = {
18035 .notifier_call = uncore_cpu_notifier,
18036 /*
18037 * to migrate uncore events, our notifier should be executed
18038 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18039 index e68a455..975a932 100644
18040 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18041 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
18042 @@ -428,7 +428,7 @@ struct intel_uncore_box {
18043 struct uncore_event_desc {
18044 struct kobj_attribute attr;
18045 const char *config;
18046 -};
18047 +} __do_const;
18048
18049 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
18050 { \
18051 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
18052 index 60c7891..9e911d3 100644
18053 --- a/arch/x86/kernel/cpuid.c
18054 +++ b/arch/x86/kernel/cpuid.c
18055 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
18056 return notifier_from_errno(err);
18057 }
18058
18059 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
18060 +static struct notifier_block cpuid_class_cpu_notifier =
18061 {
18062 .notifier_call = cpuid_class_cpu_callback,
18063 };
18064 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
18065 index 74467fe..18793d5 100644
18066 --- a/arch/x86/kernel/crash.c
18067 +++ b/arch/x86/kernel/crash.c
18068 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
18069 {
18070 #ifdef CONFIG_X86_32
18071 struct pt_regs fixed_regs;
18072 -#endif
18073
18074 -#ifdef CONFIG_X86_32
18075 - if (!user_mode_vm(regs)) {
18076 + if (!user_mode(regs)) {
18077 crash_fixup_ss_esp(&fixed_regs, regs);
18078 regs = &fixed_regs;
18079 }
18080 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
18081 index 37250fe..bf2ec74 100644
18082 --- a/arch/x86/kernel/doublefault_32.c
18083 +++ b/arch/x86/kernel/doublefault_32.c
18084 @@ -11,7 +11,7 @@
18085
18086 #define DOUBLEFAULT_STACKSIZE (1024)
18087 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
18088 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
18089 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
18090
18091 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
18092
18093 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
18094 unsigned long gdt, tss;
18095
18096 store_gdt(&gdt_desc);
18097 - gdt = gdt_desc.address;
18098 + gdt = (unsigned long)gdt_desc.address;
18099
18100 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
18101
18102 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
18103 /* 0x2 bit is always set */
18104 .flags = X86_EFLAGS_SF | 0x2,
18105 .sp = STACK_START,
18106 - .es = __USER_DS,
18107 + .es = __KERNEL_DS,
18108 .cs = __KERNEL_CS,
18109 .ss = __KERNEL_DS,
18110 - .ds = __USER_DS,
18111 + .ds = __KERNEL_DS,
18112 .fs = __KERNEL_PERCPU,
18113
18114 .__cr3 = __pa_nodebug(swapper_pg_dir),
18115 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
18116 index ae42418b..787c16b 100644
18117 --- a/arch/x86/kernel/dumpstack.c
18118 +++ b/arch/x86/kernel/dumpstack.c
18119 @@ -2,6 +2,9 @@
18120 * Copyright (C) 1991, 1992 Linus Torvalds
18121 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
18122 */
18123 +#ifdef CONFIG_GRKERNSEC_HIDESYM
18124 +#define __INCLUDED_BY_HIDESYM 1
18125 +#endif
18126 #include <linux/kallsyms.h>
18127 #include <linux/kprobes.h>
18128 #include <linux/uaccess.h>
18129 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
18130 static void
18131 print_ftrace_graph_addr(unsigned long addr, void *data,
18132 const struct stacktrace_ops *ops,
18133 - struct thread_info *tinfo, int *graph)
18134 + struct task_struct *task, int *graph)
18135 {
18136 - struct task_struct *task;
18137 unsigned long ret_addr;
18138 int index;
18139
18140 if (addr != (unsigned long)return_to_handler)
18141 return;
18142
18143 - task = tinfo->task;
18144 index = task->curr_ret_stack;
18145
18146 if (!task->ret_stack || index < *graph)
18147 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18148 static inline void
18149 print_ftrace_graph_addr(unsigned long addr, void *data,
18150 const struct stacktrace_ops *ops,
18151 - struct thread_info *tinfo, int *graph)
18152 + struct task_struct *task, int *graph)
18153 { }
18154 #endif
18155
18156 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
18157 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
18158 */
18159
18160 -static inline int valid_stack_ptr(struct thread_info *tinfo,
18161 - void *p, unsigned int size, void *end)
18162 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
18163 {
18164 - void *t = tinfo;
18165 if (end) {
18166 if (p < end && p >= (end-THREAD_SIZE))
18167 return 1;
18168 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
18169 }
18170
18171 unsigned long
18172 -print_context_stack(struct thread_info *tinfo,
18173 +print_context_stack(struct task_struct *task, void *stack_start,
18174 unsigned long *stack, unsigned long bp,
18175 const struct stacktrace_ops *ops, void *data,
18176 unsigned long *end, int *graph)
18177 {
18178 struct stack_frame *frame = (struct stack_frame *)bp;
18179
18180 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
18181 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
18182 unsigned long addr;
18183
18184 addr = *stack;
18185 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
18186 } else {
18187 ops->address(data, addr, 0);
18188 }
18189 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18190 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18191 }
18192 stack++;
18193 }
18194 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
18195 EXPORT_SYMBOL_GPL(print_context_stack);
18196
18197 unsigned long
18198 -print_context_stack_bp(struct thread_info *tinfo,
18199 +print_context_stack_bp(struct task_struct *task, void *stack_start,
18200 unsigned long *stack, unsigned long bp,
18201 const struct stacktrace_ops *ops, void *data,
18202 unsigned long *end, int *graph)
18203 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18204 struct stack_frame *frame = (struct stack_frame *)bp;
18205 unsigned long *ret_addr = &frame->return_address;
18206
18207 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
18208 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
18209 unsigned long addr = *ret_addr;
18210
18211 if (!__kernel_text_address(addr))
18212 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
18213 ops->address(data, addr, 1);
18214 frame = frame->next_frame;
18215 ret_addr = &frame->return_address;
18216 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
18217 + print_ftrace_graph_addr(addr, data, ops, task, graph);
18218 }
18219
18220 return (unsigned long)frame;
18221 @@ -189,7 +188,7 @@ void dump_stack(void)
18222
18223 bp = stack_frame(current, NULL);
18224 printk("Pid: %d, comm: %.20s %s %s %.*s\n",
18225 - current->pid, current->comm, print_tainted(),
18226 + task_pid_nr(current), current->comm, print_tainted(),
18227 init_utsname()->release,
18228 (int)strcspn(init_utsname()->version, " "),
18229 init_utsname()->version);
18230 @@ -225,6 +224,8 @@ unsigned __kprobes long oops_begin(void)
18231 }
18232 EXPORT_SYMBOL_GPL(oops_begin);
18233
18234 +extern void gr_handle_kernel_exploit(void);
18235 +
18236 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18237 {
18238 if (regs && kexec_should_crash(current))
18239 @@ -246,7 +247,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
18240 panic("Fatal exception in interrupt");
18241 if (panic_on_oops)
18242 panic("Fatal exception");
18243 - do_exit(signr);
18244 +
18245 + gr_handle_kernel_exploit();
18246 +
18247 + do_group_exit(signr);
18248 }
18249
18250 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18251 @@ -274,7 +278,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
18252 print_modules();
18253 show_regs(regs);
18254 #ifdef CONFIG_X86_32
18255 - if (user_mode_vm(regs)) {
18256 + if (user_mode(regs)) {
18257 sp = regs->sp;
18258 ss = regs->ss & 0xffff;
18259 } else {
18260 @@ -302,7 +306,7 @@ void die(const char *str, struct pt_regs *regs, long err)
18261 unsigned long flags = oops_begin();
18262 int sig = SIGSEGV;
18263
18264 - if (!user_mode_vm(regs))
18265 + if (!user_mode(regs))
18266 report_bug(regs->ip, regs);
18267
18268 if (__die(str, regs, err))
18269 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
18270 index 1038a41..db2c12b 100644
18271 --- a/arch/x86/kernel/dumpstack_32.c
18272 +++ b/arch/x86/kernel/dumpstack_32.c
18273 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18274 bp = stack_frame(task, regs);
18275
18276 for (;;) {
18277 - struct thread_info *context;
18278 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18279
18280 - context = (struct thread_info *)
18281 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
18282 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
18283 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18284
18285 - stack = (unsigned long *)context->previous_esp;
18286 - if (!stack)
18287 + if (stack_start == task_stack_page(task))
18288 break;
18289 + stack = *(unsigned long **)stack_start;
18290 if (ops->stack(data, "IRQ") < 0)
18291 break;
18292 touch_nmi_watchdog();
18293 @@ -86,7 +84,7 @@ void show_regs(struct pt_regs *regs)
18294 {
18295 int i;
18296
18297 - __show_regs(regs, !user_mode_vm(regs));
18298 + __show_regs(regs, !user_mode(regs));
18299
18300 pr_emerg("Process %.*s (pid: %d, ti=%p task=%p task.ti=%p)\n",
18301 TASK_COMM_LEN, current->comm, task_pid_nr(current),
18302 @@ -95,21 +93,22 @@ void show_regs(struct pt_regs *regs)
18303 * When in-kernel, we also print out the stack and code at the
18304 * time of the fault..
18305 */
18306 - if (!user_mode_vm(regs)) {
18307 + if (!user_mode(regs)) {
18308 unsigned int code_prologue = code_bytes * 43 / 64;
18309 unsigned int code_len = code_bytes;
18310 unsigned char c;
18311 u8 *ip;
18312 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
18313
18314 pr_emerg("Stack:\n");
18315 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
18316
18317 pr_emerg("Code:");
18318
18319 - ip = (u8 *)regs->ip - code_prologue;
18320 + ip = (u8 *)regs->ip - code_prologue + cs_base;
18321 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
18322 /* try starting at IP */
18323 - ip = (u8 *)regs->ip;
18324 + ip = (u8 *)regs->ip + cs_base;
18325 code_len = code_len - code_prologue + 1;
18326 }
18327 for (i = 0; i < code_len; i++, ip++) {
18328 @@ -118,7 +117,7 @@ void show_regs(struct pt_regs *regs)
18329 pr_cont(" Bad EIP value.");
18330 break;
18331 }
18332 - if (ip == (u8 *)regs->ip)
18333 + if (ip == (u8 *)regs->ip + cs_base)
18334 pr_cont(" <%02x>", c);
18335 else
18336 pr_cont(" %02x", c);
18337 @@ -131,6 +130,7 @@ int is_valid_bugaddr(unsigned long ip)
18338 {
18339 unsigned short ud2;
18340
18341 + ip = ktla_ktva(ip);
18342 if (ip < PAGE_OFFSET)
18343 return 0;
18344 if (probe_kernel_address((unsigned short *)ip, ud2))
18345 @@ -138,3 +138,15 @@ int is_valid_bugaddr(unsigned long ip)
18346
18347 return ud2 == 0x0b0f;
18348 }
18349 +
18350 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18351 +void pax_check_alloca(unsigned long size)
18352 +{
18353 + unsigned long sp = (unsigned long)&sp, stack_left;
18354 +
18355 + /* all kernel stacks are of the same size */
18356 + stack_left = sp & (THREAD_SIZE - 1);
18357 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18358 +}
18359 +EXPORT_SYMBOL(pax_check_alloca);
18360 +#endif
18361 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18362 index b653675..51cc8c0 100644
18363 --- a/arch/x86/kernel/dumpstack_64.c
18364 +++ b/arch/x86/kernel/dumpstack_64.c
18365 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18366 unsigned long *irq_stack_end =
18367 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18368 unsigned used = 0;
18369 - struct thread_info *tinfo;
18370 int graph = 0;
18371 unsigned long dummy;
18372 + void *stack_start;
18373
18374 if (!task)
18375 task = current;
18376 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18377 * current stack address. If the stacks consist of nested
18378 * exceptions
18379 */
18380 - tinfo = task_thread_info(task);
18381 for (;;) {
18382 char *id;
18383 unsigned long *estack_end;
18384 +
18385 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18386 &used, &id);
18387
18388 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18389 if (ops->stack(data, id) < 0)
18390 break;
18391
18392 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18393 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18394 data, estack_end, &graph);
18395 ops->stack(data, "<EOE>");
18396 /*
18397 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18398 * second-to-last pointer (index -2 to end) in the
18399 * exception stack:
18400 */
18401 + if ((u16)estack_end[-1] != __KERNEL_DS)
18402 + goto out;
18403 stack = (unsigned long *) estack_end[-2];
18404 continue;
18405 }
18406 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18407 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18408 if (ops->stack(data, "IRQ") < 0)
18409 break;
18410 - bp = ops->walk_stack(tinfo, stack, bp,
18411 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18412 ops, data, irq_stack_end, &graph);
18413 /*
18414 * We link to the next stack (which would be
18415 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18416 /*
18417 * This handles the process stack:
18418 */
18419 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18420 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18421 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18422 +out:
18423 put_cpu();
18424 }
18425 EXPORT_SYMBOL(dump_trace);
18426 @@ -249,7 +253,7 @@ void show_regs(struct pt_regs *regs)
18427 {
18428 int i;
18429 unsigned long sp;
18430 - const int cpu = smp_processor_id();
18431 + const int cpu = raw_smp_processor_id();
18432 struct task_struct *cur = current;
18433
18434 sp = regs->sp;
18435 @@ -304,3 +308,50 @@ int is_valid_bugaddr(unsigned long ip)
18436
18437 return ud2 == 0x0b0f;
18438 }
18439 +
18440 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18441 +void pax_check_alloca(unsigned long size)
18442 +{
18443 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18444 + unsigned cpu, used;
18445 + char *id;
18446 +
18447 + /* check the process stack first */
18448 + stack_start = (unsigned long)task_stack_page(current);
18449 + stack_end = stack_start + THREAD_SIZE;
18450 + if (likely(stack_start <= sp && sp < stack_end)) {
18451 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18452 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18453 + return;
18454 + }
18455 +
18456 + cpu = get_cpu();
18457 +
18458 + /* check the irq stacks */
18459 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18460 + stack_start = stack_end - IRQ_STACK_SIZE;
18461 + if (stack_start <= sp && sp < stack_end) {
18462 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18463 + put_cpu();
18464 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18465 + return;
18466 + }
18467 +
18468 + /* check the exception stacks */
18469 + used = 0;
18470 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18471 + stack_start = stack_end - EXCEPTION_STKSZ;
18472 + if (stack_end && stack_start <= sp && sp < stack_end) {
18473 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18474 + put_cpu();
18475 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18476 + return;
18477 + }
18478 +
18479 + put_cpu();
18480 +
18481 + /* unknown stack */
18482 + BUG();
18483 +}
18484 +EXPORT_SYMBOL(pax_check_alloca);
18485 +#endif
18486 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18487 index 9b9f18b..9fcaa04 100644
18488 --- a/arch/x86/kernel/early_printk.c
18489 +++ b/arch/x86/kernel/early_printk.c
18490 @@ -7,6 +7,7 @@
18491 #include <linux/pci_regs.h>
18492 #include <linux/pci_ids.h>
18493 #include <linux/errno.h>
18494 +#include <linux/sched.h>
18495 #include <asm/io.h>
18496 #include <asm/processor.h>
18497 #include <asm/fcntl.h>
18498 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18499 index 6ed91d9..6cc365b 100644
18500 --- a/arch/x86/kernel/entry_32.S
18501 +++ b/arch/x86/kernel/entry_32.S
18502 @@ -177,13 +177,153 @@
18503 /*CFI_REL_OFFSET gs, PT_GS*/
18504 .endm
18505 .macro SET_KERNEL_GS reg
18506 +
18507 +#ifdef CONFIG_CC_STACKPROTECTOR
18508 movl $(__KERNEL_STACK_CANARY), \reg
18509 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18510 + movl $(__USER_DS), \reg
18511 +#else
18512 + xorl \reg, \reg
18513 +#endif
18514 +
18515 movl \reg, %gs
18516 .endm
18517
18518 #endif /* CONFIG_X86_32_LAZY_GS */
18519
18520 -.macro SAVE_ALL
18521 +.macro pax_enter_kernel
18522 +#ifdef CONFIG_PAX_KERNEXEC
18523 + call pax_enter_kernel
18524 +#endif
18525 +.endm
18526 +
18527 +.macro pax_exit_kernel
18528 +#ifdef CONFIG_PAX_KERNEXEC
18529 + call pax_exit_kernel
18530 +#endif
18531 +.endm
18532 +
18533 +#ifdef CONFIG_PAX_KERNEXEC
18534 +ENTRY(pax_enter_kernel)
18535 +#ifdef CONFIG_PARAVIRT
18536 + pushl %eax
18537 + pushl %ecx
18538 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18539 + mov %eax, %esi
18540 +#else
18541 + mov %cr0, %esi
18542 +#endif
18543 + bts $16, %esi
18544 + jnc 1f
18545 + mov %cs, %esi
18546 + cmp $__KERNEL_CS, %esi
18547 + jz 3f
18548 + ljmp $__KERNEL_CS, $3f
18549 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18550 +2:
18551 +#ifdef CONFIG_PARAVIRT
18552 + mov %esi, %eax
18553 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18554 +#else
18555 + mov %esi, %cr0
18556 +#endif
18557 +3:
18558 +#ifdef CONFIG_PARAVIRT
18559 + popl %ecx
18560 + popl %eax
18561 +#endif
18562 + ret
18563 +ENDPROC(pax_enter_kernel)
18564 +
18565 +ENTRY(pax_exit_kernel)
18566 +#ifdef CONFIG_PARAVIRT
18567 + pushl %eax
18568 + pushl %ecx
18569 +#endif
18570 + mov %cs, %esi
18571 + cmp $__KERNEXEC_KERNEL_CS, %esi
18572 + jnz 2f
18573 +#ifdef CONFIG_PARAVIRT
18574 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18575 + mov %eax, %esi
18576 +#else
18577 + mov %cr0, %esi
18578 +#endif
18579 + btr $16, %esi
18580 + ljmp $__KERNEL_CS, $1f
18581 +1:
18582 +#ifdef CONFIG_PARAVIRT
18583 + mov %esi, %eax
18584 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18585 +#else
18586 + mov %esi, %cr0
18587 +#endif
18588 +2:
18589 +#ifdef CONFIG_PARAVIRT
18590 + popl %ecx
18591 + popl %eax
18592 +#endif
18593 + ret
18594 +ENDPROC(pax_exit_kernel)
18595 +#endif
18596 +
18597 +.macro pax_erase_kstack
18598 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18599 + call pax_erase_kstack
18600 +#endif
18601 +.endm
18602 +
18603 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18604 +/*
18605 + * ebp: thread_info
18606 + */
18607 +ENTRY(pax_erase_kstack)
18608 + pushl %edi
18609 + pushl %ecx
18610 + pushl %eax
18611 +
18612 + mov TI_lowest_stack(%ebp), %edi
18613 + mov $-0xBEEF, %eax
18614 + std
18615 +
18616 +1: mov %edi, %ecx
18617 + and $THREAD_SIZE_asm - 1, %ecx
18618 + shr $2, %ecx
18619 + repne scasl
18620 + jecxz 2f
18621 +
18622 + cmp $2*16, %ecx
18623 + jc 2f
18624 +
18625 + mov $2*16, %ecx
18626 + repe scasl
18627 + jecxz 2f
18628 + jne 1b
18629 +
18630 +2: cld
18631 + mov %esp, %ecx
18632 + sub %edi, %ecx
18633 +
18634 + cmp $THREAD_SIZE_asm, %ecx
18635 + jb 3f
18636 + ud2
18637 +3:
18638 +
18639 + shr $2, %ecx
18640 + rep stosl
18641 +
18642 + mov TI_task_thread_sp0(%ebp), %edi
18643 + sub $128, %edi
18644 + mov %edi, TI_lowest_stack(%ebp)
18645 +
18646 + popl %eax
18647 + popl %ecx
18648 + popl %edi
18649 + ret
18650 +ENDPROC(pax_erase_kstack)
18651 +#endif
18652 +
18653 +.macro __SAVE_ALL _DS
18654 cld
18655 PUSH_GS
18656 pushl_cfi %fs
18657 @@ -206,7 +346,7 @@
18658 CFI_REL_OFFSET ecx, 0
18659 pushl_cfi %ebx
18660 CFI_REL_OFFSET ebx, 0
18661 - movl $(__USER_DS), %edx
18662 + movl $\_DS, %edx
18663 movl %edx, %ds
18664 movl %edx, %es
18665 movl $(__KERNEL_PERCPU), %edx
18666 @@ -214,6 +354,15 @@
18667 SET_KERNEL_GS %edx
18668 .endm
18669
18670 +.macro SAVE_ALL
18671 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18672 + __SAVE_ALL __KERNEL_DS
18673 + pax_enter_kernel
18674 +#else
18675 + __SAVE_ALL __USER_DS
18676 +#endif
18677 +.endm
18678 +
18679 .macro RESTORE_INT_REGS
18680 popl_cfi %ebx
18681 CFI_RESTORE ebx
18682 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18683 popfl_cfi
18684 jmp syscall_exit
18685 CFI_ENDPROC
18686 -END(ret_from_fork)
18687 +ENDPROC(ret_from_fork)
18688
18689 ENTRY(ret_from_kernel_thread)
18690 CFI_STARTPROC
18691 @@ -344,7 +493,15 @@ ret_from_intr:
18692 andl $SEGMENT_RPL_MASK, %eax
18693 #endif
18694 cmpl $USER_RPL, %eax
18695 +
18696 +#ifdef CONFIG_PAX_KERNEXEC
18697 + jae resume_userspace
18698 +
18699 + pax_exit_kernel
18700 + jmp resume_kernel
18701 +#else
18702 jb resume_kernel # not returning to v8086 or userspace
18703 +#endif
18704
18705 ENTRY(resume_userspace)
18706 LOCKDEP_SYS_EXIT
18707 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18708 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18709 # int/exception return?
18710 jne work_pending
18711 - jmp restore_all
18712 -END(ret_from_exception)
18713 + jmp restore_all_pax
18714 +ENDPROC(ret_from_exception)
18715
18716 #ifdef CONFIG_PREEMPT
18717 ENTRY(resume_kernel)
18718 @@ -372,7 +529,7 @@ need_resched:
18719 jz restore_all
18720 call preempt_schedule_irq
18721 jmp need_resched
18722 -END(resume_kernel)
18723 +ENDPROC(resume_kernel)
18724 #endif
18725 CFI_ENDPROC
18726 /*
18727 @@ -406,30 +563,45 @@ sysenter_past_esp:
18728 /*CFI_REL_OFFSET cs, 0*/
18729 /*
18730 * Push current_thread_info()->sysenter_return to the stack.
18731 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18732 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18733 */
18734 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18735 + pushl_cfi $0
18736 CFI_REL_OFFSET eip, 0
18737
18738 pushl_cfi %eax
18739 SAVE_ALL
18740 + GET_THREAD_INFO(%ebp)
18741 + movl TI_sysenter_return(%ebp),%ebp
18742 + movl %ebp,PT_EIP(%esp)
18743 ENABLE_INTERRUPTS(CLBR_NONE)
18744
18745 /*
18746 * Load the potential sixth argument from user stack.
18747 * Careful about security.
18748 */
18749 + movl PT_OLDESP(%esp),%ebp
18750 +
18751 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18752 + mov PT_OLDSS(%esp),%ds
18753 +1: movl %ds:(%ebp),%ebp
18754 + push %ss
18755 + pop %ds
18756 +#else
18757 cmpl $__PAGE_OFFSET-3,%ebp
18758 jae syscall_fault
18759 ASM_STAC
18760 1: movl (%ebp),%ebp
18761 ASM_CLAC
18762 +#endif
18763 +
18764 movl %ebp,PT_EBP(%esp)
18765 _ASM_EXTABLE(1b,syscall_fault)
18766
18767 GET_THREAD_INFO(%ebp)
18768
18769 +#ifdef CONFIG_PAX_RANDKSTACK
18770 + pax_erase_kstack
18771 +#endif
18772 +
18773 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18774 jnz sysenter_audit
18775 sysenter_do_call:
18776 @@ -444,12 +616,24 @@ sysenter_do_call:
18777 testl $_TIF_ALLWORK_MASK, %ecx
18778 jne sysexit_audit
18779 sysenter_exit:
18780 +
18781 +#ifdef CONFIG_PAX_RANDKSTACK
18782 + pushl_cfi %eax
18783 + movl %esp, %eax
18784 + call pax_randomize_kstack
18785 + popl_cfi %eax
18786 +#endif
18787 +
18788 + pax_erase_kstack
18789 +
18790 /* if something modifies registers it must also disable sysexit */
18791 movl PT_EIP(%esp), %edx
18792 movl PT_OLDESP(%esp), %ecx
18793 xorl %ebp,%ebp
18794 TRACE_IRQS_ON
18795 1: mov PT_FS(%esp), %fs
18796 +2: mov PT_DS(%esp), %ds
18797 +3: mov PT_ES(%esp), %es
18798 PTGS_TO_GS
18799 ENABLE_INTERRUPTS_SYSEXIT
18800
18801 @@ -466,6 +650,9 @@ sysenter_audit:
18802 movl %eax,%edx /* 2nd arg: syscall number */
18803 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18804 call __audit_syscall_entry
18805 +
18806 + pax_erase_kstack
18807 +
18808 pushl_cfi %ebx
18809 movl PT_EAX(%esp),%eax /* reload syscall number */
18810 jmp sysenter_do_call
18811 @@ -491,10 +678,16 @@ sysexit_audit:
18812
18813 CFI_ENDPROC
18814 .pushsection .fixup,"ax"
18815 -2: movl $0,PT_FS(%esp)
18816 +4: movl $0,PT_FS(%esp)
18817 + jmp 1b
18818 +5: movl $0,PT_DS(%esp)
18819 + jmp 1b
18820 +6: movl $0,PT_ES(%esp)
18821 jmp 1b
18822 .popsection
18823 - _ASM_EXTABLE(1b,2b)
18824 + _ASM_EXTABLE(1b,4b)
18825 + _ASM_EXTABLE(2b,5b)
18826 + _ASM_EXTABLE(3b,6b)
18827 PTGS_TO_GS_EX
18828 ENDPROC(ia32_sysenter_target)
18829
18830 @@ -509,6 +702,11 @@ ENTRY(system_call)
18831 pushl_cfi %eax # save orig_eax
18832 SAVE_ALL
18833 GET_THREAD_INFO(%ebp)
18834 +
18835 +#ifdef CONFIG_PAX_RANDKSTACK
18836 + pax_erase_kstack
18837 +#endif
18838 +
18839 # system call tracing in operation / emulation
18840 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18841 jnz syscall_trace_entry
18842 @@ -527,6 +725,15 @@ syscall_exit:
18843 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18844 jne syscall_exit_work
18845
18846 +restore_all_pax:
18847 +
18848 +#ifdef CONFIG_PAX_RANDKSTACK
18849 + movl %esp, %eax
18850 + call pax_randomize_kstack
18851 +#endif
18852 +
18853 + pax_erase_kstack
18854 +
18855 restore_all:
18856 TRACE_IRQS_IRET
18857 restore_all_notrace:
18858 @@ -583,14 +790,34 @@ ldt_ss:
18859 * compensating for the offset by changing to the ESPFIX segment with
18860 * a base address that matches for the difference.
18861 */
18862 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18863 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18864 mov %esp, %edx /* load kernel esp */
18865 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18866 mov %dx, %ax /* eax: new kernel esp */
18867 sub %eax, %edx /* offset (low word is 0) */
18868 +#ifdef CONFIG_SMP
18869 + movl PER_CPU_VAR(cpu_number), %ebx
18870 + shll $PAGE_SHIFT_asm, %ebx
18871 + addl $cpu_gdt_table, %ebx
18872 +#else
18873 + movl $cpu_gdt_table, %ebx
18874 +#endif
18875 shr $16, %edx
18876 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18877 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18878 +
18879 +#ifdef CONFIG_PAX_KERNEXEC
18880 + mov %cr0, %esi
18881 + btr $16, %esi
18882 + mov %esi, %cr0
18883 +#endif
18884 +
18885 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18886 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18887 +
18888 +#ifdef CONFIG_PAX_KERNEXEC
18889 + bts $16, %esi
18890 + mov %esi, %cr0
18891 +#endif
18892 +
18893 pushl_cfi $__ESPFIX_SS
18894 pushl_cfi %eax /* new kernel esp */
18895 /* Disable interrupts, but do not irqtrace this section: we
18896 @@ -619,20 +846,18 @@ work_resched:
18897 movl TI_flags(%ebp), %ecx
18898 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18899 # than syscall tracing?
18900 - jz restore_all
18901 + jz restore_all_pax
18902 testb $_TIF_NEED_RESCHED, %cl
18903 jnz work_resched
18904
18905 work_notifysig: # deal with pending signals and
18906 # notify-resume requests
18907 + movl %esp, %eax
18908 #ifdef CONFIG_VM86
18909 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18910 - movl %esp, %eax
18911 jne work_notifysig_v86 # returning to kernel-space or
18912 # vm86-space
18913 1:
18914 -#else
18915 - movl %esp, %eax
18916 #endif
18917 TRACE_IRQS_ON
18918 ENABLE_INTERRUPTS(CLBR_NONE)
18919 @@ -653,7 +878,7 @@ work_notifysig_v86:
18920 movl %eax, %esp
18921 jmp 1b
18922 #endif
18923 -END(work_pending)
18924 +ENDPROC(work_pending)
18925
18926 # perform syscall exit tracing
18927 ALIGN
18928 @@ -661,11 +886,14 @@ syscall_trace_entry:
18929 movl $-ENOSYS,PT_EAX(%esp)
18930 movl %esp, %eax
18931 call syscall_trace_enter
18932 +
18933 + pax_erase_kstack
18934 +
18935 /* What it returned is what we'll actually use. */
18936 cmpl $(NR_syscalls), %eax
18937 jnae syscall_call
18938 jmp syscall_exit
18939 -END(syscall_trace_entry)
18940 +ENDPROC(syscall_trace_entry)
18941
18942 # perform syscall exit tracing
18943 ALIGN
18944 @@ -678,21 +906,25 @@ syscall_exit_work:
18945 movl %esp, %eax
18946 call syscall_trace_leave
18947 jmp resume_userspace
18948 -END(syscall_exit_work)
18949 +ENDPROC(syscall_exit_work)
18950 CFI_ENDPROC
18951
18952 RING0_INT_FRAME # can't unwind into user space anyway
18953 syscall_fault:
18954 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18955 + push %ss
18956 + pop %ds
18957 +#endif
18958 ASM_CLAC
18959 GET_THREAD_INFO(%ebp)
18960 movl $-EFAULT,PT_EAX(%esp)
18961 jmp resume_userspace
18962 -END(syscall_fault)
18963 +ENDPROC(syscall_fault)
18964
18965 syscall_badsys:
18966 movl $-ENOSYS,PT_EAX(%esp)
18967 jmp resume_userspace
18968 -END(syscall_badsys)
18969 +ENDPROC(syscall_badsys)
18970 CFI_ENDPROC
18971 /*
18972 * End of kprobes section
18973 @@ -753,8 +985,15 @@ PTREGSCALL1(vm86old)
18974 * normal stack and adjusts ESP with the matching offset.
18975 */
18976 /* fixup the stack */
18977 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18978 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18979 +#ifdef CONFIG_SMP
18980 + movl PER_CPU_VAR(cpu_number), %ebx
18981 + shll $PAGE_SHIFT_asm, %ebx
18982 + addl $cpu_gdt_table, %ebx
18983 +#else
18984 + movl $cpu_gdt_table, %ebx
18985 +#endif
18986 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18987 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18988 shl $16, %eax
18989 addl %esp, %eax /* the adjusted stack pointer */
18990 pushl_cfi $__KERNEL_DS
18991 @@ -807,7 +1046,7 @@ vector=vector+1
18992 .endr
18993 2: jmp common_interrupt
18994 .endr
18995 -END(irq_entries_start)
18996 +ENDPROC(irq_entries_start)
18997
18998 .previous
18999 END(interrupt)
19000 @@ -858,7 +1097,7 @@ ENTRY(coprocessor_error)
19001 pushl_cfi $do_coprocessor_error
19002 jmp error_code
19003 CFI_ENDPROC
19004 -END(coprocessor_error)
19005 +ENDPROC(coprocessor_error)
19006
19007 ENTRY(simd_coprocessor_error)
19008 RING0_INT_FRAME
19009 @@ -880,7 +1119,7 @@ ENTRY(simd_coprocessor_error)
19010 #endif
19011 jmp error_code
19012 CFI_ENDPROC
19013 -END(simd_coprocessor_error)
19014 +ENDPROC(simd_coprocessor_error)
19015
19016 ENTRY(device_not_available)
19017 RING0_INT_FRAME
19018 @@ -889,18 +1128,18 @@ ENTRY(device_not_available)
19019 pushl_cfi $do_device_not_available
19020 jmp error_code
19021 CFI_ENDPROC
19022 -END(device_not_available)
19023 +ENDPROC(device_not_available)
19024
19025 #ifdef CONFIG_PARAVIRT
19026 ENTRY(native_iret)
19027 iret
19028 _ASM_EXTABLE(native_iret, iret_exc)
19029 -END(native_iret)
19030 +ENDPROC(native_iret)
19031
19032 ENTRY(native_irq_enable_sysexit)
19033 sti
19034 sysexit
19035 -END(native_irq_enable_sysexit)
19036 +ENDPROC(native_irq_enable_sysexit)
19037 #endif
19038
19039 ENTRY(overflow)
19040 @@ -910,7 +1149,7 @@ ENTRY(overflow)
19041 pushl_cfi $do_overflow
19042 jmp error_code
19043 CFI_ENDPROC
19044 -END(overflow)
19045 +ENDPROC(overflow)
19046
19047 ENTRY(bounds)
19048 RING0_INT_FRAME
19049 @@ -919,7 +1158,7 @@ ENTRY(bounds)
19050 pushl_cfi $do_bounds
19051 jmp error_code
19052 CFI_ENDPROC
19053 -END(bounds)
19054 +ENDPROC(bounds)
19055
19056 ENTRY(invalid_op)
19057 RING0_INT_FRAME
19058 @@ -928,7 +1167,7 @@ ENTRY(invalid_op)
19059 pushl_cfi $do_invalid_op
19060 jmp error_code
19061 CFI_ENDPROC
19062 -END(invalid_op)
19063 +ENDPROC(invalid_op)
19064
19065 ENTRY(coprocessor_segment_overrun)
19066 RING0_INT_FRAME
19067 @@ -937,7 +1176,7 @@ ENTRY(coprocessor_segment_overrun)
19068 pushl_cfi $do_coprocessor_segment_overrun
19069 jmp error_code
19070 CFI_ENDPROC
19071 -END(coprocessor_segment_overrun)
19072 +ENDPROC(coprocessor_segment_overrun)
19073
19074 ENTRY(invalid_TSS)
19075 RING0_EC_FRAME
19076 @@ -945,7 +1184,7 @@ ENTRY(invalid_TSS)
19077 pushl_cfi $do_invalid_TSS
19078 jmp error_code
19079 CFI_ENDPROC
19080 -END(invalid_TSS)
19081 +ENDPROC(invalid_TSS)
19082
19083 ENTRY(segment_not_present)
19084 RING0_EC_FRAME
19085 @@ -953,7 +1192,7 @@ ENTRY(segment_not_present)
19086 pushl_cfi $do_segment_not_present
19087 jmp error_code
19088 CFI_ENDPROC
19089 -END(segment_not_present)
19090 +ENDPROC(segment_not_present)
19091
19092 ENTRY(stack_segment)
19093 RING0_EC_FRAME
19094 @@ -961,7 +1200,7 @@ ENTRY(stack_segment)
19095 pushl_cfi $do_stack_segment
19096 jmp error_code
19097 CFI_ENDPROC
19098 -END(stack_segment)
19099 +ENDPROC(stack_segment)
19100
19101 ENTRY(alignment_check)
19102 RING0_EC_FRAME
19103 @@ -969,7 +1208,7 @@ ENTRY(alignment_check)
19104 pushl_cfi $do_alignment_check
19105 jmp error_code
19106 CFI_ENDPROC
19107 -END(alignment_check)
19108 +ENDPROC(alignment_check)
19109
19110 ENTRY(divide_error)
19111 RING0_INT_FRAME
19112 @@ -978,7 +1217,7 @@ ENTRY(divide_error)
19113 pushl_cfi $do_divide_error
19114 jmp error_code
19115 CFI_ENDPROC
19116 -END(divide_error)
19117 +ENDPROC(divide_error)
19118
19119 #ifdef CONFIG_X86_MCE
19120 ENTRY(machine_check)
19121 @@ -988,7 +1227,7 @@ ENTRY(machine_check)
19122 pushl_cfi machine_check_vector
19123 jmp error_code
19124 CFI_ENDPROC
19125 -END(machine_check)
19126 +ENDPROC(machine_check)
19127 #endif
19128
19129 ENTRY(spurious_interrupt_bug)
19130 @@ -998,7 +1237,7 @@ ENTRY(spurious_interrupt_bug)
19131 pushl_cfi $do_spurious_interrupt_bug
19132 jmp error_code
19133 CFI_ENDPROC
19134 -END(spurious_interrupt_bug)
19135 +ENDPROC(spurious_interrupt_bug)
19136 /*
19137 * End of kprobes section
19138 */
19139 @@ -1101,7 +1340,7 @@ BUILD_INTERRUPT3(xen_hvm_callback_vector, XEN_HVM_EVTCHN_CALLBACK,
19140
19141 ENTRY(mcount)
19142 ret
19143 -END(mcount)
19144 +ENDPROC(mcount)
19145
19146 ENTRY(ftrace_caller)
19147 cmpl $0, function_trace_stop
19148 @@ -1134,7 +1373,7 @@ ftrace_graph_call:
19149 .globl ftrace_stub
19150 ftrace_stub:
19151 ret
19152 -END(ftrace_caller)
19153 +ENDPROC(ftrace_caller)
19154
19155 ENTRY(ftrace_regs_caller)
19156 pushf /* push flags before compare (in cs location) */
19157 @@ -1235,7 +1474,7 @@ trace:
19158 popl %ecx
19159 popl %eax
19160 jmp ftrace_stub
19161 -END(mcount)
19162 +ENDPROC(mcount)
19163 #endif /* CONFIG_DYNAMIC_FTRACE */
19164 #endif /* CONFIG_FUNCTION_TRACER */
19165
19166 @@ -1253,7 +1492,7 @@ ENTRY(ftrace_graph_caller)
19167 popl %ecx
19168 popl %eax
19169 ret
19170 -END(ftrace_graph_caller)
19171 +ENDPROC(ftrace_graph_caller)
19172
19173 .globl return_to_handler
19174 return_to_handler:
19175 @@ -1309,15 +1548,18 @@ error_code:
19176 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
19177 REG_TO_PTGS %ecx
19178 SET_KERNEL_GS %ecx
19179 - movl $(__USER_DS), %ecx
19180 + movl $(__KERNEL_DS), %ecx
19181 movl %ecx, %ds
19182 movl %ecx, %es
19183 +
19184 + pax_enter_kernel
19185 +
19186 TRACE_IRQS_OFF
19187 movl %esp,%eax # pt_regs pointer
19188 call *%edi
19189 jmp ret_from_exception
19190 CFI_ENDPROC
19191 -END(page_fault)
19192 +ENDPROC(page_fault)
19193
19194 /*
19195 * Debug traps and NMI can happen at the one SYSENTER instruction
19196 @@ -1360,7 +1602,7 @@ debug_stack_correct:
19197 call do_debug
19198 jmp ret_from_exception
19199 CFI_ENDPROC
19200 -END(debug)
19201 +ENDPROC(debug)
19202
19203 /*
19204 * NMI is doubly nasty. It can happen _while_ we're handling
19205 @@ -1398,6 +1640,9 @@ nmi_stack_correct:
19206 xorl %edx,%edx # zero error code
19207 movl %esp,%eax # pt_regs pointer
19208 call do_nmi
19209 +
19210 + pax_exit_kernel
19211 +
19212 jmp restore_all_notrace
19213 CFI_ENDPROC
19214
19215 @@ -1434,12 +1679,15 @@ nmi_espfix_stack:
19216 FIXUP_ESPFIX_STACK # %eax == %esp
19217 xorl %edx,%edx # zero error code
19218 call do_nmi
19219 +
19220 + pax_exit_kernel
19221 +
19222 RESTORE_REGS
19223 lss 12+4(%esp), %esp # back to espfix stack
19224 CFI_ADJUST_CFA_OFFSET -24
19225 jmp irq_return
19226 CFI_ENDPROC
19227 -END(nmi)
19228 +ENDPROC(nmi)
19229
19230 ENTRY(int3)
19231 RING0_INT_FRAME
19232 @@ -1452,14 +1700,14 @@ ENTRY(int3)
19233 call do_int3
19234 jmp ret_from_exception
19235 CFI_ENDPROC
19236 -END(int3)
19237 +ENDPROC(int3)
19238
19239 ENTRY(general_protection)
19240 RING0_EC_FRAME
19241 pushl_cfi $do_general_protection
19242 jmp error_code
19243 CFI_ENDPROC
19244 -END(general_protection)
19245 +ENDPROC(general_protection)
19246
19247 #ifdef CONFIG_KVM_GUEST
19248 ENTRY(async_page_fault)
19249 @@ -1468,7 +1716,7 @@ ENTRY(async_page_fault)
19250 pushl_cfi $do_async_page_fault
19251 jmp error_code
19252 CFI_ENDPROC
19253 -END(async_page_fault)
19254 +ENDPROC(async_page_fault)
19255 #endif
19256
19257 /*
19258 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
19259 index cb3c591..7ba137c 100644
19260 --- a/arch/x86/kernel/entry_64.S
19261 +++ b/arch/x86/kernel/entry_64.S
19262 @@ -59,6 +59,8 @@
19263 #include <asm/context_tracking.h>
19264 #include <asm/smap.h>
19265 #include <linux/err.h>
19266 +#include <asm/pgtable.h>
19267 +#include <asm/alternative-asm.h>
19268
19269 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
19270 #include <linux/elf-em.h>
19271 @@ -80,8 +82,9 @@
19272 #ifdef CONFIG_DYNAMIC_FTRACE
19273
19274 ENTRY(function_hook)
19275 + pax_force_retaddr
19276 retq
19277 -END(function_hook)
19278 +ENDPROC(function_hook)
19279
19280 /* skip is set if stack has been adjusted */
19281 .macro ftrace_caller_setup skip=0
19282 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
19283 #endif
19284
19285 GLOBAL(ftrace_stub)
19286 + pax_force_retaddr
19287 retq
19288 -END(ftrace_caller)
19289 +ENDPROC(ftrace_caller)
19290
19291 ENTRY(ftrace_regs_caller)
19292 /* Save the current flags before compare (in SS location)*/
19293 @@ -191,7 +195,7 @@ ftrace_restore_flags:
19294 popfq
19295 jmp ftrace_stub
19296
19297 -END(ftrace_regs_caller)
19298 +ENDPROC(ftrace_regs_caller)
19299
19300
19301 #else /* ! CONFIG_DYNAMIC_FTRACE */
19302 @@ -212,6 +216,7 @@ ENTRY(function_hook)
19303 #endif
19304
19305 GLOBAL(ftrace_stub)
19306 + pax_force_retaddr
19307 retq
19308
19309 trace:
19310 @@ -225,12 +230,13 @@ trace:
19311 #endif
19312 subq $MCOUNT_INSN_SIZE, %rdi
19313
19314 + pax_force_fptr ftrace_trace_function
19315 call *ftrace_trace_function
19316
19317 MCOUNT_RESTORE_FRAME
19318
19319 jmp ftrace_stub
19320 -END(function_hook)
19321 +ENDPROC(function_hook)
19322 #endif /* CONFIG_DYNAMIC_FTRACE */
19323 #endif /* CONFIG_FUNCTION_TRACER */
19324
19325 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
19326
19327 MCOUNT_RESTORE_FRAME
19328
19329 + pax_force_retaddr
19330 retq
19331 -END(ftrace_graph_caller)
19332 +ENDPROC(ftrace_graph_caller)
19333
19334 GLOBAL(return_to_handler)
19335 subq $24, %rsp
19336 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19337 movq 8(%rsp), %rdx
19338 movq (%rsp), %rax
19339 addq $24, %rsp
19340 + pax_force_fptr %rdi
19341 jmp *%rdi
19342 +ENDPROC(return_to_handler)
19343 #endif
19344
19345
19346 @@ -284,6 +293,273 @@ ENTRY(native_usergs_sysret64)
19347 ENDPROC(native_usergs_sysret64)
19348 #endif /* CONFIG_PARAVIRT */
19349
19350 + .macro ljmpq sel, off
19351 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19352 + .byte 0x48; ljmp *1234f(%rip)
19353 + .pushsection .rodata
19354 + .align 16
19355 + 1234: .quad \off; .word \sel
19356 + .popsection
19357 +#else
19358 + pushq $\sel
19359 + pushq $\off
19360 + lretq
19361 +#endif
19362 + .endm
19363 +
19364 + .macro pax_enter_kernel
19365 + pax_set_fptr_mask
19366 +#ifdef CONFIG_PAX_KERNEXEC
19367 + call pax_enter_kernel
19368 +#endif
19369 + .endm
19370 +
19371 + .macro pax_exit_kernel
19372 +#ifdef CONFIG_PAX_KERNEXEC
19373 + call pax_exit_kernel
19374 +#endif
19375 + .endm
19376 +
19377 +#ifdef CONFIG_PAX_KERNEXEC
19378 +ENTRY(pax_enter_kernel)
19379 + pushq %rdi
19380 +
19381 +#ifdef CONFIG_PARAVIRT
19382 + PV_SAVE_REGS(CLBR_RDI)
19383 +#endif
19384 +
19385 + GET_CR0_INTO_RDI
19386 + bts $16,%rdi
19387 + jnc 3f
19388 + mov %cs,%edi
19389 + cmp $__KERNEL_CS,%edi
19390 + jnz 2f
19391 +1:
19392 +
19393 +#ifdef CONFIG_PARAVIRT
19394 + PV_RESTORE_REGS(CLBR_RDI)
19395 +#endif
19396 +
19397 + popq %rdi
19398 + pax_force_retaddr
19399 + retq
19400 +
19401 +2: ljmpq __KERNEL_CS,1b
19402 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19403 +4: SET_RDI_INTO_CR0
19404 + jmp 1b
19405 +ENDPROC(pax_enter_kernel)
19406 +
19407 +ENTRY(pax_exit_kernel)
19408 + pushq %rdi
19409 +
19410 +#ifdef CONFIG_PARAVIRT
19411 + PV_SAVE_REGS(CLBR_RDI)
19412 +#endif
19413 +
19414 + mov %cs,%rdi
19415 + cmp $__KERNEXEC_KERNEL_CS,%edi
19416 + jz 2f
19417 +1:
19418 +
19419 +#ifdef CONFIG_PARAVIRT
19420 + PV_RESTORE_REGS(CLBR_RDI);
19421 +#endif
19422 +
19423 + popq %rdi
19424 + pax_force_retaddr
19425 + retq
19426 +
19427 +2: GET_CR0_INTO_RDI
19428 + btr $16,%rdi
19429 + ljmpq __KERNEL_CS,3f
19430 +3: SET_RDI_INTO_CR0
19431 + jmp 1b
19432 +ENDPROC(pax_exit_kernel)
19433 +#endif
19434 +
19435 + .macro pax_enter_kernel_user
19436 + pax_set_fptr_mask
19437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19438 + call pax_enter_kernel_user
19439 +#endif
19440 + .endm
19441 +
19442 + .macro pax_exit_kernel_user
19443 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19444 + call pax_exit_kernel_user
19445 +#endif
19446 +#ifdef CONFIG_PAX_RANDKSTACK
19447 + pushq %rax
19448 + call pax_randomize_kstack
19449 + popq %rax
19450 +#endif
19451 + .endm
19452 +
19453 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19454 +ENTRY(pax_enter_kernel_user)
19455 + pushq %rdi
19456 + pushq %rbx
19457 +
19458 +#ifdef CONFIG_PARAVIRT
19459 + PV_SAVE_REGS(CLBR_RDI)
19460 +#endif
19461 +
19462 + GET_CR3_INTO_RDI
19463 + mov %rdi,%rbx
19464 + add $__START_KERNEL_map,%rbx
19465 + sub phys_base(%rip),%rbx
19466 +
19467 +#ifdef CONFIG_PARAVIRT
19468 + pushq %rdi
19469 + cmpl $0, pv_info+PARAVIRT_enabled
19470 + jz 1f
19471 + i = 0
19472 + .rept USER_PGD_PTRS
19473 + mov i*8(%rbx),%rsi
19474 + mov $0,%sil
19475 + lea i*8(%rbx),%rdi
19476 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19477 + i = i + 1
19478 + .endr
19479 + jmp 2f
19480 +1:
19481 +#endif
19482 +
19483 + i = 0
19484 + .rept USER_PGD_PTRS
19485 + movb $0,i*8(%rbx)
19486 + i = i + 1
19487 + .endr
19488 +
19489 +#ifdef CONFIG_PARAVIRT
19490 +2: popq %rdi
19491 +#endif
19492 + SET_RDI_INTO_CR3
19493 +
19494 +#ifdef CONFIG_PAX_KERNEXEC
19495 + GET_CR0_INTO_RDI
19496 + bts $16,%rdi
19497 + SET_RDI_INTO_CR0
19498 +#endif
19499 +
19500 +#ifdef CONFIG_PARAVIRT
19501 + PV_RESTORE_REGS(CLBR_RDI)
19502 +#endif
19503 +
19504 + popq %rbx
19505 + popq %rdi
19506 + pax_force_retaddr
19507 + retq
19508 +ENDPROC(pax_enter_kernel_user)
19509 +
19510 +ENTRY(pax_exit_kernel_user)
19511 + push %rdi
19512 +
19513 +#ifdef CONFIG_PARAVIRT
19514 + pushq %rbx
19515 + PV_SAVE_REGS(CLBR_RDI)
19516 +#endif
19517 +
19518 +#ifdef CONFIG_PAX_KERNEXEC
19519 + GET_CR0_INTO_RDI
19520 + btr $16,%rdi
19521 + SET_RDI_INTO_CR0
19522 +#endif
19523 +
19524 + GET_CR3_INTO_RDI
19525 + add $__START_KERNEL_map,%rdi
19526 + sub phys_base(%rip),%rdi
19527 +
19528 +#ifdef CONFIG_PARAVIRT
19529 + cmpl $0, pv_info+PARAVIRT_enabled
19530 + jz 1f
19531 + mov %rdi,%rbx
19532 + i = 0
19533 + .rept USER_PGD_PTRS
19534 + mov i*8(%rbx),%rsi
19535 + mov $0x67,%sil
19536 + lea i*8(%rbx),%rdi
19537 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19538 + i = i + 1
19539 + .endr
19540 + jmp 2f
19541 +1:
19542 +#endif
19543 +
19544 + i = 0
19545 + .rept USER_PGD_PTRS
19546 + movb $0x67,i*8(%rdi)
19547 + i = i + 1
19548 + .endr
19549 +
19550 +#ifdef CONFIG_PARAVIRT
19551 +2: PV_RESTORE_REGS(CLBR_RDI)
19552 + popq %rbx
19553 +#endif
19554 +
19555 + popq %rdi
19556 + pax_force_retaddr
19557 + retq
19558 +ENDPROC(pax_exit_kernel_user)
19559 +#endif
19560 +
19561 +.macro pax_erase_kstack
19562 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19563 + call pax_erase_kstack
19564 +#endif
19565 +.endm
19566 +
19567 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19568 +ENTRY(pax_erase_kstack)
19569 + pushq %rdi
19570 + pushq %rcx
19571 + pushq %rax
19572 + pushq %r11
19573 +
19574 + GET_THREAD_INFO(%r11)
19575 + mov TI_lowest_stack(%r11), %rdi
19576 + mov $-0xBEEF, %rax
19577 + std
19578 +
19579 +1: mov %edi, %ecx
19580 + and $THREAD_SIZE_asm - 1, %ecx
19581 + shr $3, %ecx
19582 + repne scasq
19583 + jecxz 2f
19584 +
19585 + cmp $2*8, %ecx
19586 + jc 2f
19587 +
19588 + mov $2*8, %ecx
19589 + repe scasq
19590 + jecxz 2f
19591 + jne 1b
19592 +
19593 +2: cld
19594 + mov %esp, %ecx
19595 + sub %edi, %ecx
19596 +
19597 + cmp $THREAD_SIZE_asm, %rcx
19598 + jb 3f
19599 + ud2
19600 +3:
19601 +
19602 + shr $3, %ecx
19603 + rep stosq
19604 +
19605 + mov TI_task_thread_sp0(%r11), %rdi
19606 + sub $256, %rdi
19607 + mov %rdi, TI_lowest_stack(%r11)
19608 +
19609 + popq %r11
19610 + popq %rax
19611 + popq %rcx
19612 + popq %rdi
19613 + pax_force_retaddr
19614 + ret
19615 +ENDPROC(pax_erase_kstack)
19616 +#endif
19617
19618 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19619 #ifdef CONFIG_TRACE_IRQFLAGS
19620 @@ -375,8 +651,8 @@ ENDPROC(native_usergs_sysret64)
19621 .endm
19622
19623 .macro UNFAKE_STACK_FRAME
19624 - addq $8*6, %rsp
19625 - CFI_ADJUST_CFA_OFFSET -(6*8)
19626 + addq $8*6 + ARG_SKIP, %rsp
19627 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19628 .endm
19629
19630 /*
19631 @@ -463,7 +739,7 @@ ENDPROC(native_usergs_sysret64)
19632 movq %rsp, %rsi
19633
19634 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19635 - testl $3, CS-RBP(%rsi)
19636 + testb $3, CS-RBP(%rsi)
19637 je 1f
19638 SWAPGS
19639 /*
19640 @@ -498,9 +774,10 @@ ENTRY(save_rest)
19641 movq_cfi r15, R15+16
19642 movq %r11, 8(%rsp) /* return address */
19643 FIXUP_TOP_OF_STACK %r11, 16
19644 + pax_force_retaddr
19645 ret
19646 CFI_ENDPROC
19647 -END(save_rest)
19648 +ENDPROC(save_rest)
19649
19650 /* save complete stack frame */
19651 .pushsection .kprobes.text, "ax"
19652 @@ -529,9 +806,10 @@ ENTRY(save_paranoid)
19653 js 1f /* negative -> in kernel */
19654 SWAPGS
19655 xorl %ebx,%ebx
19656 -1: ret
19657 +1: pax_force_retaddr_bts
19658 + ret
19659 CFI_ENDPROC
19660 -END(save_paranoid)
19661 +ENDPROC(save_paranoid)
19662 .popsection
19663
19664 /*
19665 @@ -553,7 +831,7 @@ ENTRY(ret_from_fork)
19666
19667 RESTORE_REST
19668
19669 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19670 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19671 jz 1f
19672
19673 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19674 @@ -571,7 +849,7 @@ ENTRY(ret_from_fork)
19675 RESTORE_REST
19676 jmp int_ret_from_sys_call
19677 CFI_ENDPROC
19678 -END(ret_from_fork)
19679 +ENDPROC(ret_from_fork)
19680
19681 /*
19682 * System call entry. Up to 6 arguments in registers are supported.
19683 @@ -608,7 +886,7 @@ END(ret_from_fork)
19684 ENTRY(system_call)
19685 CFI_STARTPROC simple
19686 CFI_SIGNAL_FRAME
19687 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19688 + CFI_DEF_CFA rsp,0
19689 CFI_REGISTER rip,rcx
19690 /*CFI_REGISTER rflags,r11*/
19691 SWAPGS_UNSAFE_STACK
19692 @@ -621,16 +899,23 @@ GLOBAL(system_call_after_swapgs)
19693
19694 movq %rsp,PER_CPU_VAR(old_rsp)
19695 movq PER_CPU_VAR(kernel_stack),%rsp
19696 + SAVE_ARGS 8*6,0
19697 + pax_enter_kernel_user
19698 +
19699 +#ifdef CONFIG_PAX_RANDKSTACK
19700 + pax_erase_kstack
19701 +#endif
19702 +
19703 /*
19704 * No need to follow this irqs off/on section - it's straight
19705 * and short:
19706 */
19707 ENABLE_INTERRUPTS(CLBR_NONE)
19708 - SAVE_ARGS 8,0
19709 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19710 movq %rcx,RIP-ARGOFFSET(%rsp)
19711 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19712 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19713 + GET_THREAD_INFO(%rcx)
19714 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19715 jnz tracesys
19716 system_call_fastpath:
19717 #if __SYSCALL_MASK == ~0
19718 @@ -640,7 +925,7 @@ system_call_fastpath:
19719 cmpl $__NR_syscall_max,%eax
19720 #endif
19721 ja badsys
19722 - movq %r10,%rcx
19723 + movq R10-ARGOFFSET(%rsp),%rcx
19724 call *sys_call_table(,%rax,8) # XXX: rip relative
19725 movq %rax,RAX-ARGOFFSET(%rsp)
19726 /*
19727 @@ -654,10 +939,13 @@ sysret_check:
19728 LOCKDEP_SYS_EXIT
19729 DISABLE_INTERRUPTS(CLBR_NONE)
19730 TRACE_IRQS_OFF
19731 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19732 + GET_THREAD_INFO(%rcx)
19733 + movl TI_flags(%rcx),%edx
19734 andl %edi,%edx
19735 jnz sysret_careful
19736 CFI_REMEMBER_STATE
19737 + pax_exit_kernel_user
19738 + pax_erase_kstack
19739 /*
19740 * sysretq will re-enable interrupts:
19741 */
19742 @@ -709,14 +997,18 @@ badsys:
19743 * jump back to the normal fast path.
19744 */
19745 auditsys:
19746 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19747 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19748 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19749 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19750 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19751 movq %rax,%rsi /* 2nd arg: syscall number */
19752 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19753 call __audit_syscall_entry
19754 +
19755 + pax_erase_kstack
19756 +
19757 LOAD_ARGS 0 /* reload call-clobbered registers */
19758 + pax_set_fptr_mask
19759 jmp system_call_fastpath
19760
19761 /*
19762 @@ -737,7 +1029,7 @@ sysret_audit:
19763 /* Do syscall tracing */
19764 tracesys:
19765 #ifdef CONFIG_AUDITSYSCALL
19766 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19767 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19768 jz auditsys
19769 #endif
19770 SAVE_REST
19771 @@ -745,12 +1037,16 @@ tracesys:
19772 FIXUP_TOP_OF_STACK %rdi
19773 movq %rsp,%rdi
19774 call syscall_trace_enter
19775 +
19776 + pax_erase_kstack
19777 +
19778 /*
19779 * Reload arg registers from stack in case ptrace changed them.
19780 * We don't reload %rax because syscall_trace_enter() returned
19781 * the value it wants us to use in the table lookup.
19782 */
19783 LOAD_ARGS ARGOFFSET, 1
19784 + pax_set_fptr_mask
19785 RESTORE_REST
19786 #if __SYSCALL_MASK == ~0
19787 cmpq $__NR_syscall_max,%rax
19788 @@ -759,7 +1055,7 @@ tracesys:
19789 cmpl $__NR_syscall_max,%eax
19790 #endif
19791 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19792 - movq %r10,%rcx /* fixup for C */
19793 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19794 call *sys_call_table(,%rax,8)
19795 movq %rax,RAX-ARGOFFSET(%rsp)
19796 /* Use IRET because user could have changed frame */
19797 @@ -780,7 +1076,9 @@ GLOBAL(int_with_check)
19798 andl %edi,%edx
19799 jnz int_careful
19800 andl $~TS_COMPAT,TI_status(%rcx)
19801 - jmp retint_swapgs
19802 + pax_exit_kernel_user
19803 + pax_erase_kstack
19804 + jmp retint_swapgs_pax
19805
19806 /* Either reschedule or signal or syscall exit tracking needed. */
19807 /* First do a reschedule test. */
19808 @@ -826,7 +1124,7 @@ int_restore_rest:
19809 TRACE_IRQS_OFF
19810 jmp int_with_check
19811 CFI_ENDPROC
19812 -END(system_call)
19813 +ENDPROC(system_call)
19814
19815 /*
19816 * Certain special system calls that need to save a complete full stack frame.
19817 @@ -842,7 +1140,7 @@ ENTRY(\label)
19818 call \func
19819 jmp ptregscall_common
19820 CFI_ENDPROC
19821 -END(\label)
19822 +ENDPROC(\label)
19823 .endm
19824
19825 .macro FORK_LIKE func
19826 @@ -856,9 +1154,10 @@ ENTRY(stub_\func)
19827 DEFAULT_FRAME 0 8 /* offset 8: return address */
19828 call sys_\func
19829 RESTORE_TOP_OF_STACK %r11, 8
19830 + pax_force_retaddr
19831 ret $REST_SKIP /* pop extended registers */
19832 CFI_ENDPROC
19833 -END(stub_\func)
19834 +ENDPROC(stub_\func)
19835 .endm
19836
19837 FORK_LIKE clone
19838 @@ -875,9 +1174,10 @@ ENTRY(ptregscall_common)
19839 movq_cfi_restore R12+8, r12
19840 movq_cfi_restore RBP+8, rbp
19841 movq_cfi_restore RBX+8, rbx
19842 + pax_force_retaddr
19843 ret $REST_SKIP /* pop extended registers */
19844 CFI_ENDPROC
19845 -END(ptregscall_common)
19846 +ENDPROC(ptregscall_common)
19847
19848 ENTRY(stub_execve)
19849 CFI_STARTPROC
19850 @@ -891,7 +1191,7 @@ ENTRY(stub_execve)
19851 RESTORE_REST
19852 jmp int_ret_from_sys_call
19853 CFI_ENDPROC
19854 -END(stub_execve)
19855 +ENDPROC(stub_execve)
19856
19857 /*
19858 * sigreturn is special because it needs to restore all registers on return.
19859 @@ -909,7 +1209,7 @@ ENTRY(stub_rt_sigreturn)
19860 RESTORE_REST
19861 jmp int_ret_from_sys_call
19862 CFI_ENDPROC
19863 -END(stub_rt_sigreturn)
19864 +ENDPROC(stub_rt_sigreturn)
19865
19866 #ifdef CONFIG_X86_X32_ABI
19867 ENTRY(stub_x32_rt_sigreturn)
19868 @@ -975,7 +1275,7 @@ vector=vector+1
19869 2: jmp common_interrupt
19870 .endr
19871 CFI_ENDPROC
19872 -END(irq_entries_start)
19873 +ENDPROC(irq_entries_start)
19874
19875 .previous
19876 END(interrupt)
19877 @@ -995,6 +1295,16 @@ END(interrupt)
19878 subq $ORIG_RAX-RBP, %rsp
19879 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19880 SAVE_ARGS_IRQ
19881 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19882 + testb $3, CS(%rdi)
19883 + jnz 1f
19884 + pax_enter_kernel
19885 + jmp 2f
19886 +1: pax_enter_kernel_user
19887 +2:
19888 +#else
19889 + pax_enter_kernel
19890 +#endif
19891 call \func
19892 .endm
19893
19894 @@ -1027,7 +1337,7 @@ ret_from_intr:
19895
19896 exit_intr:
19897 GET_THREAD_INFO(%rcx)
19898 - testl $3,CS-ARGOFFSET(%rsp)
19899 + testb $3,CS-ARGOFFSET(%rsp)
19900 je retint_kernel
19901
19902 /* Interrupt came from user space */
19903 @@ -1049,12 +1359,16 @@ retint_swapgs: /* return to user-space */
19904 * The iretq could re-enable interrupts:
19905 */
19906 DISABLE_INTERRUPTS(CLBR_ANY)
19907 + pax_exit_kernel_user
19908 +retint_swapgs_pax:
19909 TRACE_IRQS_IRETQ
19910 SWAPGS
19911 jmp restore_args
19912
19913 retint_restore_args: /* return to kernel space */
19914 DISABLE_INTERRUPTS(CLBR_ANY)
19915 + pax_exit_kernel
19916 + pax_force_retaddr (RIP-ARGOFFSET)
19917 /*
19918 * The iretq could re-enable interrupts:
19919 */
19920 @@ -1137,7 +1451,7 @@ ENTRY(retint_kernel)
19921 #endif
19922
19923 CFI_ENDPROC
19924 -END(common_interrupt)
19925 +ENDPROC(common_interrupt)
19926 /*
19927 * End of kprobes section
19928 */
19929 @@ -1155,7 +1469,7 @@ ENTRY(\sym)
19930 interrupt \do_sym
19931 jmp ret_from_intr
19932 CFI_ENDPROC
19933 -END(\sym)
19934 +ENDPROC(\sym)
19935 .endm
19936
19937 #ifdef CONFIG_SMP
19938 @@ -1211,12 +1525,22 @@ ENTRY(\sym)
19939 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19940 call error_entry
19941 DEFAULT_FRAME 0
19942 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19943 + testb $3, CS(%rsp)
19944 + jnz 1f
19945 + pax_enter_kernel
19946 + jmp 2f
19947 +1: pax_enter_kernel_user
19948 +2:
19949 +#else
19950 + pax_enter_kernel
19951 +#endif
19952 movq %rsp,%rdi /* pt_regs pointer */
19953 xorl %esi,%esi /* no error code */
19954 call \do_sym
19955 jmp error_exit /* %ebx: no swapgs flag */
19956 CFI_ENDPROC
19957 -END(\sym)
19958 +ENDPROC(\sym)
19959 .endm
19960
19961 .macro paranoidzeroentry sym do_sym
19962 @@ -1229,15 +1553,25 @@ ENTRY(\sym)
19963 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19964 call save_paranoid
19965 TRACE_IRQS_OFF
19966 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19967 + testb $3, CS(%rsp)
19968 + jnz 1f
19969 + pax_enter_kernel
19970 + jmp 2f
19971 +1: pax_enter_kernel_user
19972 +2:
19973 +#else
19974 + pax_enter_kernel
19975 +#endif
19976 movq %rsp,%rdi /* pt_regs pointer */
19977 xorl %esi,%esi /* no error code */
19978 call \do_sym
19979 jmp paranoid_exit /* %ebx: no swapgs flag */
19980 CFI_ENDPROC
19981 -END(\sym)
19982 +ENDPROC(\sym)
19983 .endm
19984
19985 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19986 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19987 .macro paranoidzeroentry_ist sym do_sym ist
19988 ENTRY(\sym)
19989 INTR_FRAME
19990 @@ -1248,14 +1582,30 @@ ENTRY(\sym)
19991 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19992 call save_paranoid
19993 TRACE_IRQS_OFF_DEBUG
19994 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19995 + testb $3, CS(%rsp)
19996 + jnz 1f
19997 + pax_enter_kernel
19998 + jmp 2f
19999 +1: pax_enter_kernel_user
20000 +2:
20001 +#else
20002 + pax_enter_kernel
20003 +#endif
20004 movq %rsp,%rdi /* pt_regs pointer */
20005 xorl %esi,%esi /* no error code */
20006 +#ifdef CONFIG_SMP
20007 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
20008 + lea init_tss(%r12), %r12
20009 +#else
20010 + lea init_tss(%rip), %r12
20011 +#endif
20012 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20013 call \do_sym
20014 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
20015 jmp paranoid_exit /* %ebx: no swapgs flag */
20016 CFI_ENDPROC
20017 -END(\sym)
20018 +ENDPROC(\sym)
20019 .endm
20020
20021 .macro errorentry sym do_sym
20022 @@ -1267,13 +1617,23 @@ ENTRY(\sym)
20023 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
20024 call error_entry
20025 DEFAULT_FRAME 0
20026 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20027 + testb $3, CS(%rsp)
20028 + jnz 1f
20029 + pax_enter_kernel
20030 + jmp 2f
20031 +1: pax_enter_kernel_user
20032 +2:
20033 +#else
20034 + pax_enter_kernel
20035 +#endif
20036 movq %rsp,%rdi /* pt_regs pointer */
20037 movq ORIG_RAX(%rsp),%rsi /* get error code */
20038 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20039 call \do_sym
20040 jmp error_exit /* %ebx: no swapgs flag */
20041 CFI_ENDPROC
20042 -END(\sym)
20043 +ENDPROC(\sym)
20044 .endm
20045
20046 /* error code is on the stack already */
20047 @@ -1287,13 +1647,23 @@ ENTRY(\sym)
20048 call save_paranoid
20049 DEFAULT_FRAME 0
20050 TRACE_IRQS_OFF
20051 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20052 + testb $3, CS(%rsp)
20053 + jnz 1f
20054 + pax_enter_kernel
20055 + jmp 2f
20056 +1: pax_enter_kernel_user
20057 +2:
20058 +#else
20059 + pax_enter_kernel
20060 +#endif
20061 movq %rsp,%rdi /* pt_regs pointer */
20062 movq ORIG_RAX(%rsp),%rsi /* get error code */
20063 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
20064 call \do_sym
20065 jmp paranoid_exit /* %ebx: no swapgs flag */
20066 CFI_ENDPROC
20067 -END(\sym)
20068 +ENDPROC(\sym)
20069 .endm
20070
20071 zeroentry divide_error do_divide_error
20072 @@ -1323,9 +1693,10 @@ gs_change:
20073 2: mfence /* workaround */
20074 SWAPGS
20075 popfq_cfi
20076 + pax_force_retaddr
20077 ret
20078 CFI_ENDPROC
20079 -END(native_load_gs_index)
20080 +ENDPROC(native_load_gs_index)
20081
20082 _ASM_EXTABLE(gs_change,bad_gs)
20083 .section .fixup,"ax"
20084 @@ -1353,9 +1724,10 @@ ENTRY(call_softirq)
20085 CFI_DEF_CFA_REGISTER rsp
20086 CFI_ADJUST_CFA_OFFSET -8
20087 decl PER_CPU_VAR(irq_count)
20088 + pax_force_retaddr
20089 ret
20090 CFI_ENDPROC
20091 -END(call_softirq)
20092 +ENDPROC(call_softirq)
20093
20094 #ifdef CONFIG_XEN
20095 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
20096 @@ -1393,7 +1765,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
20097 decl PER_CPU_VAR(irq_count)
20098 jmp error_exit
20099 CFI_ENDPROC
20100 -END(xen_do_hypervisor_callback)
20101 +ENDPROC(xen_do_hypervisor_callback)
20102
20103 /*
20104 * Hypervisor uses this for application faults while it executes.
20105 @@ -1452,7 +1824,7 @@ ENTRY(xen_failsafe_callback)
20106 SAVE_ALL
20107 jmp error_exit
20108 CFI_ENDPROC
20109 -END(xen_failsafe_callback)
20110 +ENDPROC(xen_failsafe_callback)
20111
20112 apicinterrupt XEN_HVM_EVTCHN_CALLBACK \
20113 xen_hvm_callback_vector xen_evtchn_do_upcall
20114 @@ -1501,16 +1873,31 @@ ENTRY(paranoid_exit)
20115 TRACE_IRQS_OFF_DEBUG
20116 testl %ebx,%ebx /* swapgs needed? */
20117 jnz paranoid_restore
20118 - testl $3,CS(%rsp)
20119 + testb $3,CS(%rsp)
20120 jnz paranoid_userspace
20121 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20122 + pax_exit_kernel
20123 + TRACE_IRQS_IRETQ 0
20124 + SWAPGS_UNSAFE_STACK
20125 + RESTORE_ALL 8
20126 + pax_force_retaddr_bts
20127 + jmp irq_return
20128 +#endif
20129 paranoid_swapgs:
20130 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20131 + pax_exit_kernel_user
20132 +#else
20133 + pax_exit_kernel
20134 +#endif
20135 TRACE_IRQS_IRETQ 0
20136 SWAPGS_UNSAFE_STACK
20137 RESTORE_ALL 8
20138 jmp irq_return
20139 paranoid_restore:
20140 + pax_exit_kernel
20141 TRACE_IRQS_IRETQ_DEBUG 0
20142 RESTORE_ALL 8
20143 + pax_force_retaddr_bts
20144 jmp irq_return
20145 paranoid_userspace:
20146 GET_THREAD_INFO(%rcx)
20147 @@ -1539,7 +1926,7 @@ paranoid_schedule:
20148 TRACE_IRQS_OFF
20149 jmp paranoid_userspace
20150 CFI_ENDPROC
20151 -END(paranoid_exit)
20152 +ENDPROC(paranoid_exit)
20153
20154 /*
20155 * Exception entry point. This expects an error code/orig_rax on the stack.
20156 @@ -1566,12 +1953,13 @@ ENTRY(error_entry)
20157 movq_cfi r14, R14+8
20158 movq_cfi r15, R15+8
20159 xorl %ebx,%ebx
20160 - testl $3,CS+8(%rsp)
20161 + testb $3,CS+8(%rsp)
20162 je error_kernelspace
20163 error_swapgs:
20164 SWAPGS
20165 error_sti:
20166 TRACE_IRQS_OFF
20167 + pax_force_retaddr_bts
20168 ret
20169
20170 /*
20171 @@ -1598,7 +1986,7 @@ bstep_iret:
20172 movq %rcx,RIP+8(%rsp)
20173 jmp error_swapgs
20174 CFI_ENDPROC
20175 -END(error_entry)
20176 +ENDPROC(error_entry)
20177
20178
20179 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
20180 @@ -1618,7 +2006,7 @@ ENTRY(error_exit)
20181 jnz retint_careful
20182 jmp retint_swapgs
20183 CFI_ENDPROC
20184 -END(error_exit)
20185 +ENDPROC(error_exit)
20186
20187 /*
20188 * Test if a given stack is an NMI stack or not.
20189 @@ -1676,9 +2064,11 @@ ENTRY(nmi)
20190 * If %cs was not the kernel segment, then the NMI triggered in user
20191 * space, which means it is definitely not nested.
20192 */
20193 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
20194 + je 1f
20195 cmpl $__KERNEL_CS, 16(%rsp)
20196 jne first_nmi
20197 -
20198 +1:
20199 /*
20200 * Check the special variable on the stack to see if NMIs are
20201 * executing.
20202 @@ -1712,14 +2102,13 @@ nested_nmi:
20203
20204 1:
20205 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
20206 - leaq -1*8(%rsp), %rdx
20207 - movq %rdx, %rsp
20208 + subq $8, %rsp
20209 CFI_ADJUST_CFA_OFFSET 1*8
20210 leaq -10*8(%rsp), %rdx
20211 pushq_cfi $__KERNEL_DS
20212 pushq_cfi %rdx
20213 pushfq_cfi
20214 - pushq_cfi $__KERNEL_CS
20215 + pushq_cfi 6*8(%rsp)
20216 pushq_cfi $repeat_nmi
20217
20218 /* Put stack back */
20219 @@ -1731,6 +2120,7 @@ nested_nmi_out:
20220 CFI_RESTORE rdx
20221
20222 /* No need to check faults here */
20223 + pax_force_retaddr_bts
20224 INTERRUPT_RETURN
20225
20226 CFI_RESTORE_STATE
20227 @@ -1847,6 +2237,17 @@ end_repeat_nmi:
20228 */
20229 movq %cr2, %r12
20230
20231 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20232 + testb $3, CS(%rsp)
20233 + jnz 1f
20234 + pax_enter_kernel
20235 + jmp 2f
20236 +1: pax_enter_kernel_user
20237 +2:
20238 +#else
20239 + pax_enter_kernel
20240 +#endif
20241 +
20242 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
20243 movq %rsp,%rdi
20244 movq $-1,%rsi
20245 @@ -1862,23 +2263,34 @@ end_repeat_nmi:
20246 testl %ebx,%ebx /* swapgs needed? */
20247 jnz nmi_restore
20248 nmi_swapgs:
20249 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20250 + pax_exit_kernel_user
20251 +#else
20252 + pax_exit_kernel
20253 +#endif
20254 SWAPGS_UNSAFE_STACK
20255 + RESTORE_ALL 6*8
20256 + /* Clear the NMI executing stack variable */
20257 + movq $0, 5*8(%rsp)
20258 + jmp irq_return
20259 nmi_restore:
20260 + pax_exit_kernel
20261 /* Pop the extra iret frame at once */
20262 RESTORE_ALL 6*8
20263 + pax_force_retaddr_bts
20264
20265 /* Clear the NMI executing stack variable */
20266 movq $0, 5*8(%rsp)
20267 jmp irq_return
20268 CFI_ENDPROC
20269 -END(nmi)
20270 +ENDPROC(nmi)
20271
20272 ENTRY(ignore_sysret)
20273 CFI_STARTPROC
20274 mov $-ENOSYS,%eax
20275 sysret
20276 CFI_ENDPROC
20277 -END(ignore_sysret)
20278 +ENDPROC(ignore_sysret)
20279
20280 /*
20281 * End of kprobes section
20282 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20283 index 1d41402..af9a46a 100644
20284 --- a/arch/x86/kernel/ftrace.c
20285 +++ b/arch/x86/kernel/ftrace.c
20286 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20287 {
20288 unsigned char replaced[MCOUNT_INSN_SIZE];
20289
20290 + ip = ktla_ktva(ip);
20291 +
20292 /*
20293 * Note: Due to modules and __init, code can
20294 * disappear and change, we need to protect against faulting
20295 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20296 unsigned char old[MCOUNT_INSN_SIZE], *new;
20297 int ret;
20298
20299 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20300 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20301 new = ftrace_call_replace(ip, (unsigned long)func);
20302
20303 /* See comment above by declaration of modifying_ftrace_code */
20304 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20305 /* Also update the regs callback function */
20306 if (!ret) {
20307 ip = (unsigned long)(&ftrace_regs_call);
20308 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20309 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20310 new = ftrace_call_replace(ip, (unsigned long)func);
20311 ret = ftrace_modify_code(ip, old, new);
20312 }
20313 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20314 * kernel identity mapping to modify code.
20315 */
20316 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20317 - ip = (unsigned long)__va(__pa(ip));
20318 + ip = (unsigned long)__va(__pa(ktla_ktva(ip)));
20319
20320 return probe_kernel_write((void *)ip, val, size);
20321 }
20322 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20323 unsigned char replaced[MCOUNT_INSN_SIZE];
20324 unsigned char brk = BREAKPOINT_INSTRUCTION;
20325
20326 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20327 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20328 return -EFAULT;
20329
20330 /* Make sure it is what we expect it to be */
20331 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20332 return ret;
20333
20334 fail_update:
20335 - probe_kernel_write((void *)ip, &old_code[0], 1);
20336 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20337 goto out;
20338 }
20339
20340 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20341 {
20342 unsigned char code[MCOUNT_INSN_SIZE];
20343
20344 + ip = ktla_ktva(ip);
20345 +
20346 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20347 return -EFAULT;
20348
20349 diff --git a/arch/x86/kernel/head32.c b/arch/x86/kernel/head32.c
20350 index c18f59d..9c0c9f6 100644
20351 --- a/arch/x86/kernel/head32.c
20352 +++ b/arch/x86/kernel/head32.c
20353 @@ -18,6 +18,7 @@
20354 #include <asm/io_apic.h>
20355 #include <asm/bios_ebda.h>
20356 #include <asm/tlbflush.h>
20357 +#include <asm/boot.h>
20358
20359 static void __init i386_default_early_setup(void)
20360 {
20361 @@ -30,8 +31,7 @@ static void __init i386_default_early_setup(void)
20362
20363 void __init i386_start_kernel(void)
20364 {
20365 - memblock_reserve(__pa_symbol(&_text),
20366 - __pa_symbol(&__bss_stop) - __pa_symbol(&_text));
20367 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(&__bss_stop) - LOAD_PHYSICAL_ADDR);
20368
20369 #ifdef CONFIG_BLK_DEV_INITRD
20370 /* Reserve INITRD */
20371 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20372 index c8932c7..d56b622 100644
20373 --- a/arch/x86/kernel/head_32.S
20374 +++ b/arch/x86/kernel/head_32.S
20375 @@ -26,6 +26,12 @@
20376 /* Physical address */
20377 #define pa(X) ((X) - __PAGE_OFFSET)
20378
20379 +#ifdef CONFIG_PAX_KERNEXEC
20380 +#define ta(X) (X)
20381 +#else
20382 +#define ta(X) ((X) - __PAGE_OFFSET)
20383 +#endif
20384 +
20385 /*
20386 * References to members of the new_cpu_data structure.
20387 */
20388 @@ -55,11 +61,7 @@
20389 * and small than max_low_pfn, otherwise will waste some page table entries
20390 */
20391
20392 -#if PTRS_PER_PMD > 1
20393 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20394 -#else
20395 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20396 -#endif
20397 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20398
20399 /* Number of possible pages in the lowmem region */
20400 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20401 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20402 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20403
20404 /*
20405 + * Real beginning of normal "text" segment
20406 + */
20407 +ENTRY(stext)
20408 +ENTRY(_stext)
20409 +
20410 +/*
20411 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20412 * %esi points to the real-mode code as a 32-bit pointer.
20413 * CS and DS must be 4 GB flat segments, but we don't depend on
20414 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20415 * can.
20416 */
20417 __HEAD
20418 +
20419 +#ifdef CONFIG_PAX_KERNEXEC
20420 + jmp startup_32
20421 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20422 +.fill PAGE_SIZE-5,1,0xcc
20423 +#endif
20424 +
20425 ENTRY(startup_32)
20426 movl pa(stack_start),%ecx
20427
20428 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20429 2:
20430 leal -__PAGE_OFFSET(%ecx),%esp
20431
20432 +#ifdef CONFIG_SMP
20433 + movl $pa(cpu_gdt_table),%edi
20434 + movl $__per_cpu_load,%eax
20435 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20436 + rorl $16,%eax
20437 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20438 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20439 + movl $__per_cpu_end - 1,%eax
20440 + subl $__per_cpu_start,%eax
20441 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20442 +#endif
20443 +
20444 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20445 + movl $NR_CPUS,%ecx
20446 + movl $pa(cpu_gdt_table),%edi
20447 +1:
20448 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20449 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20450 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20451 + addl $PAGE_SIZE_asm,%edi
20452 + loop 1b
20453 +#endif
20454 +
20455 +#ifdef CONFIG_PAX_KERNEXEC
20456 + movl $pa(boot_gdt),%edi
20457 + movl $__LOAD_PHYSICAL_ADDR,%eax
20458 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20459 + rorl $16,%eax
20460 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20461 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20462 + rorl $16,%eax
20463 +
20464 + ljmp $(__BOOT_CS),$1f
20465 +1:
20466 +
20467 + movl $NR_CPUS,%ecx
20468 + movl $pa(cpu_gdt_table),%edi
20469 + addl $__PAGE_OFFSET,%eax
20470 +1:
20471 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20472 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20473 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20474 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20475 + rorl $16,%eax
20476 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20477 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20478 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20479 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20480 + rorl $16,%eax
20481 + addl $PAGE_SIZE_asm,%edi
20482 + loop 1b
20483 +#endif
20484 +
20485 /*
20486 * Clear BSS first so that there are no surprises...
20487 */
20488 @@ -196,8 +264,11 @@ ENTRY(startup_32)
20489 movl %eax, pa(max_pfn_mapped)
20490
20491 /* Do early initialization of the fixmap area */
20492 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20493 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20494 +#ifdef CONFIG_COMPAT_VDSO
20495 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20496 +#else
20497 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20498 +#endif
20499 #else /* Not PAE */
20500
20501 page_pde_offset = (__PAGE_OFFSET >> 20);
20502 @@ -227,8 +298,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20503 movl %eax, pa(max_pfn_mapped)
20504
20505 /* Do early initialization of the fixmap area */
20506 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20507 - movl %eax,pa(initial_page_table+0xffc)
20508 +#ifdef CONFIG_COMPAT_VDSO
20509 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20510 +#else
20511 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20512 +#endif
20513 #endif
20514
20515 #ifdef CONFIG_PARAVIRT
20516 @@ -242,9 +316,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20517 cmpl $num_subarch_entries, %eax
20518 jae bad_subarch
20519
20520 - movl pa(subarch_entries)(,%eax,4), %eax
20521 - subl $__PAGE_OFFSET, %eax
20522 - jmp *%eax
20523 + jmp *pa(subarch_entries)(,%eax,4)
20524
20525 bad_subarch:
20526 WEAK(lguest_entry)
20527 @@ -256,10 +328,10 @@ WEAK(xen_entry)
20528 __INITDATA
20529
20530 subarch_entries:
20531 - .long default_entry /* normal x86/PC */
20532 - .long lguest_entry /* lguest hypervisor */
20533 - .long xen_entry /* Xen hypervisor */
20534 - .long default_entry /* Moorestown MID */
20535 + .long ta(default_entry) /* normal x86/PC */
20536 + .long ta(lguest_entry) /* lguest hypervisor */
20537 + .long ta(xen_entry) /* Xen hypervisor */
20538 + .long ta(default_entry) /* Moorestown MID */
20539 num_subarch_entries = (. - subarch_entries) / 4
20540 .previous
20541 #else
20542 @@ -335,6 +407,7 @@ default_entry:
20543 movl pa(mmu_cr4_features),%eax
20544 movl %eax,%cr4
20545
20546 +#ifdef CONFIG_X86_PAE
20547 testb $X86_CR4_PAE, %al # check if PAE is enabled
20548 jz 6f
20549
20550 @@ -363,6 +436,9 @@ default_entry:
20551 /* Make changes effective */
20552 wrmsr
20553
20554 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20555 +#endif
20556 +
20557 6:
20558
20559 /*
20560 @@ -460,14 +536,20 @@ is386: movl $2,%ecx # set MP
20561 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20562 movl %eax,%ss # after changing gdt.
20563
20564 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20565 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20566 movl %eax,%ds
20567 movl %eax,%es
20568
20569 movl $(__KERNEL_PERCPU), %eax
20570 movl %eax,%fs # set this cpu's percpu
20571
20572 +#ifdef CONFIG_CC_STACKPROTECTOR
20573 movl $(__KERNEL_STACK_CANARY),%eax
20574 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20575 + movl $(__USER_DS),%eax
20576 +#else
20577 + xorl %eax,%eax
20578 +#endif
20579 movl %eax,%gs
20580
20581 xorl %eax,%eax # Clear LDT
20582 @@ -544,8 +626,11 @@ setup_once:
20583 * relocation. Manually set base address in stack canary
20584 * segment descriptor.
20585 */
20586 - movl $gdt_page,%eax
20587 + movl $cpu_gdt_table,%eax
20588 movl $stack_canary,%ecx
20589 +#ifdef CONFIG_SMP
20590 + addl $__per_cpu_load,%ecx
20591 +#endif
20592 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20593 shrl $16, %ecx
20594 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20595 @@ -576,7 +661,7 @@ ENDPROC(early_idt_handlers)
20596 /* This is global to keep gas from relaxing the jumps */
20597 ENTRY(early_idt_handler)
20598 cld
20599 - cmpl $2,%ss:early_recursion_flag
20600 + cmpl $1,%ss:early_recursion_flag
20601 je hlt_loop
20602 incl %ss:early_recursion_flag
20603
20604 @@ -614,8 +699,8 @@ ENTRY(early_idt_handler)
20605 pushl (20+6*4)(%esp) /* trapno */
20606 pushl $fault_msg
20607 call printk
20608 -#endif
20609 call dump_stack
20610 +#endif
20611 hlt_loop:
20612 hlt
20613 jmp hlt_loop
20614 @@ -634,8 +719,11 @@ ENDPROC(early_idt_handler)
20615 /* This is the default interrupt "handler" :-) */
20616 ALIGN
20617 ignore_int:
20618 - cld
20619 #ifdef CONFIG_PRINTK
20620 + cmpl $2,%ss:early_recursion_flag
20621 + je hlt_loop
20622 + incl %ss:early_recursion_flag
20623 + cld
20624 pushl %eax
20625 pushl %ecx
20626 pushl %edx
20627 @@ -644,9 +732,6 @@ ignore_int:
20628 movl $(__KERNEL_DS),%eax
20629 movl %eax,%ds
20630 movl %eax,%es
20631 - cmpl $2,early_recursion_flag
20632 - je hlt_loop
20633 - incl early_recursion_flag
20634 pushl 16(%esp)
20635 pushl 24(%esp)
20636 pushl 32(%esp)
20637 @@ -680,29 +765,43 @@ ENTRY(setup_once_ref)
20638 /*
20639 * BSS section
20640 */
20641 -__PAGE_ALIGNED_BSS
20642 - .align PAGE_SIZE
20643 #ifdef CONFIG_X86_PAE
20644 +.section .initial_pg_pmd,"a",@progbits
20645 initial_pg_pmd:
20646 .fill 1024*KPMDS,4,0
20647 #else
20648 +.section .initial_page_table,"a",@progbits
20649 ENTRY(initial_page_table)
20650 .fill 1024,4,0
20651 #endif
20652 +.section .initial_pg_fixmap,"a",@progbits
20653 initial_pg_fixmap:
20654 .fill 1024,4,0
20655 +.section .empty_zero_page,"a",@progbits
20656 ENTRY(empty_zero_page)
20657 .fill 4096,1,0
20658 +.section .swapper_pg_dir,"a",@progbits
20659 ENTRY(swapper_pg_dir)
20660 +#ifdef CONFIG_X86_PAE
20661 + .fill 4,8,0
20662 +#else
20663 .fill 1024,4,0
20664 +#endif
20665 +
20666 +/*
20667 + * The IDT has to be page-aligned to simplify the Pentium
20668 + * F0 0F bug workaround.. We have a special link segment
20669 + * for this.
20670 + */
20671 +.section .idt,"a",@progbits
20672 +ENTRY(idt_table)
20673 + .fill 256,8,0
20674
20675 /*
20676 * This starts the data section.
20677 */
20678 #ifdef CONFIG_X86_PAE
20679 -__PAGE_ALIGNED_DATA
20680 - /* Page-aligned for the benefit of paravirt? */
20681 - .align PAGE_SIZE
20682 +.section .initial_page_table,"a",@progbits
20683 ENTRY(initial_page_table)
20684 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20685 # if KPMDS == 3
20686 @@ -721,12 +820,20 @@ ENTRY(initial_page_table)
20687 # error "Kernel PMDs should be 1, 2 or 3"
20688 # endif
20689 .align PAGE_SIZE /* needs to be page-sized too */
20690 +
20691 +#ifdef CONFIG_PAX_PER_CPU_PGD
20692 +ENTRY(cpu_pgd)
20693 + .rept NR_CPUS
20694 + .fill 4,8,0
20695 + .endr
20696 +#endif
20697 +
20698 #endif
20699
20700 .data
20701 .balign 4
20702 ENTRY(stack_start)
20703 - .long init_thread_union+THREAD_SIZE
20704 + .long init_thread_union+THREAD_SIZE-8
20705
20706 __INITRODATA
20707 int_msg:
20708 @@ -754,7 +861,7 @@ fault_msg:
20709 * segment size, and 32-bit linear address value:
20710 */
20711
20712 - .data
20713 +.section .rodata,"a",@progbits
20714 .globl boot_gdt_descr
20715 .globl idt_descr
20716
20717 @@ -763,7 +870,7 @@ fault_msg:
20718 .word 0 # 32 bit align gdt_desc.address
20719 boot_gdt_descr:
20720 .word __BOOT_DS+7
20721 - .long boot_gdt - __PAGE_OFFSET
20722 + .long pa(boot_gdt)
20723
20724 .word 0 # 32-bit align idt_desc.address
20725 idt_descr:
20726 @@ -774,7 +881,7 @@ idt_descr:
20727 .word 0 # 32 bit align gdt_desc.address
20728 ENTRY(early_gdt_descr)
20729 .word GDT_ENTRIES*8-1
20730 - .long gdt_page /* Overwritten for secondary CPUs */
20731 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20732
20733 /*
20734 * The boot_gdt must mirror the equivalent in setup.S and is
20735 @@ -783,5 +890,65 @@ ENTRY(early_gdt_descr)
20736 .align L1_CACHE_BYTES
20737 ENTRY(boot_gdt)
20738 .fill GDT_ENTRY_BOOT_CS,8,0
20739 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20740 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20741 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20742 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20743 +
20744 + .align PAGE_SIZE_asm
20745 +ENTRY(cpu_gdt_table)
20746 + .rept NR_CPUS
20747 + .quad 0x0000000000000000 /* NULL descriptor */
20748 + .quad 0x0000000000000000 /* 0x0b reserved */
20749 + .quad 0x0000000000000000 /* 0x13 reserved */
20750 + .quad 0x0000000000000000 /* 0x1b reserved */
20751 +
20752 +#ifdef CONFIG_PAX_KERNEXEC
20753 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20754 +#else
20755 + .quad 0x0000000000000000 /* 0x20 unused */
20756 +#endif
20757 +
20758 + .quad 0x0000000000000000 /* 0x28 unused */
20759 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20760 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20761 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20762 + .quad 0x0000000000000000 /* 0x4b reserved */
20763 + .quad 0x0000000000000000 /* 0x53 reserved */
20764 + .quad 0x0000000000000000 /* 0x5b reserved */
20765 +
20766 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20767 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20768 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20769 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20770 +
20771 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20772 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20773 +
20774 + /*
20775 + * Segments used for calling PnP BIOS have byte granularity.
20776 + * The code segments and data segments have fixed 64k limits,
20777 + * the transfer segment sizes are set at run time.
20778 + */
20779 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20780 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20781 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20782 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20783 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20784 +
20785 + /*
20786 + * The APM segments have byte granularity and their bases
20787 + * are set at run time. All have 64k limits.
20788 + */
20789 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20790 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20791 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20792 +
20793 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20794 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20795 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20796 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20797 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20798 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20799 +
20800 + /* Be sure this is zeroed to avoid false validations in Xen */
20801 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20802 + .endr
20803 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20804 index 980053c..74d3b44 100644
20805 --- a/arch/x86/kernel/head_64.S
20806 +++ b/arch/x86/kernel/head_64.S
20807 @@ -20,6 +20,8 @@
20808 #include <asm/processor-flags.h>
20809 #include <asm/percpu.h>
20810 #include <asm/nops.h>
20811 +#include <asm/cpufeature.h>
20812 +#include <asm/alternative-asm.h>
20813
20814 #ifdef CONFIG_PARAVIRT
20815 #include <asm/asm-offsets.h>
20816 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20817 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20818 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20819 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20820 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20821 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20822 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20823 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20824 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20825 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20826
20827 .text
20828 __HEAD
20829 @@ -88,35 +96,23 @@ startup_64:
20830 */
20831 addq %rbp, init_level4_pgt + 0(%rip)
20832 addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20833 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20834 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20835 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20836 addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20837
20838 addq %rbp, level3_ident_pgt + 0(%rip)
20839 +#ifndef CONFIG_XEN
20840 + addq %rbp, level3_ident_pgt + 8(%rip)
20841 +#endif
20842
20843 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20844 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20845 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20846 +
20847 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20848 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8+8)(%rip)
20849
20850 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20851 -
20852 - /* Add an Identity mapping if I am above 1G */
20853 - leaq _text(%rip), %rdi
20854 - andq $PMD_PAGE_MASK, %rdi
20855 -
20856 - movq %rdi, %rax
20857 - shrq $PUD_SHIFT, %rax
20858 - andq $(PTRS_PER_PUD - 1), %rax
20859 - jz ident_complete
20860 -
20861 - leaq (level2_spare_pgt - __START_KERNEL_map + _KERNPG_TABLE)(%rbp), %rdx
20862 - leaq level3_ident_pgt(%rip), %rbx
20863 - movq %rdx, 0(%rbx, %rax, 8)
20864 -
20865 - movq %rdi, %rax
20866 - shrq $PMD_SHIFT, %rax
20867 - andq $(PTRS_PER_PMD - 1), %rax
20868 - leaq __PAGE_KERNEL_IDENT_LARGE_EXEC(%rdi), %rdx
20869 - leaq level2_spare_pgt(%rip), %rbx
20870 - movq %rdx, 0(%rbx, %rax, 8)
20871 -ident_complete:
20872 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20873
20874 /*
20875 * Fixup the kernel text+data virtual addresses. Note that
20876 @@ -159,8 +155,8 @@ ENTRY(secondary_startup_64)
20877 * after the boot processor executes this code.
20878 */
20879
20880 - /* Enable PAE mode and PGE */
20881 - movl $(X86_CR4_PAE | X86_CR4_PGE), %eax
20882 + /* Enable PAE mode and PSE/PGE */
20883 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %eax
20884 movq %rax, %cr4
20885
20886 /* Setup early boot stage 4 level pagetables. */
20887 @@ -182,9 +178,17 @@ ENTRY(secondary_startup_64)
20888 movl $MSR_EFER, %ecx
20889 rdmsr
20890 btsl $_EFER_SCE, %eax /* Enable System Call */
20891 - btl $20,%edi /* No Execute supported? */
20892 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20893 jnc 1f
20894 btsl $_EFER_NX, %eax
20895 + leaq init_level4_pgt(%rip), %rdi
20896 +#ifndef CONFIG_EFI
20897 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20898 +#endif
20899 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20900 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20901 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20902 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20903 1: wrmsr /* Make changes effective */
20904
20905 /* Setup cr0 */
20906 @@ -246,6 +250,7 @@ ENTRY(secondary_startup_64)
20907 * jump. In addition we need to ensure %cs is set so we make this
20908 * a far return.
20909 */
20910 + pax_set_fptr_mask
20911 movq initial_code(%rip),%rax
20912 pushq $0 # fake return address to stop unwinder
20913 pushq $__KERNEL_CS # set correct cs
20914 @@ -284,7 +289,7 @@ ENDPROC(start_cpu0)
20915 bad_address:
20916 jmp bad_address
20917
20918 - .section ".init.text","ax"
20919 + __INIT
20920 .globl early_idt_handlers
20921 early_idt_handlers:
20922 # 104(%rsp) %rflags
20923 @@ -343,7 +348,7 @@ ENTRY(early_idt_handler)
20924 call dump_stack
20925 #ifdef CONFIG_KALLSYMS
20926 leaq early_idt_ripmsg(%rip),%rdi
20927 - movq 40(%rsp),%rsi # %rip again
20928 + movq 88(%rsp),%rsi # %rip again
20929 call __print_symbol
20930 #endif
20931 #endif /* EARLY_PRINTK */
20932 @@ -363,11 +368,15 @@ ENTRY(early_idt_handler)
20933 addq $16,%rsp # drop vector number and error code
20934 decl early_recursion_flag(%rip)
20935 INTERRUPT_RETURN
20936 + .previous
20937
20938 + __INITDATA
20939 .balign 4
20940 early_recursion_flag:
20941 .long 0
20942 + .previous
20943
20944 + .section .rodata,"a",@progbits
20945 #ifdef CONFIG_EARLY_PRINTK
20946 early_idt_msg:
20947 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20948 @@ -376,6 +385,7 @@ early_idt_ripmsg:
20949 #endif /* CONFIG_EARLY_PRINTK */
20950 .previous
20951
20952 + .section .rodata,"a",@progbits
20953 #define NEXT_PAGE(name) \
20954 .balign PAGE_SIZE; \
20955 ENTRY(name)
20956 @@ -388,7 +398,6 @@ ENTRY(name)
20957 i = i + 1 ; \
20958 .endr
20959
20960 - .data
20961 /*
20962 * This default setting generates an ident mapping at address 0x100000
20963 * and a mapping for the kernel that precisely maps virtual address
20964 @@ -399,13 +408,41 @@ NEXT_PAGE(init_level4_pgt)
20965 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20966 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20967 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20968 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20969 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20970 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20971 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20972 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20973 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20974 .org init_level4_pgt + L4_START_KERNEL*8, 0
20975 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20976 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20977
20978 +#ifdef CONFIG_PAX_PER_CPU_PGD
20979 +NEXT_PAGE(cpu_pgd)
20980 + .rept NR_CPUS
20981 + .fill 512,8,0
20982 + .endr
20983 +#endif
20984 +
20985 NEXT_PAGE(level3_ident_pgt)
20986 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20987 +#ifdef CONFIG_XEN
20988 .fill 511,8,0
20989 +#else
20990 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20991 + .fill 510,8,0
20992 +#endif
20993 +
20994 +NEXT_PAGE(level3_vmalloc_start_pgt)
20995 + .fill 512,8,0
20996 +
20997 +NEXT_PAGE(level3_vmalloc_end_pgt)
20998 + .fill 512,8,0
20999 +
21000 +NEXT_PAGE(level3_vmemmap_pgt)
21001 + .fill L3_VMEMMAP_START,8,0
21002 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
21003
21004 NEXT_PAGE(level3_kernel_pgt)
21005 .fill L3_START_KERNEL,8,0
21006 @@ -413,20 +450,23 @@ NEXT_PAGE(level3_kernel_pgt)
21007 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
21008 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21009
21010 +NEXT_PAGE(level2_vmemmap_pgt)
21011 + .fill 512,8,0
21012 +
21013 NEXT_PAGE(level2_fixmap_pgt)
21014 - .fill 506,8,0
21015 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
21016 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
21017 - .fill 5,8,0
21018 + .fill 507,8,0
21019 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
21020 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
21021 + .fill 4,8,0
21022
21023 -NEXT_PAGE(level1_fixmap_pgt)
21024 +NEXT_PAGE(level1_vsyscall_pgt)
21025 .fill 512,8,0
21026
21027 -NEXT_PAGE(level2_ident_pgt)
21028 - /* Since I easily can, map the first 1G.
21029 + /* Since I easily can, map the first 2G.
21030 * Don't set NX because code runs from these pages.
21031 */
21032 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
21033 +NEXT_PAGE(level2_ident_pgt)
21034 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
21035
21036 NEXT_PAGE(level2_kernel_pgt)
21037 /*
21038 @@ -439,37 +479,59 @@ NEXT_PAGE(level2_kernel_pgt)
21039 * If you want to increase this then increase MODULES_VADDR
21040 * too.)
21041 */
21042 - PMDS(0, __PAGE_KERNEL_LARGE_EXEC,
21043 - KERNEL_IMAGE_SIZE/PMD_SIZE)
21044 -
21045 -NEXT_PAGE(level2_spare_pgt)
21046 - .fill 512, 8, 0
21047 + PMDS(0, __PAGE_KERNEL_LARGE_EXEC, KERNEL_IMAGE_SIZE/PMD_SIZE)
21048
21049 #undef PMDS
21050 #undef NEXT_PAGE
21051
21052 - .data
21053 + .align PAGE_SIZE
21054 +ENTRY(cpu_gdt_table)
21055 + .rept NR_CPUS
21056 + .quad 0x0000000000000000 /* NULL descriptor */
21057 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
21058 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
21059 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
21060 + .quad 0x00cffb000000ffff /* __USER32_CS */
21061 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
21062 + .quad 0x00affb000000ffff /* __USER_CS */
21063 +
21064 +#ifdef CONFIG_PAX_KERNEXEC
21065 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
21066 +#else
21067 + .quad 0x0 /* unused */
21068 +#endif
21069 +
21070 + .quad 0,0 /* TSS */
21071 + .quad 0,0 /* LDT */
21072 + .quad 0,0,0 /* three TLS descriptors */
21073 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
21074 + /* asm/segment.h:GDT_ENTRIES must match this */
21075 +
21076 + /* zero the remaining page */
21077 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
21078 + .endr
21079 +
21080 .align 16
21081 .globl early_gdt_descr
21082 early_gdt_descr:
21083 .word GDT_ENTRIES*8-1
21084 early_gdt_descr_base:
21085 - .quad INIT_PER_CPU_VAR(gdt_page)
21086 + .quad cpu_gdt_table
21087
21088 ENTRY(phys_base)
21089 /* This must match the first entry in level2_kernel_pgt */
21090 .quad 0x0000000000000000
21091
21092 #include "../../x86/xen/xen-head.S"
21093 -
21094 - .section .bss, "aw", @nobits
21095 +
21096 + .section .rodata,"a",@progbits
21097 .align L1_CACHE_BYTES
21098 ENTRY(idt_table)
21099 - .skip IDT_ENTRIES * 16
21100 + .fill 512,8,0
21101
21102 .align L1_CACHE_BYTES
21103 ENTRY(nmi_idt_table)
21104 - .skip IDT_ENTRIES * 16
21105 + .fill 512,8,0
21106
21107 __PAGE_ALIGNED_BSS
21108 .align PAGE_SIZE
21109 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
21110 index 9c3bd4a..e1d9b35 100644
21111 --- a/arch/x86/kernel/i386_ksyms_32.c
21112 +++ b/arch/x86/kernel/i386_ksyms_32.c
21113 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
21114 EXPORT_SYMBOL(cmpxchg8b_emu);
21115 #endif
21116
21117 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
21118 +
21119 /* Networking helper routines. */
21120 EXPORT_SYMBOL(csum_partial_copy_generic);
21121 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
21122 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
21123
21124 EXPORT_SYMBOL(__get_user_1);
21125 EXPORT_SYMBOL(__get_user_2);
21126 @@ -36,3 +40,7 @@ EXPORT_SYMBOL(strstr);
21127
21128 EXPORT_SYMBOL(csum_partial);
21129 EXPORT_SYMBOL(empty_zero_page);
21130 +
21131 +#ifdef CONFIG_PAX_KERNEXEC
21132 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
21133 +#endif
21134 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
21135 index 245a71d..89d9ce4 100644
21136 --- a/arch/x86/kernel/i387.c
21137 +++ b/arch/x86/kernel/i387.c
21138 @@ -55,7 +55,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
21139 static inline bool interrupted_user_mode(void)
21140 {
21141 struct pt_regs *regs = get_irq_regs();
21142 - return regs && user_mode_vm(regs);
21143 + return regs && user_mode(regs);
21144 }
21145
21146 /*
21147 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
21148 index 9a5c460..b332a4b 100644
21149 --- a/arch/x86/kernel/i8259.c
21150 +++ b/arch/x86/kernel/i8259.c
21151 @@ -209,7 +209,7 @@ spurious_8259A_irq:
21152 "spurious 8259A interrupt: IRQ%d.\n", irq);
21153 spurious_irq_mask |= irqmask;
21154 }
21155 - atomic_inc(&irq_err_count);
21156 + atomic_inc_unchecked(&irq_err_count);
21157 /*
21158 * Theoretically we do not have to handle this IRQ,
21159 * but in Linux this does not cause problems and is
21160 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
21161 /* (slave's support for AEOI in flat mode is to be investigated) */
21162 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
21163
21164 + pax_open_kernel();
21165 if (auto_eoi)
21166 /*
21167 * In AEOI mode we just have to mask the interrupt
21168 * when acking.
21169 */
21170 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
21171 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
21172 else
21173 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21174 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
21175 + pax_close_kernel();
21176
21177 udelay(100); /* wait for 8259A to initialize */
21178
21179 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
21180 index a979b5b..1d6db75 100644
21181 --- a/arch/x86/kernel/io_delay.c
21182 +++ b/arch/x86/kernel/io_delay.c
21183 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
21184 * Quirk table for systems that misbehave (lock up, etc.) if port
21185 * 0x80 is used:
21186 */
21187 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
21188 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
21189 {
21190 .callback = dmi_io_delay_0xed_port,
21191 .ident = "Compaq Presario V6000",
21192 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
21193 index 8c96897..be66bfa 100644
21194 --- a/arch/x86/kernel/ioport.c
21195 +++ b/arch/x86/kernel/ioport.c
21196 @@ -6,6 +6,7 @@
21197 #include <linux/sched.h>
21198 #include <linux/kernel.h>
21199 #include <linux/capability.h>
21200 +#include <linux/security.h>
21201 #include <linux/errno.h>
21202 #include <linux/types.h>
21203 #include <linux/ioport.h>
21204 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21205
21206 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
21207 return -EINVAL;
21208 +#ifdef CONFIG_GRKERNSEC_IO
21209 + if (turn_on && grsec_disable_privio) {
21210 + gr_handle_ioperm();
21211 + return -EPERM;
21212 + }
21213 +#endif
21214 if (turn_on && !capable(CAP_SYS_RAWIO))
21215 return -EPERM;
21216
21217 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
21218 * because the ->io_bitmap_max value must match the bitmap
21219 * contents:
21220 */
21221 - tss = &per_cpu(init_tss, get_cpu());
21222 + tss = init_tss + get_cpu();
21223
21224 if (turn_on)
21225 bitmap_clear(t->io_bitmap_ptr, from, num);
21226 @@ -102,6 +109,12 @@ long sys_iopl(unsigned int level, struct pt_regs *regs)
21227 return -EINVAL;
21228 /* Trying to gain more privileges? */
21229 if (level > old) {
21230 +#ifdef CONFIG_GRKERNSEC_IO
21231 + if (grsec_disable_privio) {
21232 + gr_handle_iopl();
21233 + return -EPERM;
21234 + }
21235 +#endif
21236 if (!capable(CAP_SYS_RAWIO))
21237 return -EPERM;
21238 }
21239 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
21240 index e4595f1..ee3bfb8 100644
21241 --- a/arch/x86/kernel/irq.c
21242 +++ b/arch/x86/kernel/irq.c
21243 @@ -18,7 +18,7 @@
21244 #include <asm/mce.h>
21245 #include <asm/hw_irq.h>
21246
21247 -atomic_t irq_err_count;
21248 +atomic_unchecked_t irq_err_count;
21249
21250 /* Function pointer for generic interrupt vector handling */
21251 void (*x86_platform_ipi_callback)(void) = NULL;
21252 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
21253 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
21254 seq_printf(p, " Machine check polls\n");
21255 #endif
21256 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
21257 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
21258 #if defined(CONFIG_X86_IO_APIC)
21259 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
21260 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
21261 #endif
21262 return 0;
21263 }
21264 @@ -164,10 +164,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
21265
21266 u64 arch_irq_stat(void)
21267 {
21268 - u64 sum = atomic_read(&irq_err_count);
21269 + u64 sum = atomic_read_unchecked(&irq_err_count);
21270
21271 #ifdef CONFIG_X86_IO_APIC
21272 - sum += atomic_read(&irq_mis_count);
21273 + sum += atomic_read_unchecked(&irq_mis_count);
21274 #endif
21275 return sum;
21276 }
21277 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
21278 index 344faf8..355f60d 100644
21279 --- a/arch/x86/kernel/irq_32.c
21280 +++ b/arch/x86/kernel/irq_32.c
21281 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
21282 __asm__ __volatile__("andl %%esp,%0" :
21283 "=r" (sp) : "0" (THREAD_SIZE - 1));
21284
21285 - return sp < (sizeof(struct thread_info) + STACK_WARN);
21286 + return sp < STACK_WARN;
21287 }
21288
21289 static void print_stack_overflow(void)
21290 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21291 * per-CPU IRQ handling contexts (thread information and stack)
21292 */
21293 union irq_ctx {
21294 - struct thread_info tinfo;
21295 - u32 stack[THREAD_SIZE/sizeof(u32)];
21296 + unsigned long previous_esp;
21297 + u32 stack[THREAD_SIZE/sizeof(u32)];
21298 } __attribute__((aligned(THREAD_SIZE)));
21299
21300 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21301 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21302 static inline int
21303 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21304 {
21305 - union irq_ctx *curctx, *irqctx;
21306 + union irq_ctx *irqctx;
21307 u32 *isp, arg1, arg2;
21308
21309 - curctx = (union irq_ctx *) current_thread_info();
21310 irqctx = __this_cpu_read(hardirq_ctx);
21311
21312 /*
21313 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21314 * handler) we can't do that and just have to keep using the
21315 * current stack (which is the irq stack already after all)
21316 */
21317 - if (unlikely(curctx == irqctx))
21318 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21319 return 0;
21320
21321 /* build the stack frame on the IRQ stack */
21322 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21323 - irqctx->tinfo.task = curctx->tinfo.task;
21324 - irqctx->tinfo.previous_esp = current_stack_pointer;
21325 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21326 + irqctx->previous_esp = current_stack_pointer;
21327
21328 - /* Copy the preempt_count so that the [soft]irq checks work. */
21329 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21330 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21331 + __set_fs(MAKE_MM_SEG(0));
21332 +#endif
21333
21334 if (unlikely(overflow))
21335 call_on_stack(print_stack_overflow, isp);
21336 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21337 : "0" (irq), "1" (desc), "2" (isp),
21338 "D" (desc->handle_irq)
21339 : "memory", "cc", "ecx");
21340 +
21341 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21342 + __set_fs(current_thread_info()->addr_limit);
21343 +#endif
21344 +
21345 return 1;
21346 }
21347
21348 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21349 */
21350 void __cpuinit irq_ctx_init(int cpu)
21351 {
21352 - union irq_ctx *irqctx;
21353 -
21354 if (per_cpu(hardirq_ctx, cpu))
21355 return;
21356
21357 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21358 - THREADINFO_GFP,
21359 - THREAD_SIZE_ORDER));
21360 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21361 - irqctx->tinfo.cpu = cpu;
21362 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21363 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21364 -
21365 - per_cpu(hardirq_ctx, cpu) = irqctx;
21366 -
21367 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21368 - THREADINFO_GFP,
21369 - THREAD_SIZE_ORDER));
21370 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21371 - irqctx->tinfo.cpu = cpu;
21372 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21373 -
21374 - per_cpu(softirq_ctx, cpu) = irqctx;
21375 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21376 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21377 +
21378 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21379 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21380
21381 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21382 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21383 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21384 asmlinkage void do_softirq(void)
21385 {
21386 unsigned long flags;
21387 - struct thread_info *curctx;
21388 union irq_ctx *irqctx;
21389 u32 *isp;
21390
21391 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21392 local_irq_save(flags);
21393
21394 if (local_softirq_pending()) {
21395 - curctx = current_thread_info();
21396 irqctx = __this_cpu_read(softirq_ctx);
21397 - irqctx->tinfo.task = curctx->task;
21398 - irqctx->tinfo.previous_esp = current_stack_pointer;
21399 + irqctx->previous_esp = current_stack_pointer;
21400
21401 /* build the stack frame on the softirq stack */
21402 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21403 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21404 +
21405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21406 + __set_fs(MAKE_MM_SEG(0));
21407 +#endif
21408
21409 call_on_stack(__do_softirq, isp);
21410 +
21411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21412 + __set_fs(current_thread_info()->addr_limit);
21413 +#endif
21414 +
21415 /*
21416 * Shouldn't happen, we returned above if in_interrupt():
21417 */
21418 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21419 if (unlikely(!desc))
21420 return false;
21421
21422 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21423 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21424 if (unlikely(overflow))
21425 print_stack_overflow();
21426 desc->handle_irq(irq, desc);
21427 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21428 index d04d3ec..ea4b374 100644
21429 --- a/arch/x86/kernel/irq_64.c
21430 +++ b/arch/x86/kernel/irq_64.c
21431 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21432 u64 estack_top, estack_bottom;
21433 u64 curbase = (u64)task_stack_page(current);
21434
21435 - if (user_mode_vm(regs))
21436 + if (user_mode(regs))
21437 return;
21438
21439 if (regs->sp >= curbase + sizeof(struct thread_info) +
21440 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21441 index dc1404b..bbc43e7 100644
21442 --- a/arch/x86/kernel/kdebugfs.c
21443 +++ b/arch/x86/kernel/kdebugfs.c
21444 @@ -27,7 +27,7 @@ struct setup_data_node {
21445 u32 len;
21446 };
21447
21448 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21449 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21450 size_t count, loff_t *ppos)
21451 {
21452 struct setup_data_node *node = file->private_data;
21453 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21454 index 836f832..a8bda67 100644
21455 --- a/arch/x86/kernel/kgdb.c
21456 +++ b/arch/x86/kernel/kgdb.c
21457 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21458 #ifdef CONFIG_X86_32
21459 switch (regno) {
21460 case GDB_SS:
21461 - if (!user_mode_vm(regs))
21462 + if (!user_mode(regs))
21463 *(unsigned long *)mem = __KERNEL_DS;
21464 break;
21465 case GDB_SP:
21466 - if (!user_mode_vm(regs))
21467 + if (!user_mode(regs))
21468 *(unsigned long *)mem = kernel_stack_pointer(regs);
21469 break;
21470 case GDB_GS:
21471 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21472 bp->attr.bp_addr = breakinfo[breakno].addr;
21473 bp->attr.bp_len = breakinfo[breakno].len;
21474 bp->attr.bp_type = breakinfo[breakno].type;
21475 - info->address = breakinfo[breakno].addr;
21476 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21477 + info->address = ktla_ktva(breakinfo[breakno].addr);
21478 + else
21479 + info->address = breakinfo[breakno].addr;
21480 info->len = breakinfo[breakno].len;
21481 info->type = breakinfo[breakno].type;
21482 val = arch_install_hw_breakpoint(bp);
21483 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21484 case 'k':
21485 /* clear the trace bit */
21486 linux_regs->flags &= ~X86_EFLAGS_TF;
21487 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21488 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21489
21490 /* set the trace bit if we're stepping */
21491 if (remcomInBuffer[0] == 's') {
21492 linux_regs->flags |= X86_EFLAGS_TF;
21493 - atomic_set(&kgdb_cpu_doing_single_step,
21494 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21495 raw_smp_processor_id());
21496 }
21497
21498 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21499
21500 switch (cmd) {
21501 case DIE_DEBUG:
21502 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21503 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21504 if (user_mode(regs))
21505 return single_step_cont(regs, args);
21506 break;
21507 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21508 #endif /* CONFIG_DEBUG_RODATA */
21509
21510 bpt->type = BP_BREAKPOINT;
21511 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21512 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21513 BREAK_INSTR_SIZE);
21514 if (err)
21515 return err;
21516 - err = probe_kernel_write((char *)bpt->bpt_addr,
21517 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21518 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21519 #ifdef CONFIG_DEBUG_RODATA
21520 if (!err)
21521 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21522 return -EBUSY;
21523 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21524 BREAK_INSTR_SIZE);
21525 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21526 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21527 if (err)
21528 return err;
21529 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21530 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21531 if (mutex_is_locked(&text_mutex))
21532 goto knl_write;
21533 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21534 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21535 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21536 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21537 goto knl_write;
21538 return err;
21539 knl_write:
21540 #endif /* CONFIG_DEBUG_RODATA */
21541 - return probe_kernel_write((char *)bpt->bpt_addr,
21542 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21543 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21544 }
21545
21546 diff --git a/arch/x86/kernel/kprobes-opt.c b/arch/x86/kernel/kprobes-opt.c
21547 index c5e410e..ed5a7f0 100644
21548 --- a/arch/x86/kernel/kprobes-opt.c
21549 +++ b/arch/x86/kernel/kprobes-opt.c
21550 @@ -338,7 +338,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21551 * Verify if the address gap is in 2GB range, because this uses
21552 * a relative jump.
21553 */
21554 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21555 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21556 if (abs(rel) > 0x7fffffff)
21557 return -ERANGE;
21558
21559 @@ -353,16 +353,16 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21560 op->optinsn.size = ret;
21561
21562 /* Copy arch-dep-instance from template */
21563 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21564 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21565
21566 /* Set probe information */
21567 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21568
21569 /* Set probe function call */
21570 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21571 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21572
21573 /* Set returning jmp instruction at the tail of out-of-line buffer */
21574 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21575 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21576 (u8 *)op->kp.addr + op->optinsn.size);
21577
21578 flush_icache_range((unsigned long) buf,
21579 @@ -385,7 +385,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21580 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21581
21582 /* Backup instructions which will be replaced by jump address */
21583 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21584 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21585 RELATIVE_ADDR_SIZE);
21586
21587 insn_buf[0] = RELATIVEJUMP_OPCODE;
21588 @@ -483,7 +483,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21589 /* This kprobe is really able to run optimized path. */
21590 op = container_of(p, struct optimized_kprobe, kp);
21591 /* Detour through copied instructions */
21592 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21593 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21594 if (!reenter)
21595 reset_current_kprobe();
21596 preempt_enable_no_resched();
21597 diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c
21598 index 57916c0..9e0b9d0 100644
21599 --- a/arch/x86/kernel/kprobes.c
21600 +++ b/arch/x86/kernel/kprobes.c
21601 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21602 s32 raddr;
21603 } __attribute__((packed)) *insn;
21604
21605 - insn = (struct __arch_relative_insn *)from;
21606 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21607 +
21608 + pax_open_kernel();
21609 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21610 insn->op = op;
21611 + pax_close_kernel();
21612 }
21613
21614 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21615 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21616 kprobe_opcode_t opcode;
21617 kprobe_opcode_t *orig_opcodes = opcodes;
21618
21619 - if (search_exception_tables((unsigned long)opcodes))
21620 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21621 return 0; /* Page fault may occur on this address. */
21622
21623 retry:
21624 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21625 * for the first byte, we can recover the original instruction
21626 * from it and kp->opcode.
21627 */
21628 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21629 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21630 buf[0] = kp->opcode;
21631 - return (unsigned long)buf;
21632 + return ktva_ktla((unsigned long)buf);
21633 }
21634
21635 /*
21636 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21637 /* Another subsystem puts a breakpoint, failed to recover */
21638 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21639 return 0;
21640 + pax_open_kernel();
21641 memcpy(dest, insn.kaddr, insn.length);
21642 + pax_close_kernel();
21643
21644 #ifdef CONFIG_X86_64
21645 if (insn_rip_relative(&insn)) {
21646 @@ -355,7 +360,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21647 newdisp = (u8 *) src + (s64) insn.displacement.value - (u8 *) dest;
21648 BUG_ON((s64) (s32) newdisp != newdisp); /* Sanity check. */
21649 disp = (u8 *) dest + insn_offset_displacement(&insn);
21650 + pax_open_kernel();
21651 *(s32 *) disp = (s32) newdisp;
21652 + pax_close_kernel();
21653 }
21654 #endif
21655 return insn.length;
21656 @@ -485,7 +492,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21657 * nor set current_kprobe, because it doesn't use single
21658 * stepping.
21659 */
21660 - regs->ip = (unsigned long)p->ainsn.insn;
21661 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21662 preempt_enable_no_resched();
21663 return;
21664 }
21665 @@ -502,9 +509,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21666 regs->flags &= ~X86_EFLAGS_IF;
21667 /* single step inline if the instruction is an int3 */
21668 if (p->opcode == BREAKPOINT_INSTRUCTION)
21669 - regs->ip = (unsigned long)p->addr;
21670 + regs->ip = ktla_ktva((unsigned long)p->addr);
21671 else
21672 - regs->ip = (unsigned long)p->ainsn.insn;
21673 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21674 }
21675
21676 /*
21677 @@ -600,7 +607,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21678 setup_singlestep(p, regs, kcb, 0);
21679 return 1;
21680 }
21681 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21682 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21683 /*
21684 * The breakpoint instruction was removed right
21685 * after we hit it. Another cpu has removed
21686 @@ -651,6 +658,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21687 " movq %rax, 152(%rsp)\n"
21688 RESTORE_REGS_STRING
21689 " popfq\n"
21690 +#ifdef KERNEXEC_PLUGIN
21691 + " btsq $63,(%rsp)\n"
21692 +#endif
21693 #else
21694 " pushf\n"
21695 SAVE_REGS_STRING
21696 @@ -788,7 +798,7 @@ static void __kprobes
21697 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21698 {
21699 unsigned long *tos = stack_addr(regs);
21700 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21701 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21702 unsigned long orig_ip = (unsigned long)p->addr;
21703 kprobe_opcode_t *insn = p->ainsn.insn;
21704
21705 @@ -970,7 +980,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21706 struct die_args *args = data;
21707 int ret = NOTIFY_DONE;
21708
21709 - if (args->regs && user_mode_vm(args->regs))
21710 + if (args->regs && user_mode(args->regs))
21711 return ret;
21712
21713 switch (val) {
21714 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21715 index 9c2bd8b..bb1131c 100644
21716 --- a/arch/x86/kernel/kvm.c
21717 +++ b/arch/x86/kernel/kvm.c
21718 @@ -452,7 +452,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21719 return NOTIFY_OK;
21720 }
21721
21722 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21723 +static struct notifier_block kvm_cpu_notifier = {
21724 .notifier_call = kvm_cpu_notify,
21725 };
21726 #endif
21727 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21728 index ebc9873..1b9724b 100644
21729 --- a/arch/x86/kernel/ldt.c
21730 +++ b/arch/x86/kernel/ldt.c
21731 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21732 if (reload) {
21733 #ifdef CONFIG_SMP
21734 preempt_disable();
21735 - load_LDT(pc);
21736 + load_LDT_nolock(pc);
21737 if (!cpumask_equal(mm_cpumask(current->mm),
21738 cpumask_of(smp_processor_id())))
21739 smp_call_function(flush_ldt, current->mm, 1);
21740 preempt_enable();
21741 #else
21742 - load_LDT(pc);
21743 + load_LDT_nolock(pc);
21744 #endif
21745 }
21746 if (oldsize) {
21747 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21748 return err;
21749
21750 for (i = 0; i < old->size; i++)
21751 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21752 + write_ldt_entry(new->ldt, i, old->ldt + i);
21753 return 0;
21754 }
21755
21756 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21757 retval = copy_ldt(&mm->context, &old_mm->context);
21758 mutex_unlock(&old_mm->context.lock);
21759 }
21760 +
21761 + if (tsk == current) {
21762 + mm->context.vdso = 0;
21763 +
21764 +#ifdef CONFIG_X86_32
21765 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21766 + mm->context.user_cs_base = 0UL;
21767 + mm->context.user_cs_limit = ~0UL;
21768 +
21769 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21770 + cpus_clear(mm->context.cpu_user_cs_mask);
21771 +#endif
21772 +
21773 +#endif
21774 +#endif
21775 +
21776 + }
21777 +
21778 return retval;
21779 }
21780
21781 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21782 }
21783 }
21784
21785 +#ifdef CONFIG_PAX_SEGMEXEC
21786 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21787 + error = -EINVAL;
21788 + goto out_unlock;
21789 + }
21790 +#endif
21791 +
21792 fill_ldt(&ldt, &ldt_info);
21793 if (oldmode)
21794 ldt.avl = 0;
21795 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21796 index 5b19e4d..6476a76 100644
21797 --- a/arch/x86/kernel/machine_kexec_32.c
21798 +++ b/arch/x86/kernel/machine_kexec_32.c
21799 @@ -26,7 +26,7 @@
21800 #include <asm/cacheflush.h>
21801 #include <asm/debugreg.h>
21802
21803 -static void set_idt(void *newidt, __u16 limit)
21804 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21805 {
21806 struct desc_ptr curidt;
21807
21808 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21809 }
21810
21811
21812 -static void set_gdt(void *newgdt, __u16 limit)
21813 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21814 {
21815 struct desc_ptr curgdt;
21816
21817 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21818 }
21819
21820 control_page = page_address(image->control_code_page);
21821 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21822 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21823
21824 relocate_kernel_ptr = control_page;
21825 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21826 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21827 index 3a04b22..1d2eb09 100644
21828 --- a/arch/x86/kernel/microcode_core.c
21829 +++ b/arch/x86/kernel/microcode_core.c
21830 @@ -512,7 +512,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21831 return NOTIFY_OK;
21832 }
21833
21834 -static struct notifier_block __refdata mc_cpu_notifier = {
21835 +static struct notifier_block mc_cpu_notifier = {
21836 .notifier_call = mc_cpu_callback,
21837 };
21838
21839 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21840 index 3544aed..01ddc1c 100644
21841 --- a/arch/x86/kernel/microcode_intel.c
21842 +++ b/arch/x86/kernel/microcode_intel.c
21843 @@ -431,13 +431,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21844
21845 static int get_ucode_user(void *to, const void *from, size_t n)
21846 {
21847 - return copy_from_user(to, from, n);
21848 + return copy_from_user(to, (const void __force_user *)from, n);
21849 }
21850
21851 static enum ucode_state
21852 request_microcode_user(int cpu, const void __user *buf, size_t size)
21853 {
21854 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21855 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21856 }
21857
21858 static void microcode_fini_cpu(int cpu)
21859 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21860 index 216a4d7..228255a 100644
21861 --- a/arch/x86/kernel/module.c
21862 +++ b/arch/x86/kernel/module.c
21863 @@ -43,15 +43,60 @@ do { \
21864 } while (0)
21865 #endif
21866
21867 -void *module_alloc(unsigned long size)
21868 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21869 {
21870 - if (PAGE_ALIGN(size) > MODULES_LEN)
21871 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21872 return NULL;
21873 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21874 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21875 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21876 -1, __builtin_return_address(0));
21877 }
21878
21879 +void *module_alloc(unsigned long size)
21880 +{
21881 +
21882 +#ifdef CONFIG_PAX_KERNEXEC
21883 + return __module_alloc(size, PAGE_KERNEL);
21884 +#else
21885 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21886 +#endif
21887 +
21888 +}
21889 +
21890 +#ifdef CONFIG_PAX_KERNEXEC
21891 +#ifdef CONFIG_X86_32
21892 +void *module_alloc_exec(unsigned long size)
21893 +{
21894 + struct vm_struct *area;
21895 +
21896 + if (size == 0)
21897 + return NULL;
21898 +
21899 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21900 + return area ? area->addr : NULL;
21901 +}
21902 +EXPORT_SYMBOL(module_alloc_exec);
21903 +
21904 +void module_free_exec(struct module *mod, void *module_region)
21905 +{
21906 + vunmap(module_region);
21907 +}
21908 +EXPORT_SYMBOL(module_free_exec);
21909 +#else
21910 +void module_free_exec(struct module *mod, void *module_region)
21911 +{
21912 + module_free(mod, module_region);
21913 +}
21914 +EXPORT_SYMBOL(module_free_exec);
21915 +
21916 +void *module_alloc_exec(unsigned long size)
21917 +{
21918 + return __module_alloc(size, PAGE_KERNEL_RX);
21919 +}
21920 +EXPORT_SYMBOL(module_alloc_exec);
21921 +#endif
21922 +#endif
21923 +
21924 #ifdef CONFIG_X86_32
21925 int apply_relocate(Elf32_Shdr *sechdrs,
21926 const char *strtab,
21927 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21928 unsigned int i;
21929 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21930 Elf32_Sym *sym;
21931 - uint32_t *location;
21932 + uint32_t *plocation, location;
21933
21934 DEBUGP("Applying relocate section %u to %u\n",
21935 relsec, sechdrs[relsec].sh_info);
21936 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21937 /* This is where to make the change */
21938 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21939 - + rel[i].r_offset;
21940 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21941 + location = (uint32_t)plocation;
21942 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21943 + plocation = ktla_ktva((void *)plocation);
21944 /* This is the symbol it is referring to. Note that all
21945 undefined symbols have been resolved. */
21946 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21947 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21948 switch (ELF32_R_TYPE(rel[i].r_info)) {
21949 case R_386_32:
21950 /* We add the value into the location given */
21951 - *location += sym->st_value;
21952 + pax_open_kernel();
21953 + *plocation += sym->st_value;
21954 + pax_close_kernel();
21955 break;
21956 case R_386_PC32:
21957 /* Add the value, subtract its position */
21958 - *location += sym->st_value - (uint32_t)location;
21959 + pax_open_kernel();
21960 + *plocation += sym->st_value - location;
21961 + pax_close_kernel();
21962 break;
21963 default:
21964 pr_err("%s: Unknown relocation: %u\n",
21965 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21966 case R_X86_64_NONE:
21967 break;
21968 case R_X86_64_64:
21969 + pax_open_kernel();
21970 *(u64 *)loc = val;
21971 + pax_close_kernel();
21972 break;
21973 case R_X86_64_32:
21974 + pax_open_kernel();
21975 *(u32 *)loc = val;
21976 + pax_close_kernel();
21977 if (val != *(u32 *)loc)
21978 goto overflow;
21979 break;
21980 case R_X86_64_32S:
21981 + pax_open_kernel();
21982 *(s32 *)loc = val;
21983 + pax_close_kernel();
21984 if ((s64)val != *(s32 *)loc)
21985 goto overflow;
21986 break;
21987 case R_X86_64_PC32:
21988 val -= (u64)loc;
21989 + pax_open_kernel();
21990 *(u32 *)loc = val;
21991 + pax_close_kernel();
21992 +
21993 #if 0
21994 if ((s64)val != *(s32 *)loc)
21995 goto overflow;
21996 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21997 index 4929502..686c291 100644
21998 --- a/arch/x86/kernel/msr.c
21999 +++ b/arch/x86/kernel/msr.c
22000 @@ -234,7 +234,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
22001 return notifier_from_errno(err);
22002 }
22003
22004 -static struct notifier_block __refdata msr_class_cpu_notifier = {
22005 +static struct notifier_block msr_class_cpu_notifier = {
22006 .notifier_call = msr_class_cpu_callback,
22007 };
22008
22009 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
22010 index f84f5c5..f404e81 100644
22011 --- a/arch/x86/kernel/nmi.c
22012 +++ b/arch/x86/kernel/nmi.c
22013 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
22014 return handled;
22015 }
22016
22017 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22018 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
22019 {
22020 struct nmi_desc *desc = nmi_to_desc(type);
22021 unsigned long flags;
22022 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
22023 * event confuses some handlers (kdump uses this flag)
22024 */
22025 if (action->flags & NMI_FLAG_FIRST)
22026 - list_add_rcu(&action->list, &desc->head);
22027 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
22028 else
22029 - list_add_tail_rcu(&action->list, &desc->head);
22030 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
22031
22032 spin_unlock_irqrestore(&desc->lock, flags);
22033 return 0;
22034 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
22035 if (!strcmp(n->name, name)) {
22036 WARN(in_nmi(),
22037 "Trying to free NMI (%s) from NMI context!\n", n->name);
22038 - list_del_rcu(&n->list);
22039 + pax_list_del_rcu((struct list_head *)&n->list);
22040 break;
22041 }
22042 }
22043 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
22044 dotraplinkage notrace __kprobes void
22045 do_nmi(struct pt_regs *regs, long error_code)
22046 {
22047 +
22048 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
22049 + if (!user_mode(regs)) {
22050 + unsigned long cs = regs->cs & 0xFFFF;
22051 + unsigned long ip = ktva_ktla(regs->ip);
22052 +
22053 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
22054 + regs->ip = ip;
22055 + }
22056 +#endif
22057 +
22058 nmi_nesting_preprocess(regs);
22059
22060 nmi_enter();
22061 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
22062 index 6d9582e..f746287 100644
22063 --- a/arch/x86/kernel/nmi_selftest.c
22064 +++ b/arch/x86/kernel/nmi_selftest.c
22065 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
22066 {
22067 /* trap all the unknown NMIs we may generate */
22068 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
22069 - __initdata);
22070 + __initconst);
22071 }
22072
22073 static void __init cleanup_nmi_testsuite(void)
22074 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
22075 unsigned long timeout;
22076
22077 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
22078 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
22079 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
22080 nmi_fail = FAILURE;
22081 return;
22082 }
22083 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
22084 index 676b8c7..870ba04 100644
22085 --- a/arch/x86/kernel/paravirt-spinlocks.c
22086 +++ b/arch/x86/kernel/paravirt-spinlocks.c
22087 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
22088 arch_spin_lock(lock);
22089 }
22090
22091 -struct pv_lock_ops pv_lock_ops = {
22092 +struct pv_lock_ops pv_lock_ops __read_only = {
22093 #ifdef CONFIG_SMP
22094 .spin_is_locked = __ticket_spin_is_locked,
22095 .spin_is_contended = __ticket_spin_is_contended,
22096 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
22097 index 17fff18..5cfa0f4 100644
22098 --- a/arch/x86/kernel/paravirt.c
22099 +++ b/arch/x86/kernel/paravirt.c
22100 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
22101 {
22102 return x;
22103 }
22104 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22105 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
22106 +#endif
22107
22108 void __init default_banner(void)
22109 {
22110 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
22111 if (opfunc == NULL)
22112 /* If there's no function, patch it with a ud2a (BUG) */
22113 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
22114 - else if (opfunc == _paravirt_nop)
22115 + else if (opfunc == (void *)_paravirt_nop)
22116 /* If the operation is a nop, then nop the callsite */
22117 ret = paravirt_patch_nop();
22118
22119 /* identity functions just return their single argument */
22120 - else if (opfunc == _paravirt_ident_32)
22121 + else if (opfunc == (void *)_paravirt_ident_32)
22122 ret = paravirt_patch_ident_32(insnbuf, len);
22123 - else if (opfunc == _paravirt_ident_64)
22124 + else if (opfunc == (void *)_paravirt_ident_64)
22125 ret = paravirt_patch_ident_64(insnbuf, len);
22126 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
22127 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
22128 + ret = paravirt_patch_ident_64(insnbuf, len);
22129 +#endif
22130
22131 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
22132 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
22133 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
22134 if (insn_len > len || start == NULL)
22135 insn_len = len;
22136 else
22137 - memcpy(insnbuf, start, insn_len);
22138 + memcpy(insnbuf, ktla_ktva(start), insn_len);
22139
22140 return insn_len;
22141 }
22142 @@ -304,7 +311,7 @@ void arch_flush_lazy_mmu_mode(void)
22143 preempt_enable();
22144 }
22145
22146 -struct pv_info pv_info = {
22147 +struct pv_info pv_info __read_only = {
22148 .name = "bare hardware",
22149 .paravirt_enabled = 0,
22150 .kernel_rpl = 0,
22151 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
22152 #endif
22153 };
22154
22155 -struct pv_init_ops pv_init_ops = {
22156 +struct pv_init_ops pv_init_ops __read_only = {
22157 .patch = native_patch,
22158 };
22159
22160 -struct pv_time_ops pv_time_ops = {
22161 +struct pv_time_ops pv_time_ops __read_only = {
22162 .sched_clock = native_sched_clock,
22163 .steal_clock = native_steal_clock,
22164 };
22165
22166 -struct pv_irq_ops pv_irq_ops = {
22167 +struct pv_irq_ops pv_irq_ops __read_only = {
22168 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
22169 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
22170 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
22171 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
22172 #endif
22173 };
22174
22175 -struct pv_cpu_ops pv_cpu_ops = {
22176 +struct pv_cpu_ops pv_cpu_ops __read_only = {
22177 .cpuid = native_cpuid,
22178 .get_debugreg = native_get_debugreg,
22179 .set_debugreg = native_set_debugreg,
22180 @@ -395,21 +402,26 @@ struct pv_cpu_ops pv_cpu_ops = {
22181 .end_context_switch = paravirt_nop,
22182 };
22183
22184 -struct pv_apic_ops pv_apic_ops = {
22185 +struct pv_apic_ops pv_apic_ops __read_only= {
22186 #ifdef CONFIG_X86_LOCAL_APIC
22187 .startup_ipi_hook = paravirt_nop,
22188 #endif
22189 };
22190
22191 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
22192 +#ifdef CONFIG_X86_32
22193 +#ifdef CONFIG_X86_PAE
22194 +/* 64-bit pagetable entries */
22195 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
22196 +#else
22197 /* 32-bit pagetable entries */
22198 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
22199 +#endif
22200 #else
22201 /* 64-bit pagetable entries */
22202 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
22203 #endif
22204
22205 -struct pv_mmu_ops pv_mmu_ops = {
22206 +struct pv_mmu_ops pv_mmu_ops __read_only = {
22207
22208 .read_cr2 = native_read_cr2,
22209 .write_cr2 = native_write_cr2,
22210 @@ -459,6 +471,7 @@ struct pv_mmu_ops pv_mmu_ops = {
22211 .make_pud = PTE_IDENT,
22212
22213 .set_pgd = native_set_pgd,
22214 + .set_pgd_batched = native_set_pgd_batched,
22215 #endif
22216 #endif /* PAGETABLE_LEVELS >= 3 */
22217
22218 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
22219 },
22220
22221 .set_fixmap = native_set_fixmap,
22222 +
22223 +#ifdef CONFIG_PAX_KERNEXEC
22224 + .pax_open_kernel = native_pax_open_kernel,
22225 + .pax_close_kernel = native_pax_close_kernel,
22226 +#endif
22227 +
22228 };
22229
22230 EXPORT_SYMBOL_GPL(pv_time_ops);
22231 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
22232 index 35ccf75..7a15747 100644
22233 --- a/arch/x86/kernel/pci-iommu_table.c
22234 +++ b/arch/x86/kernel/pci-iommu_table.c
22235 @@ -2,7 +2,7 @@
22236 #include <asm/iommu_table.h>
22237 #include <linux/string.h>
22238 #include <linux/kallsyms.h>
22239 -
22240 +#include <linux/sched.h>
22241
22242 #define DEBUG 1
22243
22244 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
22245 index 6c483ba..d10ce2f 100644
22246 --- a/arch/x86/kernel/pci-swiotlb.c
22247 +++ b/arch/x86/kernel/pci-swiotlb.c
22248 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
22249 void *vaddr, dma_addr_t dma_addr,
22250 struct dma_attrs *attrs)
22251 {
22252 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
22253 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
22254 }
22255
22256 static struct dma_map_ops swiotlb_dma_ops = {
22257 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22258 index 2ed787f..f70c9f6 100644
22259 --- a/arch/x86/kernel/process.c
22260 +++ b/arch/x86/kernel/process.c
22261 @@ -36,7 +36,8 @@
22262 * section. Since TSS's are completely CPU-local, we want them
22263 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22264 */
22265 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22266 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22267 +EXPORT_SYMBOL(init_tss);
22268
22269 #ifdef CONFIG_X86_64
22270 static DEFINE_PER_CPU(unsigned char, is_idle);
22271 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22272 task_xstate_cachep =
22273 kmem_cache_create("task_xstate", xstate_size,
22274 __alignof__(union thread_xstate),
22275 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22276 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22277 }
22278
22279 /*
22280 @@ -105,7 +106,7 @@ void exit_thread(void)
22281 unsigned long *bp = t->io_bitmap_ptr;
22282
22283 if (bp) {
22284 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22285 + struct tss_struct *tss = init_tss + get_cpu();
22286
22287 t->io_bitmap_ptr = NULL;
22288 clear_thread_flag(TIF_IO_BITMAP);
22289 @@ -136,7 +137,7 @@ void show_regs_common(void)
22290 board = dmi_get_system_info(DMI_BOARD_NAME);
22291
22292 printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s %s%s%s\n",
22293 - current->pid, current->comm, print_tainted(),
22294 + task_pid_nr(current), current->comm, print_tainted(),
22295 init_utsname()->release,
22296 (int)strcspn(init_utsname()->version, " "),
22297 init_utsname()->version,
22298 @@ -149,6 +150,9 @@ void flush_thread(void)
22299 {
22300 struct task_struct *tsk = current;
22301
22302 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22303 + loadsegment(gs, 0);
22304 +#endif
22305 flush_ptrace_hw_breakpoint(tsk);
22306 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22307 drop_init_fpu(tsk);
22308 @@ -301,7 +305,7 @@ static void __exit_idle(void)
22309 void exit_idle(void)
22310 {
22311 /* idle loop has pid 0 */
22312 - if (current->pid)
22313 + if (task_pid_nr(current))
22314 return;
22315 __exit_idle();
22316 }
22317 @@ -404,7 +408,7 @@ bool set_pm_idle_to_default(void)
22318
22319 return ret;
22320 }
22321 -void stop_this_cpu(void *dummy)
22322 +__noreturn void stop_this_cpu(void *dummy)
22323 {
22324 local_irq_disable();
22325 /*
22326 @@ -632,16 +636,37 @@ static int __init idle_setup(char *str)
22327 }
22328 early_param("idle", idle_setup);
22329
22330 -unsigned long arch_align_stack(unsigned long sp)
22331 +#ifdef CONFIG_PAX_RANDKSTACK
22332 +void pax_randomize_kstack(struct pt_regs *regs)
22333 {
22334 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22335 - sp -= get_random_int() % 8192;
22336 - return sp & ~0xf;
22337 -}
22338 + struct thread_struct *thread = &current->thread;
22339 + unsigned long time;
22340
22341 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22342 -{
22343 - unsigned long range_end = mm->brk + 0x02000000;
22344 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22345 -}
22346 + if (!randomize_va_space)
22347 + return;
22348 +
22349 + if (v8086_mode(regs))
22350 + return;
22351
22352 + rdtscl(time);
22353 +
22354 + /* P4 seems to return a 0 LSB, ignore it */
22355 +#ifdef CONFIG_MPENTIUM4
22356 + time &= 0x3EUL;
22357 + time <<= 2;
22358 +#elif defined(CONFIG_X86_64)
22359 + time &= 0xFUL;
22360 + time <<= 4;
22361 +#else
22362 + time &= 0x1FUL;
22363 + time <<= 3;
22364 +#endif
22365 +
22366 + thread->sp0 ^= time;
22367 + load_sp0(init_tss + smp_processor_id(), thread);
22368 +
22369 +#ifdef CONFIG_X86_64
22370 + this_cpu_write(kernel_stack, thread->sp0);
22371 +#endif
22372 +}
22373 +#endif
22374 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22375 index b5a8905..d9cacac 100644
22376 --- a/arch/x86/kernel/process_32.c
22377 +++ b/arch/x86/kernel/process_32.c
22378 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22379 unsigned long thread_saved_pc(struct task_struct *tsk)
22380 {
22381 return ((unsigned long *)tsk->thread.sp)[3];
22382 +//XXX return tsk->thread.eip;
22383 }
22384
22385 void __show_regs(struct pt_regs *regs, int all)
22386 @@ -74,21 +75,20 @@ void __show_regs(struct pt_regs *regs, int all)
22387 unsigned long sp;
22388 unsigned short ss, gs;
22389
22390 - if (user_mode_vm(regs)) {
22391 + if (user_mode(regs)) {
22392 sp = regs->sp;
22393 ss = regs->ss & 0xffff;
22394 - gs = get_user_gs(regs);
22395 } else {
22396 sp = kernel_stack_pointer(regs);
22397 savesegment(ss, ss);
22398 - savesegment(gs, gs);
22399 }
22400 + gs = get_user_gs(regs);
22401
22402 show_regs_common();
22403
22404 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22405 (u16)regs->cs, regs->ip, regs->flags,
22406 - smp_processor_id());
22407 + raw_smp_processor_id());
22408 print_symbol("EIP is at %s\n", regs->ip);
22409
22410 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22411 @@ -130,20 +130,21 @@ void release_thread(struct task_struct *dead_task)
22412 int copy_thread(unsigned long clone_flags, unsigned long sp,
22413 unsigned long arg, struct task_struct *p)
22414 {
22415 - struct pt_regs *childregs = task_pt_regs(p);
22416 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22417 struct task_struct *tsk;
22418 int err;
22419
22420 p->thread.sp = (unsigned long) childregs;
22421 p->thread.sp0 = (unsigned long) (childregs+1);
22422 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22423
22424 if (unlikely(p->flags & PF_KTHREAD)) {
22425 /* kernel thread */
22426 memset(childregs, 0, sizeof(struct pt_regs));
22427 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22428 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22429 - childregs->ds = __USER_DS;
22430 - childregs->es = __USER_DS;
22431 + savesegment(gs, childregs->gs);
22432 + childregs->ds = __KERNEL_DS;
22433 + childregs->es = __KERNEL_DS;
22434 childregs->fs = __KERNEL_PERCPU;
22435 childregs->bx = sp; /* function */
22436 childregs->bp = arg;
22437 @@ -250,7 +251,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22438 struct thread_struct *prev = &prev_p->thread,
22439 *next = &next_p->thread;
22440 int cpu = smp_processor_id();
22441 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22442 + struct tss_struct *tss = init_tss + cpu;
22443 fpu_switch_t fpu;
22444
22445 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22446 @@ -274,6 +275,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22447 */
22448 lazy_save_gs(prev->gs);
22449
22450 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22451 + __set_fs(task_thread_info(next_p)->addr_limit);
22452 +#endif
22453 +
22454 /*
22455 * Load the per-thread Thread-Local Storage descriptor.
22456 */
22457 @@ -304,6 +309,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22458 */
22459 arch_end_context_switch(next_p);
22460
22461 + this_cpu_write(current_task, next_p);
22462 + this_cpu_write(current_tinfo, &next_p->tinfo);
22463 +
22464 /*
22465 * Restore %gs if needed (which is common)
22466 */
22467 @@ -312,8 +320,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22468
22469 switch_fpu_finish(next_p, fpu);
22470
22471 - this_cpu_write(current_task, next_p);
22472 -
22473 return prev_p;
22474 }
22475
22476 @@ -343,4 +349,3 @@ unsigned long get_wchan(struct task_struct *p)
22477 } while (count++ < 16);
22478 return 0;
22479 }
22480 -
22481 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22482 index 6e68a61..955a9a5 100644
22483 --- a/arch/x86/kernel/process_64.c
22484 +++ b/arch/x86/kernel/process_64.c
22485 @@ -152,10 +152,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22486 struct pt_regs *childregs;
22487 struct task_struct *me = current;
22488
22489 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22490 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22491 childregs = task_pt_regs(p);
22492 p->thread.sp = (unsigned long) childregs;
22493 p->thread.usersp = me->thread.usersp;
22494 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22495 set_tsk_thread_flag(p, TIF_FORK);
22496 p->fpu_counter = 0;
22497 p->thread.io_bitmap_ptr = NULL;
22498 @@ -274,7 +275,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22499 struct thread_struct *prev = &prev_p->thread;
22500 struct thread_struct *next = &next_p->thread;
22501 int cpu = smp_processor_id();
22502 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22503 + struct tss_struct *tss = init_tss + cpu;
22504 unsigned fsindex, gsindex;
22505 fpu_switch_t fpu;
22506
22507 @@ -356,10 +357,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22508 prev->usersp = this_cpu_read(old_rsp);
22509 this_cpu_write(old_rsp, next->usersp);
22510 this_cpu_write(current_task, next_p);
22511 + this_cpu_write(current_tinfo, &next_p->tinfo);
22512
22513 - this_cpu_write(kernel_stack,
22514 - (unsigned long)task_stack_page(next_p) +
22515 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22516 + this_cpu_write(kernel_stack, next->sp0);
22517
22518 /*
22519 * Now maybe reload the debug registers and handle I/O bitmaps
22520 @@ -428,12 +428,11 @@ unsigned long get_wchan(struct task_struct *p)
22521 if (!p || p == current || p->state == TASK_RUNNING)
22522 return 0;
22523 stack = (unsigned long)task_stack_page(p);
22524 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22525 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22526 return 0;
22527 fp = *(u64 *)(p->thread.sp);
22528 do {
22529 - if (fp < (unsigned long)stack ||
22530 - fp >= (unsigned long)stack+THREAD_SIZE)
22531 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22532 return 0;
22533 ip = *(u64 *)(fp+8);
22534 if (!in_sched_functions(ip))
22535 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22536 index b629bbe..0fa615a 100644
22537 --- a/arch/x86/kernel/ptrace.c
22538 +++ b/arch/x86/kernel/ptrace.c
22539 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22540 {
22541 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22542 unsigned long sp = (unsigned long)&regs->sp;
22543 - struct thread_info *tinfo;
22544
22545 - if (context == (sp & ~(THREAD_SIZE - 1)))
22546 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22547 return sp;
22548
22549 - tinfo = (struct thread_info *)context;
22550 - if (tinfo->previous_esp)
22551 - return tinfo->previous_esp;
22552 + sp = *(unsigned long *)context;
22553 + if (sp)
22554 + return sp;
22555
22556 return (unsigned long)regs;
22557 }
22558 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22559 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22560 {
22561 int i;
22562 - int dr7 = 0;
22563 + unsigned long dr7 = 0;
22564 struct arch_hw_breakpoint *info;
22565
22566 for (i = 0; i < HBP_NUM; i++) {
22567 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22568 unsigned long addr, unsigned long data)
22569 {
22570 int ret;
22571 - unsigned long __user *datap = (unsigned long __user *)data;
22572 + unsigned long __user *datap = (__force unsigned long __user *)data;
22573
22574 switch (request) {
22575 /* read the word at location addr in the USER area. */
22576 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22577 if ((int) addr < 0)
22578 return -EIO;
22579 ret = do_get_thread_area(child, addr,
22580 - (struct user_desc __user *)data);
22581 + (__force struct user_desc __user *) data);
22582 break;
22583
22584 case PTRACE_SET_THREAD_AREA:
22585 if ((int) addr < 0)
22586 return -EIO;
22587 ret = do_set_thread_area(child, addr,
22588 - (struct user_desc __user *)data, 0);
22589 + (__force struct user_desc __user *) data, 0);
22590 break;
22591 #endif
22592
22593 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22594
22595 #ifdef CONFIG_X86_64
22596
22597 -static struct user_regset x86_64_regsets[] __read_mostly = {
22598 +static user_regset_no_const x86_64_regsets[] __read_only = {
22599 [REGSET_GENERAL] = {
22600 .core_note_type = NT_PRSTATUS,
22601 .n = sizeof(struct user_regs_struct) / sizeof(long),
22602 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22603 #endif /* CONFIG_X86_64 */
22604
22605 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22606 -static struct user_regset x86_32_regsets[] __read_mostly = {
22607 +static user_regset_no_const x86_32_regsets[] __read_only = {
22608 [REGSET_GENERAL] = {
22609 .core_note_type = NT_PRSTATUS,
22610 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22611 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22612 */
22613 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22614
22615 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22616 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22617 {
22618 #ifdef CONFIG_X86_64
22619 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22620 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22621 memset(info, 0, sizeof(*info));
22622 info->si_signo = SIGTRAP;
22623 info->si_code = si_code;
22624 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22625 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22626 }
22627
22628 void user_single_step_siginfo(struct task_struct *tsk,
22629 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22630 # define IS_IA32 0
22631 #endif
22632
22633 +#ifdef CONFIG_GRKERNSEC_SETXID
22634 +extern void gr_delayed_cred_worker(void);
22635 +#endif
22636 +
22637 /*
22638 * We must return the syscall number to actually look up in the table.
22639 * This can be -1L to skip running any syscall at all.
22640 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22641
22642 user_exit();
22643
22644 +#ifdef CONFIG_GRKERNSEC_SETXID
22645 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22646 + gr_delayed_cred_worker();
22647 +#endif
22648 +
22649 /*
22650 * If we stepped into a sysenter/syscall insn, it trapped in
22651 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22652 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22653 */
22654 user_exit();
22655
22656 +#ifdef CONFIG_GRKERNSEC_SETXID
22657 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22658 + gr_delayed_cred_worker();
22659 +#endif
22660 +
22661 audit_syscall_exit(regs);
22662
22663 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22664 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22665 index 2cb9470..ff1fd80 100644
22666 --- a/arch/x86/kernel/pvclock.c
22667 +++ b/arch/x86/kernel/pvclock.c
22668 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22669 return pv_tsc_khz;
22670 }
22671
22672 -static atomic64_t last_value = ATOMIC64_INIT(0);
22673 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22674
22675 void pvclock_resume(void)
22676 {
22677 - atomic64_set(&last_value, 0);
22678 + atomic64_set_unchecked(&last_value, 0);
22679 }
22680
22681 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22682 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22683 * updating at the same time, and one of them could be slightly behind,
22684 * making the assumption that last_value always go forward fail to hold.
22685 */
22686 - last = atomic64_read(&last_value);
22687 + last = atomic64_read_unchecked(&last_value);
22688 do {
22689 if (ret < last)
22690 return last;
22691 - last = atomic64_cmpxchg(&last_value, last, ret);
22692 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22693 } while (unlikely(last != ret));
22694
22695 return ret;
22696 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22697 index 76fa1e9..abf09ea 100644
22698 --- a/arch/x86/kernel/reboot.c
22699 +++ b/arch/x86/kernel/reboot.c
22700 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22701 EXPORT_SYMBOL(pm_power_off);
22702
22703 static const struct desc_ptr no_idt = {};
22704 -static int reboot_mode;
22705 +static unsigned short reboot_mode;
22706 enum reboot_type reboot_type = BOOT_ACPI;
22707 int reboot_force;
22708
22709 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22710
22711 void __noreturn machine_real_restart(unsigned int type)
22712 {
22713 +
22714 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22715 + struct desc_struct *gdt;
22716 +#endif
22717 +
22718 local_irq_disable();
22719
22720 /*
22721 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22722
22723 /* Jump to the identity-mapped low memory code */
22724 #ifdef CONFIG_X86_32
22725 - asm volatile("jmpl *%0" : :
22726 +
22727 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22728 + gdt = get_cpu_gdt_table(smp_processor_id());
22729 + pax_open_kernel();
22730 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22731 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22732 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22733 + loadsegment(ds, __KERNEL_DS);
22734 + loadsegment(es, __KERNEL_DS);
22735 + loadsegment(ss, __KERNEL_DS);
22736 +#endif
22737 +#ifdef CONFIG_PAX_KERNEXEC
22738 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22739 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22740 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22741 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22742 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22743 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22744 +#endif
22745 + pax_close_kernel();
22746 +#endif
22747 +
22748 + asm volatile("ljmpl *%0" : :
22749 "rm" (real_mode_header->machine_real_restart_asm),
22750 "a" (type));
22751 #else
22752 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22753 * try to force a triple fault and then cycle between hitting the keyboard
22754 * controller and doing that
22755 */
22756 -static void native_machine_emergency_restart(void)
22757 +static void __noreturn native_machine_emergency_restart(void)
22758 {
22759 int i;
22760 int attempt = 0;
22761 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22762 #endif
22763 }
22764
22765 -static void __machine_emergency_restart(int emergency)
22766 +static void __noreturn __machine_emergency_restart(int emergency)
22767 {
22768 reboot_emergency = emergency;
22769 machine_ops.emergency_restart();
22770 }
22771
22772 -static void native_machine_restart(char *__unused)
22773 +static void __noreturn native_machine_restart(char *__unused)
22774 {
22775 pr_notice("machine restart\n");
22776
22777 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22778 __machine_emergency_restart(0);
22779 }
22780
22781 -static void native_machine_halt(void)
22782 +static void __noreturn native_machine_halt(void)
22783 {
22784 /* Stop other cpus and apics */
22785 machine_shutdown();
22786 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22787 stop_this_cpu(NULL);
22788 }
22789
22790 -static void native_machine_power_off(void)
22791 +static void __noreturn native_machine_power_off(void)
22792 {
22793 if (pm_power_off) {
22794 if (!reboot_force)
22795 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22796 }
22797 /* A fallback in case there is no PM info available */
22798 tboot_shutdown(TB_SHUTDOWN_HALT);
22799 + unreachable();
22800 }
22801
22802 -struct machine_ops machine_ops = {
22803 +struct machine_ops machine_ops __read_only = {
22804 .power_off = native_machine_power_off,
22805 .shutdown = native_machine_shutdown,
22806 .emergency_restart = native_machine_emergency_restart,
22807 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22808 index 7a6f3b3..bed145d7 100644
22809 --- a/arch/x86/kernel/relocate_kernel_64.S
22810 +++ b/arch/x86/kernel/relocate_kernel_64.S
22811 @@ -11,6 +11,7 @@
22812 #include <asm/kexec.h>
22813 #include <asm/processor-flags.h>
22814 #include <asm/pgtable_types.h>
22815 +#include <asm/alternative-asm.h>
22816
22817 /*
22818 * Must be relocatable PIC code callable as a C function
22819 @@ -160,13 +161,14 @@ identity_mapped:
22820 xorq %rbp, %rbp
22821 xorq %r8, %r8
22822 xorq %r9, %r9
22823 - xorq %r10, %r9
22824 + xorq %r10, %r10
22825 xorq %r11, %r11
22826 xorq %r12, %r12
22827 xorq %r13, %r13
22828 xorq %r14, %r14
22829 xorq %r15, %r15
22830
22831 + pax_force_retaddr 0, 1
22832 ret
22833
22834 1:
22835 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22836 index 8b24289..d37b58b 100644
22837 --- a/arch/x86/kernel/setup.c
22838 +++ b/arch/x86/kernel/setup.c
22839 @@ -437,7 +437,7 @@ static void __init parse_setup_data(void)
22840
22841 switch (data->type) {
22842 case SETUP_E820_EXT:
22843 - parse_e820_ext(data);
22844 + parse_e820_ext((struct setup_data __force_kernel *)data);
22845 break;
22846 case SETUP_DTB:
22847 add_dtb(pa_data);
22848 @@ -706,7 +706,7 @@ static void __init trim_bios_range(void)
22849 * area (640->1Mb) as ram even though it is not.
22850 * take them out.
22851 */
22852 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22853 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22854
22855 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22856 }
22857 @@ -830,14 +830,14 @@ void __init setup_arch(char **cmdline_p)
22858
22859 if (!boot_params.hdr.root_flags)
22860 root_mountflags &= ~MS_RDONLY;
22861 - init_mm.start_code = (unsigned long) _text;
22862 - init_mm.end_code = (unsigned long) _etext;
22863 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22864 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22865 init_mm.end_data = (unsigned long) _edata;
22866 init_mm.brk = _brk_end;
22867
22868 - code_resource.start = virt_to_phys(_text);
22869 - code_resource.end = virt_to_phys(_etext)-1;
22870 - data_resource.start = virt_to_phys(_etext);
22871 + code_resource.start = virt_to_phys(ktla_ktva(_text));
22872 + code_resource.end = virt_to_phys(ktla_ktva(_etext))-1;
22873 + data_resource.start = virt_to_phys(_sdata);
22874 data_resource.end = virt_to_phys(_edata)-1;
22875 bss_resource.start = virt_to_phys(&__bss_start);
22876 bss_resource.end = virt_to_phys(&__bss_stop)-1;
22877 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22878 index 5cdff03..80fa283 100644
22879 --- a/arch/x86/kernel/setup_percpu.c
22880 +++ b/arch/x86/kernel/setup_percpu.c
22881 @@ -21,19 +21,17 @@
22882 #include <asm/cpu.h>
22883 #include <asm/stackprotector.h>
22884
22885 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22886 +#ifdef CONFIG_SMP
22887 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22888 EXPORT_PER_CPU_SYMBOL(cpu_number);
22889 +#endif
22890
22891 -#ifdef CONFIG_X86_64
22892 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22893 -#else
22894 -#define BOOT_PERCPU_OFFSET 0
22895 -#endif
22896
22897 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22898 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22899
22900 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22901 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22902 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22903 };
22904 EXPORT_SYMBOL(__per_cpu_offset);
22905 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22906 {
22907 #ifdef CONFIG_NEED_MULTIPLE_NODES
22908 pg_data_t *last = NULL;
22909 - unsigned int cpu;
22910 + int cpu;
22911
22912 for_each_possible_cpu(cpu) {
22913 int node = early_cpu_to_node(cpu);
22914 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22915 {
22916 #ifdef CONFIG_X86_32
22917 struct desc_struct gdt;
22918 + unsigned long base = per_cpu_offset(cpu);
22919
22920 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22921 - 0x2 | DESCTYPE_S, 0x8);
22922 - gdt.s = 1;
22923 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22924 + 0x83 | DESCTYPE_S, 0xC);
22925 write_gdt_entry(get_cpu_gdt_table(cpu),
22926 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22927 #endif
22928 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22929 /* alrighty, percpu areas up and running */
22930 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22931 for_each_possible_cpu(cpu) {
22932 +#ifdef CONFIG_CC_STACKPROTECTOR
22933 +#ifdef CONFIG_X86_32
22934 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22935 +#endif
22936 +#endif
22937 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22938 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22939 per_cpu(cpu_number, cpu) = cpu;
22940 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22941 */
22942 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22943 #endif
22944 +#ifdef CONFIG_CC_STACKPROTECTOR
22945 +#ifdef CONFIG_X86_32
22946 + if (!cpu)
22947 + per_cpu(stack_canary.canary, cpu) = canary;
22948 +#endif
22949 +#endif
22950 /*
22951 * Up to this point, the boot CPU has been using .init.data
22952 * area. Reload any changed state for the boot CPU.
22953 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22954 index d6bf1f3..3ffce5a 100644
22955 --- a/arch/x86/kernel/signal.c
22956 +++ b/arch/x86/kernel/signal.c
22957 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22958 * Align the stack pointer according to the i386 ABI,
22959 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22960 */
22961 - sp = ((sp + 4) & -16ul) - 4;
22962 + sp = ((sp - 12) & -16ul) - 4;
22963 #else /* !CONFIG_X86_32 */
22964 sp = round_down(sp, 16) - 8;
22965 #endif
22966 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22967 }
22968
22969 if (current->mm->context.vdso)
22970 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22971 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22972 else
22973 - restorer = &frame->retcode;
22974 + restorer = (void __user *)&frame->retcode;
22975 if (ka->sa.sa_flags & SA_RESTORER)
22976 restorer = ka->sa.sa_restorer;
22977
22978 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct k_sigaction *ka, sigset_t *set,
22979 * reasons and because gdb uses it as a signature to notice
22980 * signal handler stack frames.
22981 */
22982 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22983 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22984
22985 if (err)
22986 return -EFAULT;
22987 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
22988 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22989
22990 /* Set up to return from userspace. */
22991 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22992 + if (current->mm->context.vdso)
22993 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22994 + else
22995 + restorer = (void __user *)&frame->retcode;
22996 if (ka->sa.sa_flags & SA_RESTORER)
22997 restorer = ka->sa.sa_restorer;
22998 put_user_ex(restorer, &frame->pretcode);
22999 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
23000 * reasons and because gdb uses it as a signature to notice
23001 * signal handler stack frames.
23002 */
23003 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
23004 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
23005 } put_user_catch(err);
23006
23007 err |= copy_siginfo_to_user(&frame->info, info);
23008 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
23009 index 48d2b7d..90d328a 100644
23010 --- a/arch/x86/kernel/smp.c
23011 +++ b/arch/x86/kernel/smp.c
23012 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
23013
23014 __setup("nonmi_ipi", nonmi_ipi_setup);
23015
23016 -struct smp_ops smp_ops = {
23017 +struct smp_ops smp_ops __read_only = {
23018 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
23019 .smp_prepare_cpus = native_smp_prepare_cpus,
23020 .smp_cpus_done = native_smp_cpus_done,
23021 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
23022 index ed0fe38..87fc692 100644
23023 --- a/arch/x86/kernel/smpboot.c
23024 +++ b/arch/x86/kernel/smpboot.c
23025 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23026 idle->thread.sp = (unsigned long) (((struct pt_regs *)
23027 (THREAD_SIZE + task_stack_page(idle))) - 1);
23028 per_cpu(current_task, cpu) = idle;
23029 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
23030
23031 #ifdef CONFIG_X86_32
23032 /* Stack for startup_32 can be just as for start_secondary onwards */
23033 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
23034 #else
23035 clear_tsk_thread_flag(idle, TIF_FORK);
23036 initial_gs = per_cpu_offset(cpu);
23037 - per_cpu(kernel_stack, cpu) =
23038 - (unsigned long)task_stack_page(idle) -
23039 - KERNEL_STACK_OFFSET + THREAD_SIZE;
23040 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
23041 #endif
23042 +
23043 + pax_open_kernel();
23044 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
23045 + pax_close_kernel();
23046 +
23047 initial_code = (unsigned long)start_secondary;
23048 stack_start = idle->thread.sp;
23049
23050 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
23051 /* the FPU context is blank, nobody can own it */
23052 __cpu_disable_lazy_restore(cpu);
23053
23054 +#ifdef CONFIG_PAX_PER_CPU_PGD
23055 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
23056 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
23057 + KERNEL_PGD_PTRS);
23058 +#endif
23059 +
23060 + /* the FPU context is blank, nobody can own it */
23061 + __cpu_disable_lazy_restore(cpu);
23062 +
23063 err = do_boot_cpu(apicid, cpu, tidle);
23064 if (err) {
23065 pr_debug("do_boot_cpu failed %d\n", err);
23066 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
23067 index 9b4d51d..5d28b58 100644
23068 --- a/arch/x86/kernel/step.c
23069 +++ b/arch/x86/kernel/step.c
23070 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23071 struct desc_struct *desc;
23072 unsigned long base;
23073
23074 - seg &= ~7UL;
23075 + seg >>= 3;
23076
23077 mutex_lock(&child->mm->context.lock);
23078 - if (unlikely((seg >> 3) >= child->mm->context.size))
23079 + if (unlikely(seg >= child->mm->context.size))
23080 addr = -1L; /* bogus selector, access would fault */
23081 else {
23082 desc = child->mm->context.ldt + seg;
23083 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
23084 addr += base;
23085 }
23086 mutex_unlock(&child->mm->context.lock);
23087 - }
23088 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
23089 + addr = ktla_ktva(addr);
23090
23091 return addr;
23092 }
23093 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
23094 unsigned char opcode[15];
23095 unsigned long addr = convert_ip_to_linear(child, regs);
23096
23097 + if (addr == -EINVAL)
23098 + return 0;
23099 +
23100 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
23101 for (i = 0; i < copied; i++) {
23102 switch (opcode[i]) {
23103 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
23104 new file mode 100644
23105 index 0000000..207bec6
23106 --- /dev/null
23107 +++ b/arch/x86/kernel/sys_i386_32.c
23108 @@ -0,0 +1,250 @@
23109 +/*
23110 + * This file contains various random system calls that
23111 + * have a non-standard calling sequence on the Linux/i386
23112 + * platform.
23113 + */
23114 +
23115 +#include <linux/errno.h>
23116 +#include <linux/sched.h>
23117 +#include <linux/mm.h>
23118 +#include <linux/fs.h>
23119 +#include <linux/smp.h>
23120 +#include <linux/sem.h>
23121 +#include <linux/msg.h>
23122 +#include <linux/shm.h>
23123 +#include <linux/stat.h>
23124 +#include <linux/syscalls.h>
23125 +#include <linux/mman.h>
23126 +#include <linux/file.h>
23127 +#include <linux/utsname.h>
23128 +#include <linux/ipc.h>
23129 +
23130 +#include <linux/uaccess.h>
23131 +#include <linux/unistd.h>
23132 +
23133 +#include <asm/syscalls.h>
23134 +
23135 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
23136 +{
23137 + unsigned long pax_task_size = TASK_SIZE;
23138 +
23139 +#ifdef CONFIG_PAX_SEGMEXEC
23140 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
23141 + pax_task_size = SEGMEXEC_TASK_SIZE;
23142 +#endif
23143 +
23144 + if (flags & MAP_FIXED)
23145 + if (len > pax_task_size || addr > pax_task_size - len)
23146 + return -EINVAL;
23147 +
23148 + return 0;
23149 +}
23150 +
23151 +unsigned long
23152 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
23153 + unsigned long len, unsigned long pgoff, unsigned long flags)
23154 +{
23155 + struct mm_struct *mm = current->mm;
23156 + struct vm_area_struct *vma;
23157 + unsigned long start_addr, pax_task_size = TASK_SIZE;
23158 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23159 +
23160 +#ifdef CONFIG_PAX_SEGMEXEC
23161 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23162 + pax_task_size = SEGMEXEC_TASK_SIZE;
23163 +#endif
23164 +
23165 + pax_task_size -= PAGE_SIZE;
23166 +
23167 + if (len > pax_task_size)
23168 + return -ENOMEM;
23169 +
23170 + if (flags & MAP_FIXED)
23171 + return addr;
23172 +
23173 +#ifdef CONFIG_PAX_RANDMMAP
23174 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23175 +#endif
23176 +
23177 + if (addr) {
23178 + addr = PAGE_ALIGN(addr);
23179 + if (pax_task_size - len >= addr) {
23180 + vma = find_vma(mm, addr);
23181 + if (check_heap_stack_gap(vma, addr, len, offset))
23182 + return addr;
23183 + }
23184 + }
23185 + if (len > mm->cached_hole_size) {
23186 + start_addr = addr = mm->free_area_cache;
23187 + } else {
23188 + start_addr = addr = mm->mmap_base;
23189 + mm->cached_hole_size = 0;
23190 + }
23191 +
23192 +#ifdef CONFIG_PAX_PAGEEXEC
23193 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE) && start_addr >= mm->mmap_base) {
23194 + start_addr = 0x00110000UL;
23195 +
23196 +#ifdef CONFIG_PAX_RANDMMAP
23197 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23198 + start_addr += mm->delta_mmap & 0x03FFF000UL;
23199 +#endif
23200 +
23201 + if (mm->start_brk <= start_addr && start_addr < mm->mmap_base)
23202 + start_addr = addr = mm->mmap_base;
23203 + else
23204 + addr = start_addr;
23205 + }
23206 +#endif
23207 +
23208 +full_search:
23209 + for (vma = find_vma(mm, addr); ; vma = vma->vm_next) {
23210 + /* At this point: (!vma || addr < vma->vm_end). */
23211 + if (pax_task_size - len < addr) {
23212 + /*
23213 + * Start a new search - just in case we missed
23214 + * some holes.
23215 + */
23216 + if (start_addr != mm->mmap_base) {
23217 + start_addr = addr = mm->mmap_base;
23218 + mm->cached_hole_size = 0;
23219 + goto full_search;
23220 + }
23221 + return -ENOMEM;
23222 + }
23223 + if (check_heap_stack_gap(vma, addr, len, offset))
23224 + break;
23225 + if (addr + mm->cached_hole_size < vma->vm_start)
23226 + mm->cached_hole_size = vma->vm_start - addr;
23227 + addr = vma->vm_end;
23228 + if (mm->start_brk <= addr && addr < mm->mmap_base) {
23229 + start_addr = addr = mm->mmap_base;
23230 + mm->cached_hole_size = 0;
23231 + goto full_search;
23232 + }
23233 + }
23234 +
23235 + /*
23236 + * Remember the place where we stopped the search:
23237 + */
23238 + mm->free_area_cache = addr + len;
23239 + return addr;
23240 +}
23241 +
23242 +unsigned long
23243 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23244 + const unsigned long len, const unsigned long pgoff,
23245 + const unsigned long flags)
23246 +{
23247 + struct vm_area_struct *vma;
23248 + struct mm_struct *mm = current->mm;
23249 + unsigned long base = mm->mmap_base, addr = addr0, pax_task_size = TASK_SIZE;
23250 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23251 +
23252 +#ifdef CONFIG_PAX_SEGMEXEC
23253 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23254 + pax_task_size = SEGMEXEC_TASK_SIZE;
23255 +#endif
23256 +
23257 + pax_task_size -= PAGE_SIZE;
23258 +
23259 + /* requested length too big for entire address space */
23260 + if (len > pax_task_size)
23261 + return -ENOMEM;
23262 +
23263 + if (flags & MAP_FIXED)
23264 + return addr;
23265 +
23266 +#ifdef CONFIG_PAX_PAGEEXEC
23267 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23268 + goto bottomup;
23269 +#endif
23270 +
23271 +#ifdef CONFIG_PAX_RANDMMAP
23272 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23273 +#endif
23274 +
23275 + /* requesting a specific address */
23276 + if (addr) {
23277 + addr = PAGE_ALIGN(addr);
23278 + if (pax_task_size - len >= addr) {
23279 + vma = find_vma(mm, addr);
23280 + if (check_heap_stack_gap(vma, addr, len, offset))
23281 + return addr;
23282 + }
23283 + }
23284 +
23285 + /* check if free_area_cache is useful for us */
23286 + if (len <= mm->cached_hole_size) {
23287 + mm->cached_hole_size = 0;
23288 + mm->free_area_cache = mm->mmap_base;
23289 + }
23290 +
23291 + /* either no address requested or can't fit in requested address hole */
23292 + addr = mm->free_area_cache;
23293 +
23294 + /* make sure it can fit in the remaining address space */
23295 + if (addr > len) {
23296 + vma = find_vma(mm, addr-len);
23297 + if (check_heap_stack_gap(vma, addr - len, len, offset))
23298 + /* remember the address as a hint for next time */
23299 + return (mm->free_area_cache = addr-len);
23300 + }
23301 +
23302 + if (mm->mmap_base < len)
23303 + goto bottomup;
23304 +
23305 + addr = mm->mmap_base-len;
23306 +
23307 + do {
23308 + /*
23309 + * Lookup failure means no vma is above this address,
23310 + * else if new region fits below vma->vm_start,
23311 + * return with success:
23312 + */
23313 + vma = find_vma(mm, addr);
23314 + if (check_heap_stack_gap(vma, addr, len, offset))
23315 + /* remember the address as a hint for next time */
23316 + return (mm->free_area_cache = addr);
23317 +
23318 + /* remember the largest hole we saw so far */
23319 + if (addr + mm->cached_hole_size < vma->vm_start)
23320 + mm->cached_hole_size = vma->vm_start - addr;
23321 +
23322 + /* try just below the current vma->vm_start */
23323 + addr = skip_heap_stack_gap(vma, len, offset);
23324 + } while (!IS_ERR_VALUE(addr));
23325 +
23326 +bottomup:
23327 + /*
23328 + * A failed mmap() very likely causes application failure,
23329 + * so fall back to the bottom-up function here. This scenario
23330 + * can happen with large stack limits and large mmap()
23331 + * allocations.
23332 + */
23333 +
23334 +#ifdef CONFIG_PAX_SEGMEXEC
23335 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23336 + mm->mmap_base = SEGMEXEC_TASK_UNMAPPED_BASE;
23337 + else
23338 +#endif
23339 +
23340 + mm->mmap_base = TASK_UNMAPPED_BASE;
23341 +
23342 +#ifdef CONFIG_PAX_RANDMMAP
23343 + if (mm->pax_flags & MF_PAX_RANDMMAP)
23344 + mm->mmap_base += mm->delta_mmap;
23345 +#endif
23346 +
23347 + mm->free_area_cache = mm->mmap_base;
23348 + mm->cached_hole_size = ~0UL;
23349 + addr = arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23350 + /*
23351 + * Restore the topdown base:
23352 + */
23353 + mm->mmap_base = base;
23354 + mm->free_area_cache = base;
23355 + mm->cached_hole_size = ~0UL;
23356 +
23357 + return addr;
23358 +}
23359 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23360 index 97ef74b..57a1882 100644
23361 --- a/arch/x86/kernel/sys_x86_64.c
23362 +++ b/arch/x86/kernel/sys_x86_64.c
23363 @@ -81,8 +81,8 @@ out:
23364 return error;
23365 }
23366
23367 -static void find_start_end(unsigned long flags, unsigned long *begin,
23368 - unsigned long *end)
23369 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23370 + unsigned long *begin, unsigned long *end)
23371 {
23372 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23373 unsigned long new_begin;
23374 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23375 *begin = new_begin;
23376 }
23377 } else {
23378 - *begin = TASK_UNMAPPED_BASE;
23379 + *begin = mm->mmap_base;
23380 *end = TASK_SIZE;
23381 }
23382 }
23383 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23384 struct vm_area_struct *vma;
23385 struct vm_unmapped_area_info info;
23386 unsigned long begin, end;
23387 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23388
23389 if (flags & MAP_FIXED)
23390 return addr;
23391
23392 - find_start_end(flags, &begin, &end);
23393 + find_start_end(mm, flags, &begin, &end);
23394
23395 if (len > end)
23396 return -ENOMEM;
23397
23398 +#ifdef CONFIG_PAX_RANDMMAP
23399 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23400 +#endif
23401 +
23402 if (addr) {
23403 addr = PAGE_ALIGN(addr);
23404 vma = find_vma(mm, addr);
23405 - if (end - len >= addr &&
23406 - (!vma || addr + len <= vma->vm_start))
23407 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23408 return addr;
23409 }
23410
23411 @@ -161,6 +165,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23412 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23413 goto bottomup;
23414
23415 +#ifdef CONFIG_PAX_RANDMMAP
23416 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23417 +#endif
23418 +
23419 /* requesting a specific address */
23420 if (addr) {
23421 addr = PAGE_ALIGN(addr);
23422 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23423 index f84fe00..f41d9f1 100644
23424 --- a/arch/x86/kernel/tboot.c
23425 +++ b/arch/x86/kernel/tboot.c
23426 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23427
23428 void tboot_shutdown(u32 shutdown_type)
23429 {
23430 - void (*shutdown)(void);
23431 + void (* __noreturn shutdown)(void);
23432
23433 if (!tboot_enabled())
23434 return;
23435 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23436
23437 switch_to_tboot_pt();
23438
23439 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23440 + shutdown = (void *)tboot->shutdown_entry;
23441 shutdown();
23442
23443 /* should not reach here */
23444 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23445 return 0;
23446 }
23447
23448 -static atomic_t ap_wfs_count;
23449 +static atomic_unchecked_t ap_wfs_count;
23450
23451 static int tboot_wait_for_aps(int num_aps)
23452 {
23453 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23454 {
23455 switch (action) {
23456 case CPU_DYING:
23457 - atomic_inc(&ap_wfs_count);
23458 + atomic_inc_unchecked(&ap_wfs_count);
23459 if (num_online_cpus() == 1)
23460 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23461 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23462 return NOTIFY_BAD;
23463 break;
23464 }
23465 return NOTIFY_OK;
23466 }
23467
23468 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23469 +static struct notifier_block tboot_cpu_notifier =
23470 {
23471 .notifier_call = tboot_cpu_callback,
23472 };
23473 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23474
23475 tboot_create_trampoline();
23476
23477 - atomic_set(&ap_wfs_count, 0);
23478 + atomic_set_unchecked(&ap_wfs_count, 0);
23479 register_hotcpu_notifier(&tboot_cpu_notifier);
23480
23481 acpi_os_set_prepare_sleep(&tboot_sleep);
23482 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23483 index 24d3c91..d06b473 100644
23484 --- a/arch/x86/kernel/time.c
23485 +++ b/arch/x86/kernel/time.c
23486 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23487 {
23488 unsigned long pc = instruction_pointer(regs);
23489
23490 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23491 + if (!user_mode(regs) && in_lock_functions(pc)) {
23492 #ifdef CONFIG_FRAME_POINTER
23493 - return *(unsigned long *)(regs->bp + sizeof(long));
23494 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23495 #else
23496 unsigned long *sp =
23497 (unsigned long *)kernel_stack_pointer(regs);
23498 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23499 * or above a saved flags. Eflags has bits 22-31 zero,
23500 * kernel addresses don't.
23501 */
23502 +
23503 +#ifdef CONFIG_PAX_KERNEXEC
23504 + return ktla_ktva(sp[0]);
23505 +#else
23506 if (sp[0] >> 22)
23507 return sp[0];
23508 if (sp[1] >> 22)
23509 return sp[1];
23510 #endif
23511 +
23512 +#endif
23513 }
23514 return pc;
23515 }
23516 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23517 index 9d9d2f9..cad418a 100644
23518 --- a/arch/x86/kernel/tls.c
23519 +++ b/arch/x86/kernel/tls.c
23520 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23521 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23522 return -EINVAL;
23523
23524 +#ifdef CONFIG_PAX_SEGMEXEC
23525 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23526 + return -EINVAL;
23527 +#endif
23528 +
23529 set_tls_desc(p, idx, &info, 1);
23530
23531 return 0;
23532 @@ -204,7 +209,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23533
23534 if (kbuf)
23535 info = kbuf;
23536 - else if (__copy_from_user(infobuf, ubuf, count))
23537 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23538 return -EFAULT;
23539 else
23540 info = infobuf;
23541 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23542 index ecffca1..95c4d13 100644
23543 --- a/arch/x86/kernel/traps.c
23544 +++ b/arch/x86/kernel/traps.c
23545 @@ -68,12 +68,6 @@
23546 #include <asm/setup.h>
23547
23548 asmlinkage int system_call(void);
23549 -
23550 -/*
23551 - * The IDT has to be page-aligned to simplify the Pentium
23552 - * F0 0F bug workaround.
23553 - */
23554 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23555 #endif
23556
23557 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23558 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23559 }
23560
23561 static int __kprobes
23562 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23563 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23564 struct pt_regs *regs, long error_code)
23565 {
23566 #ifdef CONFIG_X86_32
23567 - if (regs->flags & X86_VM_MASK) {
23568 + if (v8086_mode(regs)) {
23569 /*
23570 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23571 * On nmi (interrupt 2), do_trap should not be called.
23572 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23573 return -1;
23574 }
23575 #endif
23576 - if (!user_mode(regs)) {
23577 + if (!user_mode_novm(regs)) {
23578 if (!fixup_exception(regs)) {
23579 tsk->thread.error_code = error_code;
23580 tsk->thread.trap_nr = trapnr;
23581 +
23582 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23583 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23584 + str = "PAX: suspicious stack segment fault";
23585 +#endif
23586 +
23587 die(str, regs, error_code);
23588 }
23589 +
23590 +#ifdef CONFIG_PAX_REFCOUNT
23591 + if (trapnr == 4)
23592 + pax_report_refcount_overflow(regs);
23593 +#endif
23594 +
23595 return 0;
23596 }
23597
23598 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23599 }
23600
23601 static void __kprobes
23602 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23603 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23604 long error_code, siginfo_t *info)
23605 {
23606 struct task_struct *tsk = current;
23607 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23608 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23609 printk_ratelimit()) {
23610 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23611 - tsk->comm, tsk->pid, str,
23612 + tsk->comm, task_pid_nr(tsk), str,
23613 regs->ip, regs->sp, error_code);
23614 print_vma_addr(" in ", regs->ip);
23615 pr_cont("\n");
23616 @@ -266,7 +272,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23617 conditional_sti(regs);
23618
23619 #ifdef CONFIG_X86_32
23620 - if (regs->flags & X86_VM_MASK) {
23621 + if (v8086_mode(regs)) {
23622 local_irq_enable();
23623 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23624 goto exit;
23625 @@ -274,18 +280,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23626 #endif
23627
23628 tsk = current;
23629 - if (!user_mode(regs)) {
23630 + if (!user_mode_novm(regs)) {
23631 if (fixup_exception(regs))
23632 goto exit;
23633
23634 tsk->thread.error_code = error_code;
23635 tsk->thread.trap_nr = X86_TRAP_GP;
23636 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23637 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23638 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23639 +
23640 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23641 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23642 + die("PAX: suspicious general protection fault", regs, error_code);
23643 + else
23644 +#endif
23645 +
23646 die("general protection fault", regs, error_code);
23647 + }
23648 goto exit;
23649 }
23650
23651 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23652 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23653 + struct mm_struct *mm = tsk->mm;
23654 + unsigned long limit;
23655 +
23656 + down_write(&mm->mmap_sem);
23657 + limit = mm->context.user_cs_limit;
23658 + if (limit < TASK_SIZE) {
23659 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23660 + up_write(&mm->mmap_sem);
23661 + return;
23662 + }
23663 + up_write(&mm->mmap_sem);
23664 + }
23665 +#endif
23666 +
23667 tsk->thread.error_code = error_code;
23668 tsk->thread.trap_nr = X86_TRAP_GP;
23669
23670 @@ -440,7 +470,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23671 /* It's safe to allow irq's after DR6 has been saved */
23672 preempt_conditional_sti(regs);
23673
23674 - if (regs->flags & X86_VM_MASK) {
23675 + if (v8086_mode(regs)) {
23676 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23677 X86_TRAP_DB);
23678 preempt_conditional_cli(regs);
23679 @@ -455,7 +485,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23680 * We already checked v86 mode above, so we can check for kernel mode
23681 * by just checking the CPL of CS.
23682 */
23683 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23684 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23685 tsk->thread.debugreg6 &= ~DR_STEP;
23686 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23687 regs->flags &= ~X86_EFLAGS_TF;
23688 @@ -487,7 +517,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23689 return;
23690 conditional_sti(regs);
23691
23692 - if (!user_mode_vm(regs))
23693 + if (!user_mode(regs))
23694 {
23695 if (!fixup_exception(regs)) {
23696 task->thread.error_code = error_code;
23697 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23698 index c71025b..b117501 100644
23699 --- a/arch/x86/kernel/uprobes.c
23700 +++ b/arch/x86/kernel/uprobes.c
23701 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23702 int ret = NOTIFY_DONE;
23703
23704 /* We are only interested in userspace traps */
23705 - if (regs && !user_mode_vm(regs))
23706 + if (regs && !user_mode(regs))
23707 return NOTIFY_DONE;
23708
23709 switch (val) {
23710 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23711 index b9242ba..50c5edd 100644
23712 --- a/arch/x86/kernel/verify_cpu.S
23713 +++ b/arch/x86/kernel/verify_cpu.S
23714 @@ -20,6 +20,7 @@
23715 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23716 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23717 * arch/x86/kernel/head_32.S: processor startup
23718 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23719 *
23720 * verify_cpu, returns the status of longmode and SSE in register %eax.
23721 * 0: Success 1: Failure
23722 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23723 index 1dfe69c..a3df6f6 100644
23724 --- a/arch/x86/kernel/vm86_32.c
23725 +++ b/arch/x86/kernel/vm86_32.c
23726 @@ -43,6 +43,7 @@
23727 #include <linux/ptrace.h>
23728 #include <linux/audit.h>
23729 #include <linux/stddef.h>
23730 +#include <linux/grsecurity.h>
23731
23732 #include <asm/uaccess.h>
23733 #include <asm/io.h>
23734 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23735 do_exit(SIGSEGV);
23736 }
23737
23738 - tss = &per_cpu(init_tss, get_cpu());
23739 + tss = init_tss + get_cpu();
23740 current->thread.sp0 = current->thread.saved_sp0;
23741 current->thread.sysenter_cs = __KERNEL_CS;
23742 load_sp0(tss, &current->thread);
23743 @@ -212,6 +213,13 @@ int sys_vm86old(struct vm86_struct __user *v86, struct pt_regs *regs)
23744 struct task_struct *tsk;
23745 int tmp, ret = -EPERM;
23746
23747 +#ifdef CONFIG_GRKERNSEC_VM86
23748 + if (!capable(CAP_SYS_RAWIO)) {
23749 + gr_handle_vm86();
23750 + goto out;
23751 + }
23752 +#endif
23753 +
23754 tsk = current;
23755 if (tsk->thread.saved_sp0)
23756 goto out;
23757 @@ -242,6 +250,14 @@ int sys_vm86(unsigned long cmd, unsigned long arg, struct pt_regs *regs)
23758 int tmp, ret;
23759 struct vm86plus_struct __user *v86;
23760
23761 +#ifdef CONFIG_GRKERNSEC_VM86
23762 + if (!capable(CAP_SYS_RAWIO)) {
23763 + gr_handle_vm86();
23764 + ret = -EPERM;
23765 + goto out;
23766 + }
23767 +#endif
23768 +
23769 tsk = current;
23770 switch (cmd) {
23771 case VM86_REQUEST_IRQ:
23772 @@ -328,7 +344,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23773 tsk->thread.saved_fs = info->regs32->fs;
23774 tsk->thread.saved_gs = get_user_gs(info->regs32);
23775
23776 - tss = &per_cpu(init_tss, get_cpu());
23777 + tss = init_tss + get_cpu();
23778 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23779 if (cpu_has_sep)
23780 tsk->thread.sysenter_cs = 0;
23781 @@ -535,7 +551,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23782 goto cannot_handle;
23783 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23784 goto cannot_handle;
23785 - intr_ptr = (unsigned long __user *) (i << 2);
23786 + intr_ptr = (__force unsigned long __user *) (i << 2);
23787 if (get_user(segoffs, intr_ptr))
23788 goto cannot_handle;
23789 if ((segoffs >> 16) == BIOSSEG)
23790 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23791 index 22a1530..8fbaaad 100644
23792 --- a/arch/x86/kernel/vmlinux.lds.S
23793 +++ b/arch/x86/kernel/vmlinux.lds.S
23794 @@ -26,6 +26,13 @@
23795 #include <asm/page_types.h>
23796 #include <asm/cache.h>
23797 #include <asm/boot.h>
23798 +#include <asm/segment.h>
23799 +
23800 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23801 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23802 +#else
23803 +#define __KERNEL_TEXT_OFFSET 0
23804 +#endif
23805
23806 #undef i386 /* in case the preprocessor is a 32bit one */
23807
23808 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23809
23810 PHDRS {
23811 text PT_LOAD FLAGS(5); /* R_E */
23812 +#ifdef CONFIG_X86_32
23813 + module PT_LOAD FLAGS(5); /* R_E */
23814 +#endif
23815 +#ifdef CONFIG_XEN
23816 + rodata PT_LOAD FLAGS(5); /* R_E */
23817 +#else
23818 + rodata PT_LOAD FLAGS(4); /* R__ */
23819 +#endif
23820 data PT_LOAD FLAGS(6); /* RW_ */
23821 -#ifdef CONFIG_X86_64
23822 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23823 #ifdef CONFIG_SMP
23824 percpu PT_LOAD FLAGS(6); /* RW_ */
23825 #endif
23826 + text.init PT_LOAD FLAGS(5); /* R_E */
23827 + text.exit PT_LOAD FLAGS(5); /* R_E */
23828 init PT_LOAD FLAGS(7); /* RWE */
23829 -#endif
23830 note PT_NOTE FLAGS(0); /* ___ */
23831 }
23832
23833 SECTIONS
23834 {
23835 #ifdef CONFIG_X86_32
23836 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23837 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23838 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23839 #else
23840 - . = __START_KERNEL;
23841 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23842 + . = __START_KERNEL;
23843 #endif
23844
23845 /* Text and read-only data */
23846 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23847 - _text = .;
23848 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23849 /* bootstrapping code */
23850 +#ifdef CONFIG_X86_32
23851 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23852 +#else
23853 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23854 +#endif
23855 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23856 + _text = .;
23857 HEAD_TEXT
23858 #ifdef CONFIG_X86_32
23859 . = ALIGN(PAGE_SIZE);
23860 @@ -108,13 +128,48 @@ SECTIONS
23861 IRQENTRY_TEXT
23862 *(.fixup)
23863 *(.gnu.warning)
23864 - /* End of text section */
23865 - _etext = .;
23866 } :text = 0x9090
23867
23868 - NOTES :text :note
23869 + . += __KERNEL_TEXT_OFFSET;
23870
23871 - EXCEPTION_TABLE(16) :text = 0x9090
23872 +#ifdef CONFIG_X86_32
23873 + . = ALIGN(PAGE_SIZE);
23874 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23875 +
23876 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_MODULES)
23877 + MODULES_EXEC_VADDR = .;
23878 + BYTE(0)
23879 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23880 + . = ALIGN(HPAGE_SIZE) - 1;
23881 + MODULES_EXEC_END = .;
23882 +#endif
23883 +
23884 + } :module
23885 +#endif
23886 +
23887 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23888 + /* End of text section */
23889 + BYTE(0)
23890 + _etext = . - __KERNEL_TEXT_OFFSET;
23891 + }
23892 +
23893 +#ifdef CONFIG_X86_32
23894 + . = ALIGN(PAGE_SIZE);
23895 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23896 + *(.idt)
23897 + . = ALIGN(PAGE_SIZE);
23898 + *(.empty_zero_page)
23899 + *(.initial_pg_fixmap)
23900 + *(.initial_pg_pmd)
23901 + *(.initial_page_table)
23902 + *(.swapper_pg_dir)
23903 + } :rodata
23904 +#endif
23905 +
23906 + . = ALIGN(PAGE_SIZE);
23907 + NOTES :rodata :note
23908 +
23909 + EXCEPTION_TABLE(16) :rodata
23910
23911 #if defined(CONFIG_DEBUG_RODATA)
23912 /* .text should occupy whole number of pages */
23913 @@ -126,16 +181,20 @@ SECTIONS
23914
23915 /* Data */
23916 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23917 +
23918 +#ifdef CONFIG_PAX_KERNEXEC
23919 + . = ALIGN(HPAGE_SIZE);
23920 +#else
23921 + . = ALIGN(PAGE_SIZE);
23922 +#endif
23923 +
23924 /* Start of data section */
23925 _sdata = .;
23926
23927 /* init_task */
23928 INIT_TASK_DATA(THREAD_SIZE)
23929
23930 -#ifdef CONFIG_X86_32
23931 - /* 32 bit has nosave before _edata */
23932 NOSAVE_DATA
23933 -#endif
23934
23935 PAGE_ALIGNED_DATA(PAGE_SIZE)
23936
23937 @@ -176,12 +235,19 @@ SECTIONS
23938 #endif /* CONFIG_X86_64 */
23939
23940 /* Init code and data - will be freed after init */
23941 - . = ALIGN(PAGE_SIZE);
23942 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23943 + BYTE(0)
23944 +
23945 +#ifdef CONFIG_PAX_KERNEXEC
23946 + . = ALIGN(HPAGE_SIZE);
23947 +#else
23948 + . = ALIGN(PAGE_SIZE);
23949 +#endif
23950 +
23951 __init_begin = .; /* paired with __init_end */
23952 - }
23953 + } :init.begin
23954
23955 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23956 +#ifdef CONFIG_SMP
23957 /*
23958 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23959 * output PHDR, so the next output section - .init.text - should
23960 @@ -190,12 +256,27 @@ SECTIONS
23961 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23962 #endif
23963
23964 - INIT_TEXT_SECTION(PAGE_SIZE)
23965 -#ifdef CONFIG_X86_64
23966 - :init
23967 -#endif
23968 + . = ALIGN(PAGE_SIZE);
23969 + init_begin = .;
23970 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23971 + VMLINUX_SYMBOL(_sinittext) = .;
23972 + INIT_TEXT
23973 + VMLINUX_SYMBOL(_einittext) = .;
23974 + . = ALIGN(PAGE_SIZE);
23975 + } :text.init
23976
23977 - INIT_DATA_SECTION(16)
23978 + /*
23979 + * .exit.text is discard at runtime, not link time, to deal with
23980 + * references from .altinstructions and .eh_frame
23981 + */
23982 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23983 + EXIT_TEXT
23984 + . = ALIGN(16);
23985 + } :text.exit
23986 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23987 +
23988 + . = ALIGN(PAGE_SIZE);
23989 + INIT_DATA_SECTION(16) :init
23990
23991 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23992 __x86_cpu_dev_start = .;
23993 @@ -257,19 +338,12 @@ SECTIONS
23994 }
23995
23996 . = ALIGN(8);
23997 - /*
23998 - * .exit.text is discard at runtime, not link time, to deal with
23999 - * references from .altinstructions and .eh_frame
24000 - */
24001 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
24002 - EXIT_TEXT
24003 - }
24004
24005 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
24006 EXIT_DATA
24007 }
24008
24009 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
24010 +#ifndef CONFIG_SMP
24011 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
24012 #endif
24013
24014 @@ -288,16 +362,10 @@ SECTIONS
24015 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
24016 __smp_locks = .;
24017 *(.smp_locks)
24018 - . = ALIGN(PAGE_SIZE);
24019 __smp_locks_end = .;
24020 + . = ALIGN(PAGE_SIZE);
24021 }
24022
24023 -#ifdef CONFIG_X86_64
24024 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
24025 - NOSAVE_DATA
24026 - }
24027 -#endif
24028 -
24029 /* BSS */
24030 . = ALIGN(PAGE_SIZE);
24031 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
24032 @@ -313,6 +381,7 @@ SECTIONS
24033 __brk_base = .;
24034 . += 64 * 1024; /* 64k alignment slop space */
24035 *(.brk_reservation) /* areas brk users have reserved */
24036 + . = ALIGN(HPAGE_SIZE);
24037 __brk_limit = .;
24038 }
24039
24040 @@ -339,13 +408,12 @@ SECTIONS
24041 * for the boot processor.
24042 */
24043 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
24044 -INIT_PER_CPU(gdt_page);
24045 INIT_PER_CPU(irq_stack_union);
24046
24047 /*
24048 * Build-time check on the image size:
24049 */
24050 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
24051 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
24052 "kernel image bigger than KERNEL_IMAGE_SIZE");
24053
24054 #ifdef CONFIG_SMP
24055 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
24056 index 9a907a6..f83f921 100644
24057 --- a/arch/x86/kernel/vsyscall_64.c
24058 +++ b/arch/x86/kernel/vsyscall_64.c
24059 @@ -56,15 +56,13 @@
24060 DEFINE_VVAR(int, vgetcpu_mode);
24061 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
24062
24063 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
24064 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
24065
24066 static int __init vsyscall_setup(char *str)
24067 {
24068 if (str) {
24069 if (!strcmp("emulate", str))
24070 vsyscall_mode = EMULATE;
24071 - else if (!strcmp("native", str))
24072 - vsyscall_mode = NATIVE;
24073 else if (!strcmp("none", str))
24074 vsyscall_mode = NONE;
24075 else
24076 @@ -323,8 +321,7 @@ do_ret:
24077 return true;
24078
24079 sigsegv:
24080 - force_sig(SIGSEGV, current);
24081 - return true;
24082 + do_group_exit(SIGKILL);
24083 }
24084
24085 /*
24086 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
24087 extern char __vvar_page;
24088 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
24089
24090 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
24091 - vsyscall_mode == NATIVE
24092 - ? PAGE_KERNEL_VSYSCALL
24093 - : PAGE_KERNEL_VVAR);
24094 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
24095 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
24096 (unsigned long)VSYSCALL_START);
24097
24098 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
24099 index 1330dd1..d220b99 100644
24100 --- a/arch/x86/kernel/x8664_ksyms_64.c
24101 +++ b/arch/x86/kernel/x8664_ksyms_64.c
24102 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
24103 EXPORT_SYMBOL(copy_user_generic_unrolled);
24104 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
24105 EXPORT_SYMBOL(__copy_user_nocache);
24106 -EXPORT_SYMBOL(_copy_from_user);
24107 -EXPORT_SYMBOL(_copy_to_user);
24108
24109 EXPORT_SYMBOL(copy_page);
24110 EXPORT_SYMBOL(clear_page);
24111 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
24112 index 7a3d075..6cb373d 100644
24113 --- a/arch/x86/kernel/x86_init.c
24114 +++ b/arch/x86/kernel/x86_init.c
24115 @@ -88,7 +88,7 @@ struct x86_init_ops x86_init __initdata = {
24116 },
24117 };
24118
24119 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24120 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
24121 .early_percpu_clock_init = x86_init_noop,
24122 .setup_percpu_clockev = setup_secondary_APIC_clock,
24123 };
24124 @@ -96,7 +96,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
24125 static void default_nmi_init(void) { };
24126 static int default_i8042_detect(void) { return 1; };
24127
24128 -struct x86_platform_ops x86_platform = {
24129 +struct x86_platform_ops x86_platform __read_only = {
24130 .calibrate_tsc = native_calibrate_tsc,
24131 .get_wallclock = mach_get_cmos_time,
24132 .set_wallclock = mach_set_rtc_mmss,
24133 @@ -110,14 +110,14 @@ struct x86_platform_ops x86_platform = {
24134 };
24135
24136 EXPORT_SYMBOL_GPL(x86_platform);
24137 -struct x86_msi_ops x86_msi = {
24138 +struct x86_msi_ops x86_msi __read_only = {
24139 .setup_msi_irqs = native_setup_msi_irqs,
24140 .teardown_msi_irq = native_teardown_msi_irq,
24141 .teardown_msi_irqs = default_teardown_msi_irqs,
24142 .restore_msi_irqs = default_restore_msi_irqs,
24143 };
24144
24145 -struct x86_io_apic_ops x86_io_apic_ops = {
24146 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
24147 .init = native_io_apic_init_mappings,
24148 .read = native_io_apic_read,
24149 .write = native_io_apic_write,
24150 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
24151 index ada87a3..afea76d 100644
24152 --- a/arch/x86/kernel/xsave.c
24153 +++ b/arch/x86/kernel/xsave.c
24154 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
24155 {
24156 int err;
24157
24158 + buf = (struct xsave_struct __user *)____m(buf);
24159 if (use_xsave())
24160 err = xsave_user(buf);
24161 else if (use_fxsr())
24162 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
24163 */
24164 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
24165 {
24166 + buf = (void __user *)____m(buf);
24167 if (use_xsave()) {
24168 if ((unsigned long)buf % 64 || fx_only) {
24169 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
24170 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
24171 index a20ecb5..d0e2194 100644
24172 --- a/arch/x86/kvm/cpuid.c
24173 +++ b/arch/x86/kvm/cpuid.c
24174 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
24175 struct kvm_cpuid2 *cpuid,
24176 struct kvm_cpuid_entry2 __user *entries)
24177 {
24178 - int r;
24179 + int r, i;
24180
24181 r = -E2BIG;
24182 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
24183 goto out;
24184 r = -EFAULT;
24185 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
24186 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24187 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
24188 goto out;
24189 + for (i = 0; i < cpuid->nent; ++i) {
24190 + struct kvm_cpuid_entry2 cpuid_entry;
24191 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
24192 + goto out;
24193 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
24194 + }
24195 vcpu->arch.cpuid_nent = cpuid->nent;
24196 kvm_apic_set_version(vcpu);
24197 kvm_x86_ops->cpuid_update(vcpu);
24198 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
24199 struct kvm_cpuid2 *cpuid,
24200 struct kvm_cpuid_entry2 __user *entries)
24201 {
24202 - int r;
24203 + int r, i;
24204
24205 r = -E2BIG;
24206 if (cpuid->nent < vcpu->arch.cpuid_nent)
24207 goto out;
24208 r = -EFAULT;
24209 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
24210 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24211 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
24212 goto out;
24213 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
24214 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
24215 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
24216 + goto out;
24217 + }
24218 return 0;
24219
24220 out:
24221 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
24222 index a27e763..54bfe43 100644
24223 --- a/arch/x86/kvm/emulate.c
24224 +++ b/arch/x86/kvm/emulate.c
24225 @@ -292,6 +292,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24226
24227 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
24228 do { \
24229 + unsigned long _tmp; \
24230 __asm__ __volatile__ ( \
24231 _PRE_EFLAGS("0", "4", "2") \
24232 _op _suffix " %"_x"3,%1; " \
24233 @@ -306,8 +307,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24234 /* Raw emulation: instruction has two explicit operands. */
24235 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
24236 do { \
24237 - unsigned long _tmp; \
24238 - \
24239 switch ((ctxt)->dst.bytes) { \
24240 case 2: \
24241 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
24242 @@ -323,7 +322,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
24243
24244 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24245 do { \
24246 - unsigned long _tmp; \
24247 switch ((ctxt)->dst.bytes) { \
24248 case 1: \
24249 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24250 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24251 index 9392f52..0e56d77 100644
24252 --- a/arch/x86/kvm/lapic.c
24253 +++ b/arch/x86/kvm/lapic.c
24254 @@ -55,7 +55,7 @@
24255 #define APIC_BUS_CYCLE_NS 1
24256
24257 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24258 -#define apic_debug(fmt, arg...)
24259 +#define apic_debug(fmt, arg...) do {} while (0)
24260
24261 #define APIC_LVT_NUM 6
24262 /* 14 is the version for Xeon and Pentium 8.4.8*/
24263 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24264 index 891eb6d..e027900 100644
24265 --- a/arch/x86/kvm/paging_tmpl.h
24266 +++ b/arch/x86/kvm/paging_tmpl.h
24267 @@ -208,7 +208,7 @@ retry_walk:
24268 if (unlikely(kvm_is_error_hva(host_addr)))
24269 goto error;
24270
24271 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24272 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24273 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24274 goto error;
24275 walker->ptep_user[walker->level - 1] = ptep_user;
24276 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24277 index d29d3cd..ec9d522 100644
24278 --- a/arch/x86/kvm/svm.c
24279 +++ b/arch/x86/kvm/svm.c
24280 @@ -3507,7 +3507,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24281 int cpu = raw_smp_processor_id();
24282
24283 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24284 +
24285 + pax_open_kernel();
24286 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24287 + pax_close_kernel();
24288 +
24289 load_TR_desc();
24290 }
24291
24292 @@ -3881,6 +3885,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24293 #endif
24294 #endif
24295
24296 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24297 + __set_fs(current_thread_info()->addr_limit);
24298 +#endif
24299 +
24300 reload_tss(vcpu);
24301
24302 local_irq_disable();
24303 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24304 index 9120ae1..238abc0 100644
24305 --- a/arch/x86/kvm/vmx.c
24306 +++ b/arch/x86/kvm/vmx.c
24307 @@ -1370,7 +1370,11 @@ static void reload_tss(void)
24308 struct desc_struct *descs;
24309
24310 descs = (void *)gdt->address;
24311 +
24312 + pax_open_kernel();
24313 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24314 + pax_close_kernel();
24315 +
24316 load_TR_desc();
24317 }
24318
24319 @@ -1594,6 +1598,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24320 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24321 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24322
24323 +#ifdef CONFIG_PAX_PER_CPU_PGD
24324 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24325 +#endif
24326 +
24327 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24328 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24329 vmx->loaded_vmcs->cpu = cpu;
24330 @@ -2738,8 +2746,11 @@ static __init int hardware_setup(void)
24331 if (!cpu_has_vmx_flexpriority())
24332 flexpriority_enabled = 0;
24333
24334 - if (!cpu_has_vmx_tpr_shadow())
24335 - kvm_x86_ops->update_cr8_intercept = NULL;
24336 + if (!cpu_has_vmx_tpr_shadow()) {
24337 + pax_open_kernel();
24338 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24339 + pax_close_kernel();
24340 + }
24341
24342 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24343 kvm_disable_largepages();
24344 @@ -3782,7 +3793,10 @@ static void vmx_set_constant_host_state(void)
24345
24346 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24347 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24348 +
24349 +#ifndef CONFIG_PAX_PER_CPU_PGD
24350 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24351 +#endif
24352
24353 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24354 #ifdef CONFIG_X86_64
24355 @@ -3803,7 +3817,7 @@ static void vmx_set_constant_host_state(void)
24356 native_store_idt(&dt);
24357 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24358
24359 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24360 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24361
24362 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24363 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24364 @@ -6355,6 +6369,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24365 "jmp 2f \n\t"
24366 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24367 "2: "
24368 +
24369 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24370 + "ljmp %[cs],$3f\n\t"
24371 + "3: "
24372 +#endif
24373 +
24374 /* Save guest registers, load host registers, keep flags */
24375 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24376 "pop %0 \n\t"
24377 @@ -6407,6 +6427,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24378 #endif
24379 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24380 [wordsize]"i"(sizeof(ulong))
24381 +
24382 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24383 + ,[cs]"i"(__KERNEL_CS)
24384 +#endif
24385 +
24386 : "cc", "memory"
24387 #ifdef CONFIG_X86_64
24388 , "rax", "rbx", "rdi", "rsi"
24389 @@ -6420,7 +6445,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24390 if (debugctlmsr)
24391 update_debugctlmsr(debugctlmsr);
24392
24393 -#ifndef CONFIG_X86_64
24394 +#ifdef CONFIG_X86_32
24395 /*
24396 * The sysexit path does not restore ds/es, so we must set them to
24397 * a reasonable value ourselves.
24398 @@ -6429,8 +6454,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24399 * may be executed in interrupt context, which saves and restore segments
24400 * around it, nullifying its effect.
24401 */
24402 - loadsegment(ds, __USER_DS);
24403 - loadsegment(es, __USER_DS);
24404 + loadsegment(ds, __KERNEL_DS);
24405 + loadsegment(es, __KERNEL_DS);
24406 + loadsegment(ss, __KERNEL_DS);
24407 +
24408 +#ifdef CONFIG_PAX_KERNEXEC
24409 + loadsegment(fs, __KERNEL_PERCPU);
24410 +#endif
24411 +
24412 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24413 + __set_fs(current_thread_info()->addr_limit);
24414 +#endif
24415 +
24416 #endif
24417
24418 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24419 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24420 index c243b81..b692af3 100644
24421 --- a/arch/x86/kvm/x86.c
24422 +++ b/arch/x86/kvm/x86.c
24423 @@ -1408,10 +1408,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24424 unsigned long flags, this_tsc_khz;
24425 struct kvm_vcpu_arch *vcpu = &v->arch;
24426 struct kvm_arch *ka = &v->kvm->arch;
24427 - void *shared_kaddr;
24428 s64 kernel_ns, max_kernel_ns;
24429 u64 tsc_timestamp, host_tsc;
24430 - struct pvclock_vcpu_time_info *guest_hv_clock;
24431 + struct pvclock_vcpu_time_info guest_hv_clock;
24432 u8 pvclock_flags;
24433 bool use_master_clock;
24434
24435 @@ -1465,7 +1464,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24436
24437 local_irq_restore(flags);
24438
24439 - if (!vcpu->time_page)
24440 + if (!vcpu->pv_time_enabled)
24441 return 0;
24442
24443 /*
24444 @@ -1527,12 +1526,12 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24445 */
24446 vcpu->hv_clock.version += 2;
24447
24448 - shared_kaddr = kmap_atomic(vcpu->time_page);
24449 -
24450 - guest_hv_clock = shared_kaddr + vcpu->time_offset;
24451 + if (unlikely(kvm_read_guest_cached(v->kvm, &vcpu->pv_time,
24452 + &guest_hv_clock, sizeof(guest_hv_clock))))
24453 + return 0;
24454
24455 /* retain PVCLOCK_GUEST_STOPPED if set in guest copy */
24456 - pvclock_flags = (guest_hv_clock->flags & PVCLOCK_GUEST_STOPPED);
24457 + pvclock_flags = (guest_hv_clock.flags & PVCLOCK_GUEST_STOPPED);
24458
24459 if (vcpu->pvclock_set_guest_stopped_request) {
24460 pvclock_flags |= PVCLOCK_GUEST_STOPPED;
24461 @@ -1545,12 +1544,9 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
24462
24463 vcpu->hv_clock.flags = pvclock_flags;
24464
24465 - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock,
24466 - sizeof(vcpu->hv_clock));
24467 -
24468 - kunmap_atomic(shared_kaddr);
24469 -
24470 - mark_page_dirty(v->kvm, vcpu->time >> PAGE_SHIFT);
24471 + kvm_write_guest_cached(v->kvm, &vcpu->pv_time,
24472 + &vcpu->hv_clock,
24473 + sizeof(vcpu->hv_clock));
24474 return 0;
24475 }
24476
24477 @@ -1692,8 +1688,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24478 {
24479 struct kvm *kvm = vcpu->kvm;
24480 int lm = is_long_mode(vcpu);
24481 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24482 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24483 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24484 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24485 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24486 : kvm->arch.xen_hvm_config.blob_size_32;
24487 u32 page_num = data & ~PAGE_MASK;
24488 @@ -1839,10 +1835,7 @@ static int kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
24489
24490 static void kvmclock_reset(struct kvm_vcpu *vcpu)
24491 {
24492 - if (vcpu->arch.time_page) {
24493 - kvm_release_page_dirty(vcpu->arch.time_page);
24494 - vcpu->arch.time_page = NULL;
24495 - }
24496 + vcpu->arch.pv_time_enabled = false;
24497 }
24498
24499 static void accumulate_steal_time(struct kvm_vcpu *vcpu)
24500 @@ -1948,6 +1941,7 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24501 break;
24502 case MSR_KVM_SYSTEM_TIME_NEW:
24503 case MSR_KVM_SYSTEM_TIME: {
24504 + u64 gpa_offset;
24505 kvmclock_reset(vcpu);
24506
24507 vcpu->arch.time = data;
24508 @@ -1957,14 +1951,17 @@ int kvm_set_msr_common(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
24509 if (!(data & 1))
24510 break;
24511
24512 - /* ...but clean it before doing the actual write */
24513 - vcpu->arch.time_offset = data & ~(PAGE_MASK | 1);
24514 + gpa_offset = data & ~(PAGE_MASK | 1);
24515
24516 - vcpu->arch.time_page =
24517 - gfn_to_page(vcpu->kvm, data >> PAGE_SHIFT);
24518 + /* Check that the address is 32-byte aligned. */
24519 + if (gpa_offset & (sizeof(struct pvclock_vcpu_time_info) - 1))
24520 + break;
24521
24522 - if (is_error_page(vcpu->arch.time_page))
24523 - vcpu->arch.time_page = NULL;
24524 + if (kvm_gfn_to_hva_cache_init(vcpu->kvm,
24525 + &vcpu->arch.pv_time, data & ~1ULL))
24526 + vcpu->arch.pv_time_enabled = false;
24527 + else
24528 + vcpu->arch.pv_time_enabled = true;
24529
24530 break;
24531 }
24532 @@ -2571,6 +2568,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24533 if (n < msr_list.nmsrs)
24534 goto out;
24535 r = -EFAULT;
24536 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24537 + goto out;
24538 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24539 num_msrs_to_save * sizeof(u32)))
24540 goto out;
24541 @@ -2700,7 +2699,7 @@ static int kvm_vcpu_ioctl_set_lapic(struct kvm_vcpu *vcpu,
24542 static int kvm_vcpu_ioctl_interrupt(struct kvm_vcpu *vcpu,
24543 struct kvm_interrupt *irq)
24544 {
24545 - if (irq->irq < 0 || irq->irq >= KVM_NR_INTERRUPTS)
24546 + if (irq->irq >= KVM_NR_INTERRUPTS)
24547 return -EINVAL;
24548 if (irqchip_in_kernel(vcpu->kvm))
24549 return -ENXIO;
24550 @@ -2967,7 +2966,7 @@ static int kvm_vcpu_ioctl_x86_set_xcrs(struct kvm_vcpu *vcpu,
24551 */
24552 static int kvm_set_guest_paused(struct kvm_vcpu *vcpu)
24553 {
24554 - if (!vcpu->arch.time_page)
24555 + if (!vcpu->arch.pv_time_enabled)
24556 return -EINVAL;
24557 vcpu->arch.pvclock_set_guest_stopped_request = true;
24558 kvm_make_request(KVM_REQ_CLOCK_UPDATE, vcpu);
24559 @@ -5213,7 +5212,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24560 };
24561 #endif
24562
24563 -int kvm_arch_init(void *opaque)
24564 +int kvm_arch_init(const void *opaque)
24565 {
24566 int r;
24567 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24568 @@ -6661,6 +6660,7 @@ int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu)
24569 goto fail_free_wbinvd_dirty_mask;
24570
24571 vcpu->arch.ia32_tsc_adjust_msr = 0x0;
24572 + vcpu->arch.pv_time_enabled = false;
24573 kvm_async_pf_hash_reset(vcpu);
24574 kvm_pmu_init(vcpu);
24575
24576 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24577 index df4176c..23ce092 100644
24578 --- a/arch/x86/lguest/boot.c
24579 +++ b/arch/x86/lguest/boot.c
24580 @@ -1200,9 +1200,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24581 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24582 * Launcher to reboot us.
24583 */
24584 -static void lguest_restart(char *reason)
24585 +static __noreturn void lguest_restart(char *reason)
24586 {
24587 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24588 + BUG();
24589 }
24590
24591 /*G:050
24592 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24593 index 00933d5..3a64af9 100644
24594 --- a/arch/x86/lib/atomic64_386_32.S
24595 +++ b/arch/x86/lib/atomic64_386_32.S
24596 @@ -48,6 +48,10 @@ BEGIN(read)
24597 movl (v), %eax
24598 movl 4(v), %edx
24599 RET_ENDP
24600 +BEGIN(read_unchecked)
24601 + movl (v), %eax
24602 + movl 4(v), %edx
24603 +RET_ENDP
24604 #undef v
24605
24606 #define v %esi
24607 @@ -55,6 +59,10 @@ BEGIN(set)
24608 movl %ebx, (v)
24609 movl %ecx, 4(v)
24610 RET_ENDP
24611 +BEGIN(set_unchecked)
24612 + movl %ebx, (v)
24613 + movl %ecx, 4(v)
24614 +RET_ENDP
24615 #undef v
24616
24617 #define v %esi
24618 @@ -70,6 +78,20 @@ RET_ENDP
24619 BEGIN(add)
24620 addl %eax, (v)
24621 adcl %edx, 4(v)
24622 +
24623 +#ifdef CONFIG_PAX_REFCOUNT
24624 + jno 0f
24625 + subl %eax, (v)
24626 + sbbl %edx, 4(v)
24627 + int $4
24628 +0:
24629 + _ASM_EXTABLE(0b, 0b)
24630 +#endif
24631 +
24632 +RET_ENDP
24633 +BEGIN(add_unchecked)
24634 + addl %eax, (v)
24635 + adcl %edx, 4(v)
24636 RET_ENDP
24637 #undef v
24638
24639 @@ -77,6 +99,24 @@ RET_ENDP
24640 BEGIN(add_return)
24641 addl (v), %eax
24642 adcl 4(v), %edx
24643 +
24644 +#ifdef CONFIG_PAX_REFCOUNT
24645 + into
24646 +1234:
24647 + _ASM_EXTABLE(1234b, 2f)
24648 +#endif
24649 +
24650 + movl %eax, (v)
24651 + movl %edx, 4(v)
24652 +
24653 +#ifdef CONFIG_PAX_REFCOUNT
24654 +2:
24655 +#endif
24656 +
24657 +RET_ENDP
24658 +BEGIN(add_return_unchecked)
24659 + addl (v), %eax
24660 + adcl 4(v), %edx
24661 movl %eax, (v)
24662 movl %edx, 4(v)
24663 RET_ENDP
24664 @@ -86,6 +126,20 @@ RET_ENDP
24665 BEGIN(sub)
24666 subl %eax, (v)
24667 sbbl %edx, 4(v)
24668 +
24669 +#ifdef CONFIG_PAX_REFCOUNT
24670 + jno 0f
24671 + addl %eax, (v)
24672 + adcl %edx, 4(v)
24673 + int $4
24674 +0:
24675 + _ASM_EXTABLE(0b, 0b)
24676 +#endif
24677 +
24678 +RET_ENDP
24679 +BEGIN(sub_unchecked)
24680 + subl %eax, (v)
24681 + sbbl %edx, 4(v)
24682 RET_ENDP
24683 #undef v
24684
24685 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24686 sbbl $0, %edx
24687 addl (v), %eax
24688 adcl 4(v), %edx
24689 +
24690 +#ifdef CONFIG_PAX_REFCOUNT
24691 + into
24692 +1234:
24693 + _ASM_EXTABLE(1234b, 2f)
24694 +#endif
24695 +
24696 + movl %eax, (v)
24697 + movl %edx, 4(v)
24698 +
24699 +#ifdef CONFIG_PAX_REFCOUNT
24700 +2:
24701 +#endif
24702 +
24703 +RET_ENDP
24704 +BEGIN(sub_return_unchecked)
24705 + negl %edx
24706 + negl %eax
24707 + sbbl $0, %edx
24708 + addl (v), %eax
24709 + adcl 4(v), %edx
24710 movl %eax, (v)
24711 movl %edx, 4(v)
24712 RET_ENDP
24713 @@ -105,6 +180,20 @@ RET_ENDP
24714 BEGIN(inc)
24715 addl $1, (v)
24716 adcl $0, 4(v)
24717 +
24718 +#ifdef CONFIG_PAX_REFCOUNT
24719 + jno 0f
24720 + subl $1, (v)
24721 + sbbl $0, 4(v)
24722 + int $4
24723 +0:
24724 + _ASM_EXTABLE(0b, 0b)
24725 +#endif
24726 +
24727 +RET_ENDP
24728 +BEGIN(inc_unchecked)
24729 + addl $1, (v)
24730 + adcl $0, 4(v)
24731 RET_ENDP
24732 #undef v
24733
24734 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24735 movl 4(v), %edx
24736 addl $1, %eax
24737 adcl $0, %edx
24738 +
24739 +#ifdef CONFIG_PAX_REFCOUNT
24740 + into
24741 +1234:
24742 + _ASM_EXTABLE(1234b, 2f)
24743 +#endif
24744 +
24745 + movl %eax, (v)
24746 + movl %edx, 4(v)
24747 +
24748 +#ifdef CONFIG_PAX_REFCOUNT
24749 +2:
24750 +#endif
24751 +
24752 +RET_ENDP
24753 +BEGIN(inc_return_unchecked)
24754 + movl (v), %eax
24755 + movl 4(v), %edx
24756 + addl $1, %eax
24757 + adcl $0, %edx
24758 movl %eax, (v)
24759 movl %edx, 4(v)
24760 RET_ENDP
24761 @@ -123,6 +232,20 @@ RET_ENDP
24762 BEGIN(dec)
24763 subl $1, (v)
24764 sbbl $0, 4(v)
24765 +
24766 +#ifdef CONFIG_PAX_REFCOUNT
24767 + jno 0f
24768 + addl $1, (v)
24769 + adcl $0, 4(v)
24770 + int $4
24771 +0:
24772 + _ASM_EXTABLE(0b, 0b)
24773 +#endif
24774 +
24775 +RET_ENDP
24776 +BEGIN(dec_unchecked)
24777 + subl $1, (v)
24778 + sbbl $0, 4(v)
24779 RET_ENDP
24780 #undef v
24781
24782 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24783 movl 4(v), %edx
24784 subl $1, %eax
24785 sbbl $0, %edx
24786 +
24787 +#ifdef CONFIG_PAX_REFCOUNT
24788 + into
24789 +1234:
24790 + _ASM_EXTABLE(1234b, 2f)
24791 +#endif
24792 +
24793 + movl %eax, (v)
24794 + movl %edx, 4(v)
24795 +
24796 +#ifdef CONFIG_PAX_REFCOUNT
24797 +2:
24798 +#endif
24799 +
24800 +RET_ENDP
24801 +BEGIN(dec_return_unchecked)
24802 + movl (v), %eax
24803 + movl 4(v), %edx
24804 + subl $1, %eax
24805 + sbbl $0, %edx
24806 movl %eax, (v)
24807 movl %edx, 4(v)
24808 RET_ENDP
24809 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24810 adcl %edx, %edi
24811 addl (v), %eax
24812 adcl 4(v), %edx
24813 +
24814 +#ifdef CONFIG_PAX_REFCOUNT
24815 + into
24816 +1234:
24817 + _ASM_EXTABLE(1234b, 2f)
24818 +#endif
24819 +
24820 cmpl %eax, %ecx
24821 je 3f
24822 1:
24823 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24824 1:
24825 addl $1, %eax
24826 adcl $0, %edx
24827 +
24828 +#ifdef CONFIG_PAX_REFCOUNT
24829 + into
24830 +1234:
24831 + _ASM_EXTABLE(1234b, 2f)
24832 +#endif
24833 +
24834 movl %eax, (v)
24835 movl %edx, 4(v)
24836 movl $1, %eax
24837 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24838 movl 4(v), %edx
24839 subl $1, %eax
24840 sbbl $0, %edx
24841 +
24842 +#ifdef CONFIG_PAX_REFCOUNT
24843 + into
24844 +1234:
24845 + _ASM_EXTABLE(1234b, 1f)
24846 +#endif
24847 +
24848 js 1f
24849 movl %eax, (v)
24850 movl %edx, 4(v)
24851 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24852 index f5cc9eb..51fa319 100644
24853 --- a/arch/x86/lib/atomic64_cx8_32.S
24854 +++ b/arch/x86/lib/atomic64_cx8_32.S
24855 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24856 CFI_STARTPROC
24857
24858 read64 %ecx
24859 + pax_force_retaddr
24860 ret
24861 CFI_ENDPROC
24862 ENDPROC(atomic64_read_cx8)
24863
24864 +ENTRY(atomic64_read_unchecked_cx8)
24865 + CFI_STARTPROC
24866 +
24867 + read64 %ecx
24868 + pax_force_retaddr
24869 + ret
24870 + CFI_ENDPROC
24871 +ENDPROC(atomic64_read_unchecked_cx8)
24872 +
24873 ENTRY(atomic64_set_cx8)
24874 CFI_STARTPROC
24875
24876 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24877 cmpxchg8b (%esi)
24878 jne 1b
24879
24880 + pax_force_retaddr
24881 ret
24882 CFI_ENDPROC
24883 ENDPROC(atomic64_set_cx8)
24884
24885 +ENTRY(atomic64_set_unchecked_cx8)
24886 + CFI_STARTPROC
24887 +
24888 +1:
24889 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24890 + * are atomic on 586 and newer */
24891 + cmpxchg8b (%esi)
24892 + jne 1b
24893 +
24894 + pax_force_retaddr
24895 + ret
24896 + CFI_ENDPROC
24897 +ENDPROC(atomic64_set_unchecked_cx8)
24898 +
24899 ENTRY(atomic64_xchg_cx8)
24900 CFI_STARTPROC
24901
24902 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24903 cmpxchg8b (%esi)
24904 jne 1b
24905
24906 + pax_force_retaddr
24907 ret
24908 CFI_ENDPROC
24909 ENDPROC(atomic64_xchg_cx8)
24910
24911 -.macro addsub_return func ins insc
24912 -ENTRY(atomic64_\func\()_return_cx8)
24913 +.macro addsub_return func ins insc unchecked=""
24914 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24915 CFI_STARTPROC
24916 SAVE ebp
24917 SAVE ebx
24918 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24919 movl %edx, %ecx
24920 \ins\()l %esi, %ebx
24921 \insc\()l %edi, %ecx
24922 +
24923 +.ifb \unchecked
24924 +#ifdef CONFIG_PAX_REFCOUNT
24925 + into
24926 +2:
24927 + _ASM_EXTABLE(2b, 3f)
24928 +#endif
24929 +.endif
24930 +
24931 LOCK_PREFIX
24932 cmpxchg8b (%ebp)
24933 jne 1b
24934 -
24935 -10:
24936 movl %ebx, %eax
24937 movl %ecx, %edx
24938 +
24939 +.ifb \unchecked
24940 +#ifdef CONFIG_PAX_REFCOUNT
24941 +3:
24942 +#endif
24943 +.endif
24944 +
24945 RESTORE edi
24946 RESTORE esi
24947 RESTORE ebx
24948 RESTORE ebp
24949 + pax_force_retaddr
24950 ret
24951 CFI_ENDPROC
24952 -ENDPROC(atomic64_\func\()_return_cx8)
24953 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24954 .endm
24955
24956 addsub_return add add adc
24957 addsub_return sub sub sbb
24958 +addsub_return add add adc _unchecked
24959 +addsub_return sub sub sbb _unchecked
24960
24961 -.macro incdec_return func ins insc
24962 -ENTRY(atomic64_\func\()_return_cx8)
24963 +.macro incdec_return func ins insc unchecked=""
24964 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24965 CFI_STARTPROC
24966 SAVE ebx
24967
24968 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24969 movl %edx, %ecx
24970 \ins\()l $1, %ebx
24971 \insc\()l $0, %ecx
24972 +
24973 +.ifb \unchecked
24974 +#ifdef CONFIG_PAX_REFCOUNT
24975 + into
24976 +2:
24977 + _ASM_EXTABLE(2b, 3f)
24978 +#endif
24979 +.endif
24980 +
24981 LOCK_PREFIX
24982 cmpxchg8b (%esi)
24983 jne 1b
24984
24985 -10:
24986 movl %ebx, %eax
24987 movl %ecx, %edx
24988 +
24989 +.ifb \unchecked
24990 +#ifdef CONFIG_PAX_REFCOUNT
24991 +3:
24992 +#endif
24993 +.endif
24994 +
24995 RESTORE ebx
24996 + pax_force_retaddr
24997 ret
24998 CFI_ENDPROC
24999 -ENDPROC(atomic64_\func\()_return_cx8)
25000 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
25001 .endm
25002
25003 incdec_return inc add adc
25004 incdec_return dec sub sbb
25005 +incdec_return inc add adc _unchecked
25006 +incdec_return dec sub sbb _unchecked
25007
25008 ENTRY(atomic64_dec_if_positive_cx8)
25009 CFI_STARTPROC
25010 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
25011 movl %edx, %ecx
25012 subl $1, %ebx
25013 sbb $0, %ecx
25014 +
25015 +#ifdef CONFIG_PAX_REFCOUNT
25016 + into
25017 +1234:
25018 + _ASM_EXTABLE(1234b, 2f)
25019 +#endif
25020 +
25021 js 2f
25022 LOCK_PREFIX
25023 cmpxchg8b (%esi)
25024 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
25025 movl %ebx, %eax
25026 movl %ecx, %edx
25027 RESTORE ebx
25028 + pax_force_retaddr
25029 ret
25030 CFI_ENDPROC
25031 ENDPROC(atomic64_dec_if_positive_cx8)
25032 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
25033 movl %edx, %ecx
25034 addl %ebp, %ebx
25035 adcl %edi, %ecx
25036 +
25037 +#ifdef CONFIG_PAX_REFCOUNT
25038 + into
25039 +1234:
25040 + _ASM_EXTABLE(1234b, 3f)
25041 +#endif
25042 +
25043 LOCK_PREFIX
25044 cmpxchg8b (%esi)
25045 jne 1b
25046 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
25047 CFI_ADJUST_CFA_OFFSET -8
25048 RESTORE ebx
25049 RESTORE ebp
25050 + pax_force_retaddr
25051 ret
25052 4:
25053 cmpl %edx, 4(%esp)
25054 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
25055 xorl %ecx, %ecx
25056 addl $1, %ebx
25057 adcl %edx, %ecx
25058 +
25059 +#ifdef CONFIG_PAX_REFCOUNT
25060 + into
25061 +1234:
25062 + _ASM_EXTABLE(1234b, 3f)
25063 +#endif
25064 +
25065 LOCK_PREFIX
25066 cmpxchg8b (%esi)
25067 jne 1b
25068 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
25069 movl $1, %eax
25070 3:
25071 RESTORE ebx
25072 + pax_force_retaddr
25073 ret
25074 CFI_ENDPROC
25075 ENDPROC(atomic64_inc_not_zero_cx8)
25076 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
25077 index 2af5df3..62b1a5a 100644
25078 --- a/arch/x86/lib/checksum_32.S
25079 +++ b/arch/x86/lib/checksum_32.S
25080 @@ -29,7 +29,8 @@
25081 #include <asm/dwarf2.h>
25082 #include <asm/errno.h>
25083 #include <asm/asm.h>
25084 -
25085 +#include <asm/segment.h>
25086 +
25087 /*
25088 * computes a partial checksum, e.g. for TCP/UDP fragments
25089 */
25090 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
25091
25092 #define ARGBASE 16
25093 #define FP 12
25094 -
25095 -ENTRY(csum_partial_copy_generic)
25096 +
25097 +ENTRY(csum_partial_copy_generic_to_user)
25098 CFI_STARTPROC
25099 +
25100 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25101 + pushl_cfi %gs
25102 + popl_cfi %es
25103 + jmp csum_partial_copy_generic
25104 +#endif
25105 +
25106 +ENTRY(csum_partial_copy_generic_from_user)
25107 +
25108 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25109 + pushl_cfi %gs
25110 + popl_cfi %ds
25111 +#endif
25112 +
25113 +ENTRY(csum_partial_copy_generic)
25114 subl $4,%esp
25115 CFI_ADJUST_CFA_OFFSET 4
25116 pushl_cfi %edi
25117 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
25118 jmp 4f
25119 SRC(1: movw (%esi), %bx )
25120 addl $2, %esi
25121 -DST( movw %bx, (%edi) )
25122 +DST( movw %bx, %es:(%edi) )
25123 addl $2, %edi
25124 addw %bx, %ax
25125 adcl $0, %eax
25126 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
25127 SRC(1: movl (%esi), %ebx )
25128 SRC( movl 4(%esi), %edx )
25129 adcl %ebx, %eax
25130 -DST( movl %ebx, (%edi) )
25131 +DST( movl %ebx, %es:(%edi) )
25132 adcl %edx, %eax
25133 -DST( movl %edx, 4(%edi) )
25134 +DST( movl %edx, %es:4(%edi) )
25135
25136 SRC( movl 8(%esi), %ebx )
25137 SRC( movl 12(%esi), %edx )
25138 adcl %ebx, %eax
25139 -DST( movl %ebx, 8(%edi) )
25140 +DST( movl %ebx, %es:8(%edi) )
25141 adcl %edx, %eax
25142 -DST( movl %edx, 12(%edi) )
25143 +DST( movl %edx, %es:12(%edi) )
25144
25145 SRC( movl 16(%esi), %ebx )
25146 SRC( movl 20(%esi), %edx )
25147 adcl %ebx, %eax
25148 -DST( movl %ebx, 16(%edi) )
25149 +DST( movl %ebx, %es:16(%edi) )
25150 adcl %edx, %eax
25151 -DST( movl %edx, 20(%edi) )
25152 +DST( movl %edx, %es:20(%edi) )
25153
25154 SRC( movl 24(%esi), %ebx )
25155 SRC( movl 28(%esi), %edx )
25156 adcl %ebx, %eax
25157 -DST( movl %ebx, 24(%edi) )
25158 +DST( movl %ebx, %es:24(%edi) )
25159 adcl %edx, %eax
25160 -DST( movl %edx, 28(%edi) )
25161 +DST( movl %edx, %es:28(%edi) )
25162
25163 lea 32(%esi), %esi
25164 lea 32(%edi), %edi
25165 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
25166 shrl $2, %edx # This clears CF
25167 SRC(3: movl (%esi), %ebx )
25168 adcl %ebx, %eax
25169 -DST( movl %ebx, (%edi) )
25170 +DST( movl %ebx, %es:(%edi) )
25171 lea 4(%esi), %esi
25172 lea 4(%edi), %edi
25173 dec %edx
25174 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
25175 jb 5f
25176 SRC( movw (%esi), %cx )
25177 leal 2(%esi), %esi
25178 -DST( movw %cx, (%edi) )
25179 +DST( movw %cx, %es:(%edi) )
25180 leal 2(%edi), %edi
25181 je 6f
25182 shll $16,%ecx
25183 SRC(5: movb (%esi), %cl )
25184 -DST( movb %cl, (%edi) )
25185 +DST( movb %cl, %es:(%edi) )
25186 6: addl %ecx, %eax
25187 adcl $0, %eax
25188 7:
25189 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
25190
25191 6001:
25192 movl ARGBASE+20(%esp), %ebx # src_err_ptr
25193 - movl $-EFAULT, (%ebx)
25194 + movl $-EFAULT, %ss:(%ebx)
25195
25196 # zero the complete destination - computing the rest
25197 # is too much work
25198 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
25199
25200 6002:
25201 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25202 - movl $-EFAULT,(%ebx)
25203 + movl $-EFAULT,%ss:(%ebx)
25204 jmp 5000b
25205
25206 .previous
25207
25208 + pushl_cfi %ss
25209 + popl_cfi %ds
25210 + pushl_cfi %ss
25211 + popl_cfi %es
25212 popl_cfi %ebx
25213 CFI_RESTORE ebx
25214 popl_cfi %esi
25215 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
25216 popl_cfi %ecx # equivalent to addl $4,%esp
25217 ret
25218 CFI_ENDPROC
25219 -ENDPROC(csum_partial_copy_generic)
25220 +ENDPROC(csum_partial_copy_generic_to_user)
25221
25222 #else
25223
25224 /* Version for PentiumII/PPro */
25225
25226 #define ROUND1(x) \
25227 + nop; nop; nop; \
25228 SRC(movl x(%esi), %ebx ) ; \
25229 addl %ebx, %eax ; \
25230 - DST(movl %ebx, x(%edi) ) ;
25231 + DST(movl %ebx, %es:x(%edi)) ;
25232
25233 #define ROUND(x) \
25234 + nop; nop; nop; \
25235 SRC(movl x(%esi), %ebx ) ; \
25236 adcl %ebx, %eax ; \
25237 - DST(movl %ebx, x(%edi) ) ;
25238 + DST(movl %ebx, %es:x(%edi)) ;
25239
25240 #define ARGBASE 12
25241 -
25242 -ENTRY(csum_partial_copy_generic)
25243 +
25244 +ENTRY(csum_partial_copy_generic_to_user)
25245 CFI_STARTPROC
25246 +
25247 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25248 + pushl_cfi %gs
25249 + popl_cfi %es
25250 + jmp csum_partial_copy_generic
25251 +#endif
25252 +
25253 +ENTRY(csum_partial_copy_generic_from_user)
25254 +
25255 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25256 + pushl_cfi %gs
25257 + popl_cfi %ds
25258 +#endif
25259 +
25260 +ENTRY(csum_partial_copy_generic)
25261 pushl_cfi %ebx
25262 CFI_REL_OFFSET ebx, 0
25263 pushl_cfi %edi
25264 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
25265 subl %ebx, %edi
25266 lea -1(%esi),%edx
25267 andl $-32,%edx
25268 - lea 3f(%ebx,%ebx), %ebx
25269 + lea 3f(%ebx,%ebx,2), %ebx
25270 testl %esi, %esi
25271 jmp *%ebx
25272 1: addl $64,%esi
25273 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
25274 jb 5f
25275 SRC( movw (%esi), %dx )
25276 leal 2(%esi), %esi
25277 -DST( movw %dx, (%edi) )
25278 +DST( movw %dx, %es:(%edi) )
25279 leal 2(%edi), %edi
25280 je 6f
25281 shll $16,%edx
25282 5:
25283 SRC( movb (%esi), %dl )
25284 -DST( movb %dl, (%edi) )
25285 +DST( movb %dl, %es:(%edi) )
25286 6: addl %edx, %eax
25287 adcl $0, %eax
25288 7:
25289 .section .fixup, "ax"
25290 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
25291 - movl $-EFAULT, (%ebx)
25292 + movl $-EFAULT, %ss:(%ebx)
25293 # zero the complete destination (computing the rest is too much work)
25294 movl ARGBASE+8(%esp),%edi # dst
25295 movl ARGBASE+12(%esp),%ecx # len
25296 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
25297 rep; stosb
25298 jmp 7b
25299 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
25300 - movl $-EFAULT, (%ebx)
25301 + movl $-EFAULT, %ss:(%ebx)
25302 jmp 7b
25303 .previous
25304
25305 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25306 + pushl_cfi %ss
25307 + popl_cfi %ds
25308 + pushl_cfi %ss
25309 + popl_cfi %es
25310 +#endif
25311 +
25312 popl_cfi %esi
25313 CFI_RESTORE esi
25314 popl_cfi %edi
25315 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
25316 CFI_RESTORE ebx
25317 ret
25318 CFI_ENDPROC
25319 -ENDPROC(csum_partial_copy_generic)
25320 +ENDPROC(csum_partial_copy_generic_to_user)
25321
25322 #undef ROUND
25323 #undef ROUND1
25324 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
25325 index f2145cf..cea889d 100644
25326 --- a/arch/x86/lib/clear_page_64.S
25327 +++ b/arch/x86/lib/clear_page_64.S
25328 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
25329 movl $4096/8,%ecx
25330 xorl %eax,%eax
25331 rep stosq
25332 + pax_force_retaddr
25333 ret
25334 CFI_ENDPROC
25335 ENDPROC(clear_page_c)
25336 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25337 movl $4096,%ecx
25338 xorl %eax,%eax
25339 rep stosb
25340 + pax_force_retaddr
25341 ret
25342 CFI_ENDPROC
25343 ENDPROC(clear_page_c_e)
25344 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25345 leaq 64(%rdi),%rdi
25346 jnz .Lloop
25347 nop
25348 + pax_force_retaddr
25349 ret
25350 CFI_ENDPROC
25351 .Lclear_page_end:
25352 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25353
25354 #include <asm/cpufeature.h>
25355
25356 - .section .altinstr_replacement,"ax"
25357 + .section .altinstr_replacement,"a"
25358 1: .byte 0xeb /* jmp <disp8> */
25359 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25360 2: .byte 0xeb /* jmp <disp8> */
25361 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25362 index 1e572c5..2a162cd 100644
25363 --- a/arch/x86/lib/cmpxchg16b_emu.S
25364 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25365 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25366
25367 popf
25368 mov $1, %al
25369 + pax_force_retaddr
25370 ret
25371
25372 not_same:
25373 popf
25374 xor %al,%al
25375 + pax_force_retaddr
25376 ret
25377
25378 CFI_ENDPROC
25379 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25380 index 176cca6..1166c50 100644
25381 --- a/arch/x86/lib/copy_page_64.S
25382 +++ b/arch/x86/lib/copy_page_64.S
25383 @@ -9,6 +9,7 @@ copy_page_rep:
25384 CFI_STARTPROC
25385 movl $4096/8, %ecx
25386 rep movsq
25387 + pax_force_retaddr
25388 ret
25389 CFI_ENDPROC
25390 ENDPROC(copy_page_rep)
25391 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25392
25393 ENTRY(copy_page)
25394 CFI_STARTPROC
25395 - subq $2*8, %rsp
25396 - CFI_ADJUST_CFA_OFFSET 2*8
25397 + subq $3*8, %rsp
25398 + CFI_ADJUST_CFA_OFFSET 3*8
25399 movq %rbx, (%rsp)
25400 CFI_REL_OFFSET rbx, 0
25401 movq %r12, 1*8(%rsp)
25402 CFI_REL_OFFSET r12, 1*8
25403 + movq %r13, 2*8(%rsp)
25404 + CFI_REL_OFFSET r13, 2*8
25405
25406 movl $(4096/64)-5, %ecx
25407 .p2align 4
25408 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25409 movq 0x8*2(%rsi), %rdx
25410 movq 0x8*3(%rsi), %r8
25411 movq 0x8*4(%rsi), %r9
25412 - movq 0x8*5(%rsi), %r10
25413 + movq 0x8*5(%rsi), %r13
25414 movq 0x8*6(%rsi), %r11
25415 movq 0x8*7(%rsi), %r12
25416
25417 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25418 movq %rdx, 0x8*2(%rdi)
25419 movq %r8, 0x8*3(%rdi)
25420 movq %r9, 0x8*4(%rdi)
25421 - movq %r10, 0x8*5(%rdi)
25422 + movq %r13, 0x8*5(%rdi)
25423 movq %r11, 0x8*6(%rdi)
25424 movq %r12, 0x8*7(%rdi)
25425
25426 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25427 movq 0x8*2(%rsi), %rdx
25428 movq 0x8*3(%rsi), %r8
25429 movq 0x8*4(%rsi), %r9
25430 - movq 0x8*5(%rsi), %r10
25431 + movq 0x8*5(%rsi), %r13
25432 movq 0x8*6(%rsi), %r11
25433 movq 0x8*7(%rsi), %r12
25434
25435 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25436 movq %rdx, 0x8*2(%rdi)
25437 movq %r8, 0x8*3(%rdi)
25438 movq %r9, 0x8*4(%rdi)
25439 - movq %r10, 0x8*5(%rdi)
25440 + movq %r13, 0x8*5(%rdi)
25441 movq %r11, 0x8*6(%rdi)
25442 movq %r12, 0x8*7(%rdi)
25443
25444 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25445 CFI_RESTORE rbx
25446 movq 1*8(%rsp), %r12
25447 CFI_RESTORE r12
25448 - addq $2*8, %rsp
25449 - CFI_ADJUST_CFA_OFFSET -2*8
25450 + movq 2*8(%rsp), %r13
25451 + CFI_RESTORE r13
25452 + addq $3*8, %rsp
25453 + CFI_ADJUST_CFA_OFFSET -3*8
25454 + pax_force_retaddr
25455 ret
25456 .Lcopy_page_end:
25457 CFI_ENDPROC
25458 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25459
25460 #include <asm/cpufeature.h>
25461
25462 - .section .altinstr_replacement,"ax"
25463 + .section .altinstr_replacement,"a"
25464 1: .byte 0xeb /* jmp <disp8> */
25465 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25466 2:
25467 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25468 index a30ca15..d25fab6 100644
25469 --- a/arch/x86/lib/copy_user_64.S
25470 +++ b/arch/x86/lib/copy_user_64.S
25471 @@ -18,6 +18,7 @@
25472 #include <asm/alternative-asm.h>
25473 #include <asm/asm.h>
25474 #include <asm/smap.h>
25475 +#include <asm/pgtable.h>
25476
25477 /*
25478 * By placing feature2 after feature1 in altinstructions section, we logically
25479 @@ -31,7 +32,7 @@
25480 .byte 0xe9 /* 32bit jump */
25481 .long \orig-1f /* by default jump to orig */
25482 1:
25483 - .section .altinstr_replacement,"ax"
25484 + .section .altinstr_replacement,"a"
25485 2: .byte 0xe9 /* near jump with 32bit immediate */
25486 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25487 3: .byte 0xe9 /* near jump with 32bit immediate */
25488 @@ -70,47 +71,20 @@
25489 #endif
25490 .endm
25491
25492 -/* Standard copy_to_user with segment limit checking */
25493 -ENTRY(_copy_to_user)
25494 - CFI_STARTPROC
25495 - GET_THREAD_INFO(%rax)
25496 - movq %rdi,%rcx
25497 - addq %rdx,%rcx
25498 - jc bad_to_user
25499 - cmpq TI_addr_limit(%rax),%rcx
25500 - ja bad_to_user
25501 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25502 - copy_user_generic_unrolled,copy_user_generic_string, \
25503 - copy_user_enhanced_fast_string
25504 - CFI_ENDPROC
25505 -ENDPROC(_copy_to_user)
25506 -
25507 -/* Standard copy_from_user with segment limit checking */
25508 -ENTRY(_copy_from_user)
25509 - CFI_STARTPROC
25510 - GET_THREAD_INFO(%rax)
25511 - movq %rsi,%rcx
25512 - addq %rdx,%rcx
25513 - jc bad_from_user
25514 - cmpq TI_addr_limit(%rax),%rcx
25515 - ja bad_from_user
25516 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25517 - copy_user_generic_unrolled,copy_user_generic_string, \
25518 - copy_user_enhanced_fast_string
25519 - CFI_ENDPROC
25520 -ENDPROC(_copy_from_user)
25521 -
25522 .section .fixup,"ax"
25523 /* must zero dest */
25524 ENTRY(bad_from_user)
25525 bad_from_user:
25526 CFI_STARTPROC
25527 + testl %edx,%edx
25528 + js bad_to_user
25529 movl %edx,%ecx
25530 xorl %eax,%eax
25531 rep
25532 stosb
25533 bad_to_user:
25534 movl %edx,%eax
25535 + pax_force_retaddr
25536 ret
25537 CFI_ENDPROC
25538 ENDPROC(bad_from_user)
25539 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25540 jz 17f
25541 1: movq (%rsi),%r8
25542 2: movq 1*8(%rsi),%r9
25543 -3: movq 2*8(%rsi),%r10
25544 +3: movq 2*8(%rsi),%rax
25545 4: movq 3*8(%rsi),%r11
25546 5: movq %r8,(%rdi)
25547 6: movq %r9,1*8(%rdi)
25548 -7: movq %r10,2*8(%rdi)
25549 +7: movq %rax,2*8(%rdi)
25550 8: movq %r11,3*8(%rdi)
25551 9: movq 4*8(%rsi),%r8
25552 10: movq 5*8(%rsi),%r9
25553 -11: movq 6*8(%rsi),%r10
25554 +11: movq 6*8(%rsi),%rax
25555 12: movq 7*8(%rsi),%r11
25556 13: movq %r8,4*8(%rdi)
25557 14: movq %r9,5*8(%rdi)
25558 -15: movq %r10,6*8(%rdi)
25559 +15: movq %rax,6*8(%rdi)
25560 16: movq %r11,7*8(%rdi)
25561 leaq 64(%rsi),%rsi
25562 leaq 64(%rdi),%rdi
25563 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25564 jnz 21b
25565 23: xor %eax,%eax
25566 ASM_CLAC
25567 + pax_force_retaddr
25568 ret
25569
25570 .section .fixup,"ax"
25571 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25572 movsb
25573 4: xorl %eax,%eax
25574 ASM_CLAC
25575 + pax_force_retaddr
25576 ret
25577
25578 .section .fixup,"ax"
25579 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25580 movsb
25581 2: xorl %eax,%eax
25582 ASM_CLAC
25583 + pax_force_retaddr
25584 ret
25585
25586 .section .fixup,"ax"
25587 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25588 index 6a4f43c..f5f9e26 100644
25589 --- a/arch/x86/lib/copy_user_nocache_64.S
25590 +++ b/arch/x86/lib/copy_user_nocache_64.S
25591 @@ -8,6 +8,7 @@
25592
25593 #include <linux/linkage.h>
25594 #include <asm/dwarf2.h>
25595 +#include <asm/alternative-asm.h>
25596
25597 #define FIX_ALIGNMENT 1
25598
25599 @@ -16,6 +17,7 @@
25600 #include <asm/thread_info.h>
25601 #include <asm/asm.h>
25602 #include <asm/smap.h>
25603 +#include <asm/pgtable.h>
25604
25605 .macro ALIGN_DESTINATION
25606 #ifdef FIX_ALIGNMENT
25607 @@ -49,6 +51,15 @@
25608 */
25609 ENTRY(__copy_user_nocache)
25610 CFI_STARTPROC
25611 +
25612 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25613 + mov $PAX_USER_SHADOW_BASE,%rcx
25614 + cmp %rcx,%rsi
25615 + jae 1f
25616 + add %rcx,%rsi
25617 +1:
25618 +#endif
25619 +
25620 ASM_STAC
25621 cmpl $8,%edx
25622 jb 20f /* less then 8 bytes, go to byte copy loop */
25623 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25624 jz 17f
25625 1: movq (%rsi),%r8
25626 2: movq 1*8(%rsi),%r9
25627 -3: movq 2*8(%rsi),%r10
25628 +3: movq 2*8(%rsi),%rax
25629 4: movq 3*8(%rsi),%r11
25630 5: movnti %r8,(%rdi)
25631 6: movnti %r9,1*8(%rdi)
25632 -7: movnti %r10,2*8(%rdi)
25633 +7: movnti %rax,2*8(%rdi)
25634 8: movnti %r11,3*8(%rdi)
25635 9: movq 4*8(%rsi),%r8
25636 10: movq 5*8(%rsi),%r9
25637 -11: movq 6*8(%rsi),%r10
25638 +11: movq 6*8(%rsi),%rax
25639 12: movq 7*8(%rsi),%r11
25640 13: movnti %r8,4*8(%rdi)
25641 14: movnti %r9,5*8(%rdi)
25642 -15: movnti %r10,6*8(%rdi)
25643 +15: movnti %rax,6*8(%rdi)
25644 16: movnti %r11,7*8(%rdi)
25645 leaq 64(%rsi),%rsi
25646 leaq 64(%rdi),%rdi
25647 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25648 23: xorl %eax,%eax
25649 ASM_CLAC
25650 sfence
25651 + pax_force_retaddr
25652 ret
25653
25654 .section .fixup,"ax"
25655 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25656 index 2419d5f..953ee51 100644
25657 --- a/arch/x86/lib/csum-copy_64.S
25658 +++ b/arch/x86/lib/csum-copy_64.S
25659 @@ -9,6 +9,7 @@
25660 #include <asm/dwarf2.h>
25661 #include <asm/errno.h>
25662 #include <asm/asm.h>
25663 +#include <asm/alternative-asm.h>
25664
25665 /*
25666 * Checksum copy with exception handling.
25667 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25668 CFI_RESTORE rbp
25669 addq $7*8, %rsp
25670 CFI_ADJUST_CFA_OFFSET -7*8
25671 + pax_force_retaddr 0, 1
25672 ret
25673 CFI_RESTORE_STATE
25674
25675 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25676 index 25b7ae8..169fafc 100644
25677 --- a/arch/x86/lib/csum-wrappers_64.c
25678 +++ b/arch/x86/lib/csum-wrappers_64.c
25679 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25680 len -= 2;
25681 }
25682 }
25683 - isum = csum_partial_copy_generic((__force const void *)src,
25684 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25685 dst, len, isum, errp, NULL);
25686 if (unlikely(*errp))
25687 goto out_err;
25688 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25689 }
25690
25691 *errp = 0;
25692 - return csum_partial_copy_generic(src, (void __force *)dst,
25693 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25694 len, isum, NULL, errp);
25695 }
25696 EXPORT_SYMBOL(csum_partial_copy_to_user);
25697 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25698 index 156b9c8..b144132 100644
25699 --- a/arch/x86/lib/getuser.S
25700 +++ b/arch/x86/lib/getuser.S
25701 @@ -34,17 +34,40 @@
25702 #include <asm/thread_info.h>
25703 #include <asm/asm.h>
25704 #include <asm/smap.h>
25705 +#include <asm/segment.h>
25706 +#include <asm/pgtable.h>
25707 +#include <asm/alternative-asm.h>
25708 +
25709 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25710 +#define __copyuser_seg gs;
25711 +#else
25712 +#define __copyuser_seg
25713 +#endif
25714
25715 .text
25716 ENTRY(__get_user_1)
25717 CFI_STARTPROC
25718 +
25719 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25720 GET_THREAD_INFO(%_ASM_DX)
25721 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25722 jae bad_get_user
25723 ASM_STAC
25724 -1: movzb (%_ASM_AX),%edx
25725 +
25726 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25727 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25728 + cmp %_ASM_DX,%_ASM_AX
25729 + jae 1234f
25730 + add %_ASM_DX,%_ASM_AX
25731 +1234:
25732 +#endif
25733 +
25734 +#endif
25735 +
25736 +1: __copyuser_seg movzb (%_ASM_AX),%edx
25737 xor %eax,%eax
25738 ASM_CLAC
25739 + pax_force_retaddr
25740 ret
25741 CFI_ENDPROC
25742 ENDPROC(__get_user_1)
25743 @@ -52,14 +75,28 @@ ENDPROC(__get_user_1)
25744 ENTRY(__get_user_2)
25745 CFI_STARTPROC
25746 add $1,%_ASM_AX
25747 +
25748 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25749 jc bad_get_user
25750 GET_THREAD_INFO(%_ASM_DX)
25751 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25752 jae bad_get_user
25753 ASM_STAC
25754 -2: movzwl -1(%_ASM_AX),%edx
25755 +
25756 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25757 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25758 + cmp %_ASM_DX,%_ASM_AX
25759 + jae 1234f
25760 + add %_ASM_DX,%_ASM_AX
25761 +1234:
25762 +#endif
25763 +
25764 +#endif
25765 +
25766 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25767 xor %eax,%eax
25768 ASM_CLAC
25769 + pax_force_retaddr
25770 ret
25771 CFI_ENDPROC
25772 ENDPROC(__get_user_2)
25773 @@ -67,14 +104,28 @@ ENDPROC(__get_user_2)
25774 ENTRY(__get_user_4)
25775 CFI_STARTPROC
25776 add $3,%_ASM_AX
25777 +
25778 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25779 jc bad_get_user
25780 GET_THREAD_INFO(%_ASM_DX)
25781 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25782 jae bad_get_user
25783 ASM_STAC
25784 -3: mov -3(%_ASM_AX),%edx
25785 +
25786 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25787 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25788 + cmp %_ASM_DX,%_ASM_AX
25789 + jae 1234f
25790 + add %_ASM_DX,%_ASM_AX
25791 +1234:
25792 +#endif
25793 +
25794 +#endif
25795 +
25796 +3: __copyuser_seg mov -3(%_ASM_AX),%edx
25797 xor %eax,%eax
25798 ASM_CLAC
25799 + pax_force_retaddr
25800 ret
25801 CFI_ENDPROC
25802 ENDPROC(__get_user_4)
25803 @@ -87,10 +138,20 @@ ENTRY(__get_user_8)
25804 GET_THREAD_INFO(%_ASM_DX)
25805 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25806 jae bad_get_user
25807 +
25808 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25809 + mov $PAX_USER_SHADOW_BASE,%_ASM_DX
25810 + cmp %_ASM_DX,%_ASM_AX
25811 + jae 1234f
25812 + add %_ASM_DX,%_ASM_AX
25813 +1234:
25814 +#endif
25815 +
25816 ASM_STAC
25817 4: movq -7(%_ASM_AX),%_ASM_DX
25818 xor %eax,%eax
25819 ASM_CLAC
25820 + pax_force_retaddr
25821 ret
25822 CFI_ENDPROC
25823 ENDPROC(__get_user_8)
25824 @@ -101,6 +162,7 @@ bad_get_user:
25825 xor %edx,%edx
25826 mov $(-EFAULT),%_ASM_AX
25827 ASM_CLAC
25828 + pax_force_retaddr
25829 ret
25830 CFI_ENDPROC
25831 END(bad_get_user)
25832 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25833 index 54fcffe..7be149e 100644
25834 --- a/arch/x86/lib/insn.c
25835 +++ b/arch/x86/lib/insn.c
25836 @@ -20,8 +20,10 @@
25837
25838 #ifdef __KERNEL__
25839 #include <linux/string.h>
25840 +#include <asm/pgtable_types.h>
25841 #else
25842 #include <string.h>
25843 +#define ktla_ktva(addr) addr
25844 #endif
25845 #include <asm/inat.h>
25846 #include <asm/insn.h>
25847 @@ -53,8 +55,8 @@
25848 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25849 {
25850 memset(insn, 0, sizeof(*insn));
25851 - insn->kaddr = kaddr;
25852 - insn->next_byte = kaddr;
25853 + insn->kaddr = ktla_ktva(kaddr);
25854 + insn->next_byte = ktla_ktva(kaddr);
25855 insn->x86_64 = x86_64 ? 1 : 0;
25856 insn->opnd_bytes = 4;
25857 if (x86_64)
25858 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25859 index 05a95e7..326f2fa 100644
25860 --- a/arch/x86/lib/iomap_copy_64.S
25861 +++ b/arch/x86/lib/iomap_copy_64.S
25862 @@ -17,6 +17,7 @@
25863
25864 #include <linux/linkage.h>
25865 #include <asm/dwarf2.h>
25866 +#include <asm/alternative-asm.h>
25867
25868 /*
25869 * override generic version in lib/iomap_copy.c
25870 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25871 CFI_STARTPROC
25872 movl %edx,%ecx
25873 rep movsd
25874 + pax_force_retaddr
25875 ret
25876 CFI_ENDPROC
25877 ENDPROC(__iowrite32_copy)
25878 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25879 index 1c273be..da9cc0e 100644
25880 --- a/arch/x86/lib/memcpy_64.S
25881 +++ b/arch/x86/lib/memcpy_64.S
25882 @@ -33,6 +33,7 @@
25883 rep movsq
25884 movl %edx, %ecx
25885 rep movsb
25886 + pax_force_retaddr
25887 ret
25888 .Lmemcpy_e:
25889 .previous
25890 @@ -49,6 +50,7 @@
25891 movq %rdi, %rax
25892 movq %rdx, %rcx
25893 rep movsb
25894 + pax_force_retaddr
25895 ret
25896 .Lmemcpy_e_e:
25897 .previous
25898 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25899 */
25900 movq 0*8(%rsi), %r8
25901 movq 1*8(%rsi), %r9
25902 - movq 2*8(%rsi), %r10
25903 + movq 2*8(%rsi), %rcx
25904 movq 3*8(%rsi), %r11
25905 leaq 4*8(%rsi), %rsi
25906
25907 movq %r8, 0*8(%rdi)
25908 movq %r9, 1*8(%rdi)
25909 - movq %r10, 2*8(%rdi)
25910 + movq %rcx, 2*8(%rdi)
25911 movq %r11, 3*8(%rdi)
25912 leaq 4*8(%rdi), %rdi
25913 jae .Lcopy_forward_loop
25914 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25915 subq $0x20, %rdx
25916 movq -1*8(%rsi), %r8
25917 movq -2*8(%rsi), %r9
25918 - movq -3*8(%rsi), %r10
25919 + movq -3*8(%rsi), %rcx
25920 movq -4*8(%rsi), %r11
25921 leaq -4*8(%rsi), %rsi
25922 movq %r8, -1*8(%rdi)
25923 movq %r9, -2*8(%rdi)
25924 - movq %r10, -3*8(%rdi)
25925 + movq %rcx, -3*8(%rdi)
25926 movq %r11, -4*8(%rdi)
25927 leaq -4*8(%rdi), %rdi
25928 jae .Lcopy_backward_loop
25929 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25930 */
25931 movq 0*8(%rsi), %r8
25932 movq 1*8(%rsi), %r9
25933 - movq -2*8(%rsi, %rdx), %r10
25934 + movq -2*8(%rsi, %rdx), %rcx
25935 movq -1*8(%rsi, %rdx), %r11
25936 movq %r8, 0*8(%rdi)
25937 movq %r9, 1*8(%rdi)
25938 - movq %r10, -2*8(%rdi, %rdx)
25939 + movq %rcx, -2*8(%rdi, %rdx)
25940 movq %r11, -1*8(%rdi, %rdx)
25941 + pax_force_retaddr
25942 retq
25943 .p2align 4
25944 .Lless_16bytes:
25945 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25946 movq -1*8(%rsi, %rdx), %r9
25947 movq %r8, 0*8(%rdi)
25948 movq %r9, -1*8(%rdi, %rdx)
25949 + pax_force_retaddr
25950 retq
25951 .p2align 4
25952 .Lless_8bytes:
25953 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25954 movl -4(%rsi, %rdx), %r8d
25955 movl %ecx, (%rdi)
25956 movl %r8d, -4(%rdi, %rdx)
25957 + pax_force_retaddr
25958 retq
25959 .p2align 4
25960 .Lless_3bytes:
25961 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25962 movb %cl, (%rdi)
25963
25964 .Lend:
25965 + pax_force_retaddr
25966 retq
25967 CFI_ENDPROC
25968 ENDPROC(memcpy)
25969 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25970 index ee16461..c39c199 100644
25971 --- a/arch/x86/lib/memmove_64.S
25972 +++ b/arch/x86/lib/memmove_64.S
25973 @@ -61,13 +61,13 @@ ENTRY(memmove)
25974 5:
25975 sub $0x20, %rdx
25976 movq 0*8(%rsi), %r11
25977 - movq 1*8(%rsi), %r10
25978 + movq 1*8(%rsi), %rcx
25979 movq 2*8(%rsi), %r9
25980 movq 3*8(%rsi), %r8
25981 leaq 4*8(%rsi), %rsi
25982
25983 movq %r11, 0*8(%rdi)
25984 - movq %r10, 1*8(%rdi)
25985 + movq %rcx, 1*8(%rdi)
25986 movq %r9, 2*8(%rdi)
25987 movq %r8, 3*8(%rdi)
25988 leaq 4*8(%rdi), %rdi
25989 @@ -81,10 +81,10 @@ ENTRY(memmove)
25990 4:
25991 movq %rdx, %rcx
25992 movq -8(%rsi, %rdx), %r11
25993 - lea -8(%rdi, %rdx), %r10
25994 + lea -8(%rdi, %rdx), %r9
25995 shrq $3, %rcx
25996 rep movsq
25997 - movq %r11, (%r10)
25998 + movq %r11, (%r9)
25999 jmp 13f
26000 .Lmemmove_end_forward:
26001
26002 @@ -95,14 +95,14 @@ ENTRY(memmove)
26003 7:
26004 movq %rdx, %rcx
26005 movq (%rsi), %r11
26006 - movq %rdi, %r10
26007 + movq %rdi, %r9
26008 leaq -8(%rsi, %rdx), %rsi
26009 leaq -8(%rdi, %rdx), %rdi
26010 shrq $3, %rcx
26011 std
26012 rep movsq
26013 cld
26014 - movq %r11, (%r10)
26015 + movq %r11, (%r9)
26016 jmp 13f
26017
26018 /*
26019 @@ -127,13 +127,13 @@ ENTRY(memmove)
26020 8:
26021 subq $0x20, %rdx
26022 movq -1*8(%rsi), %r11
26023 - movq -2*8(%rsi), %r10
26024 + movq -2*8(%rsi), %rcx
26025 movq -3*8(%rsi), %r9
26026 movq -4*8(%rsi), %r8
26027 leaq -4*8(%rsi), %rsi
26028
26029 movq %r11, -1*8(%rdi)
26030 - movq %r10, -2*8(%rdi)
26031 + movq %rcx, -2*8(%rdi)
26032 movq %r9, -3*8(%rdi)
26033 movq %r8, -4*8(%rdi)
26034 leaq -4*8(%rdi), %rdi
26035 @@ -151,11 +151,11 @@ ENTRY(memmove)
26036 * Move data from 16 bytes to 31 bytes.
26037 */
26038 movq 0*8(%rsi), %r11
26039 - movq 1*8(%rsi), %r10
26040 + movq 1*8(%rsi), %rcx
26041 movq -2*8(%rsi, %rdx), %r9
26042 movq -1*8(%rsi, %rdx), %r8
26043 movq %r11, 0*8(%rdi)
26044 - movq %r10, 1*8(%rdi)
26045 + movq %rcx, 1*8(%rdi)
26046 movq %r9, -2*8(%rdi, %rdx)
26047 movq %r8, -1*8(%rdi, %rdx)
26048 jmp 13f
26049 @@ -167,9 +167,9 @@ ENTRY(memmove)
26050 * Move data from 8 bytes to 15 bytes.
26051 */
26052 movq 0*8(%rsi), %r11
26053 - movq -1*8(%rsi, %rdx), %r10
26054 + movq -1*8(%rsi, %rdx), %r9
26055 movq %r11, 0*8(%rdi)
26056 - movq %r10, -1*8(%rdi, %rdx)
26057 + movq %r9, -1*8(%rdi, %rdx)
26058 jmp 13f
26059 10:
26060 cmpq $4, %rdx
26061 @@ -178,9 +178,9 @@ ENTRY(memmove)
26062 * Move data from 4 bytes to 7 bytes.
26063 */
26064 movl (%rsi), %r11d
26065 - movl -4(%rsi, %rdx), %r10d
26066 + movl -4(%rsi, %rdx), %r9d
26067 movl %r11d, (%rdi)
26068 - movl %r10d, -4(%rdi, %rdx)
26069 + movl %r9d, -4(%rdi, %rdx)
26070 jmp 13f
26071 11:
26072 cmp $2, %rdx
26073 @@ -189,9 +189,9 @@ ENTRY(memmove)
26074 * Move data from 2 bytes to 3 bytes.
26075 */
26076 movw (%rsi), %r11w
26077 - movw -2(%rsi, %rdx), %r10w
26078 + movw -2(%rsi, %rdx), %r9w
26079 movw %r11w, (%rdi)
26080 - movw %r10w, -2(%rdi, %rdx)
26081 + movw %r9w, -2(%rdi, %rdx)
26082 jmp 13f
26083 12:
26084 cmp $1, %rdx
26085 @@ -202,6 +202,7 @@ ENTRY(memmove)
26086 movb (%rsi), %r11b
26087 movb %r11b, (%rdi)
26088 13:
26089 + pax_force_retaddr
26090 retq
26091 CFI_ENDPROC
26092
26093 @@ -210,6 +211,7 @@ ENTRY(memmove)
26094 /* Forward moving data. */
26095 movq %rdx, %rcx
26096 rep movsb
26097 + pax_force_retaddr
26098 retq
26099 .Lmemmove_end_forward_efs:
26100 .previous
26101 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
26102 index 2dcb380..963660a 100644
26103 --- a/arch/x86/lib/memset_64.S
26104 +++ b/arch/x86/lib/memset_64.S
26105 @@ -30,6 +30,7 @@
26106 movl %edx,%ecx
26107 rep stosb
26108 movq %r9,%rax
26109 + pax_force_retaddr
26110 ret
26111 .Lmemset_e:
26112 .previous
26113 @@ -52,6 +53,7 @@
26114 movq %rdx,%rcx
26115 rep stosb
26116 movq %r9,%rax
26117 + pax_force_retaddr
26118 ret
26119 .Lmemset_e_e:
26120 .previous
26121 @@ -59,7 +61,7 @@
26122 ENTRY(memset)
26123 ENTRY(__memset)
26124 CFI_STARTPROC
26125 - movq %rdi,%r10
26126 + movq %rdi,%r11
26127
26128 /* expand byte value */
26129 movzbl %sil,%ecx
26130 @@ -117,7 +119,8 @@ ENTRY(__memset)
26131 jnz .Lloop_1
26132
26133 .Lende:
26134 - movq %r10,%rax
26135 + movq %r11,%rax
26136 + pax_force_retaddr
26137 ret
26138
26139 CFI_RESTORE_STATE
26140 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
26141 index c9f2d9b..e7fd2c0 100644
26142 --- a/arch/x86/lib/mmx_32.c
26143 +++ b/arch/x86/lib/mmx_32.c
26144 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26145 {
26146 void *p;
26147 int i;
26148 + unsigned long cr0;
26149
26150 if (unlikely(in_interrupt()))
26151 return __memcpy(to, from, len);
26152 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
26153 kernel_fpu_begin();
26154
26155 __asm__ __volatile__ (
26156 - "1: prefetch (%0)\n" /* This set is 28 bytes */
26157 - " prefetch 64(%0)\n"
26158 - " prefetch 128(%0)\n"
26159 - " prefetch 192(%0)\n"
26160 - " prefetch 256(%0)\n"
26161 + "1: prefetch (%1)\n" /* This set is 28 bytes */
26162 + " prefetch 64(%1)\n"
26163 + " prefetch 128(%1)\n"
26164 + " prefetch 192(%1)\n"
26165 + " prefetch 256(%1)\n"
26166 "2: \n"
26167 ".section .fixup, \"ax\"\n"
26168 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26169 + "3: \n"
26170 +
26171 +#ifdef CONFIG_PAX_KERNEXEC
26172 + " movl %%cr0, %0\n"
26173 + " movl %0, %%eax\n"
26174 + " andl $0xFFFEFFFF, %%eax\n"
26175 + " movl %%eax, %%cr0\n"
26176 +#endif
26177 +
26178 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26179 +
26180 +#ifdef CONFIG_PAX_KERNEXEC
26181 + " movl %0, %%cr0\n"
26182 +#endif
26183 +
26184 " jmp 2b\n"
26185 ".previous\n"
26186 _ASM_EXTABLE(1b, 3b)
26187 - : : "r" (from));
26188 + : "=&r" (cr0) : "r" (from) : "ax");
26189
26190 for ( ; i > 5; i--) {
26191 __asm__ __volatile__ (
26192 - "1: prefetch 320(%0)\n"
26193 - "2: movq (%0), %%mm0\n"
26194 - " movq 8(%0), %%mm1\n"
26195 - " movq 16(%0), %%mm2\n"
26196 - " movq 24(%0), %%mm3\n"
26197 - " movq %%mm0, (%1)\n"
26198 - " movq %%mm1, 8(%1)\n"
26199 - " movq %%mm2, 16(%1)\n"
26200 - " movq %%mm3, 24(%1)\n"
26201 - " movq 32(%0), %%mm0\n"
26202 - " movq 40(%0), %%mm1\n"
26203 - " movq 48(%0), %%mm2\n"
26204 - " movq 56(%0), %%mm3\n"
26205 - " movq %%mm0, 32(%1)\n"
26206 - " movq %%mm1, 40(%1)\n"
26207 - " movq %%mm2, 48(%1)\n"
26208 - " movq %%mm3, 56(%1)\n"
26209 + "1: prefetch 320(%1)\n"
26210 + "2: movq (%1), %%mm0\n"
26211 + " movq 8(%1), %%mm1\n"
26212 + " movq 16(%1), %%mm2\n"
26213 + " movq 24(%1), %%mm3\n"
26214 + " movq %%mm0, (%2)\n"
26215 + " movq %%mm1, 8(%2)\n"
26216 + " movq %%mm2, 16(%2)\n"
26217 + " movq %%mm3, 24(%2)\n"
26218 + " movq 32(%1), %%mm0\n"
26219 + " movq 40(%1), %%mm1\n"
26220 + " movq 48(%1), %%mm2\n"
26221 + " movq 56(%1), %%mm3\n"
26222 + " movq %%mm0, 32(%2)\n"
26223 + " movq %%mm1, 40(%2)\n"
26224 + " movq %%mm2, 48(%2)\n"
26225 + " movq %%mm3, 56(%2)\n"
26226 ".section .fixup, \"ax\"\n"
26227 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26228 + "3:\n"
26229 +
26230 +#ifdef CONFIG_PAX_KERNEXEC
26231 + " movl %%cr0, %0\n"
26232 + " movl %0, %%eax\n"
26233 + " andl $0xFFFEFFFF, %%eax\n"
26234 + " movl %%eax, %%cr0\n"
26235 +#endif
26236 +
26237 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26238 +
26239 +#ifdef CONFIG_PAX_KERNEXEC
26240 + " movl %0, %%cr0\n"
26241 +#endif
26242 +
26243 " jmp 2b\n"
26244 ".previous\n"
26245 _ASM_EXTABLE(1b, 3b)
26246 - : : "r" (from), "r" (to) : "memory");
26247 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26248
26249 from += 64;
26250 to += 64;
26251 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
26252 static void fast_copy_page(void *to, void *from)
26253 {
26254 int i;
26255 + unsigned long cr0;
26256
26257 kernel_fpu_begin();
26258
26259 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
26260 * but that is for later. -AV
26261 */
26262 __asm__ __volatile__(
26263 - "1: prefetch (%0)\n"
26264 - " prefetch 64(%0)\n"
26265 - " prefetch 128(%0)\n"
26266 - " prefetch 192(%0)\n"
26267 - " prefetch 256(%0)\n"
26268 + "1: prefetch (%1)\n"
26269 + " prefetch 64(%1)\n"
26270 + " prefetch 128(%1)\n"
26271 + " prefetch 192(%1)\n"
26272 + " prefetch 256(%1)\n"
26273 "2: \n"
26274 ".section .fixup, \"ax\"\n"
26275 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26276 + "3: \n"
26277 +
26278 +#ifdef CONFIG_PAX_KERNEXEC
26279 + " movl %%cr0, %0\n"
26280 + " movl %0, %%eax\n"
26281 + " andl $0xFFFEFFFF, %%eax\n"
26282 + " movl %%eax, %%cr0\n"
26283 +#endif
26284 +
26285 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26286 +
26287 +#ifdef CONFIG_PAX_KERNEXEC
26288 + " movl %0, %%cr0\n"
26289 +#endif
26290 +
26291 " jmp 2b\n"
26292 ".previous\n"
26293 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26294 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26295
26296 for (i = 0; i < (4096-320)/64; i++) {
26297 __asm__ __volatile__ (
26298 - "1: prefetch 320(%0)\n"
26299 - "2: movq (%0), %%mm0\n"
26300 - " movntq %%mm0, (%1)\n"
26301 - " movq 8(%0), %%mm1\n"
26302 - " movntq %%mm1, 8(%1)\n"
26303 - " movq 16(%0), %%mm2\n"
26304 - " movntq %%mm2, 16(%1)\n"
26305 - " movq 24(%0), %%mm3\n"
26306 - " movntq %%mm3, 24(%1)\n"
26307 - " movq 32(%0), %%mm4\n"
26308 - " movntq %%mm4, 32(%1)\n"
26309 - " movq 40(%0), %%mm5\n"
26310 - " movntq %%mm5, 40(%1)\n"
26311 - " movq 48(%0), %%mm6\n"
26312 - " movntq %%mm6, 48(%1)\n"
26313 - " movq 56(%0), %%mm7\n"
26314 - " movntq %%mm7, 56(%1)\n"
26315 + "1: prefetch 320(%1)\n"
26316 + "2: movq (%1), %%mm0\n"
26317 + " movntq %%mm0, (%2)\n"
26318 + " movq 8(%1), %%mm1\n"
26319 + " movntq %%mm1, 8(%2)\n"
26320 + " movq 16(%1), %%mm2\n"
26321 + " movntq %%mm2, 16(%2)\n"
26322 + " movq 24(%1), %%mm3\n"
26323 + " movntq %%mm3, 24(%2)\n"
26324 + " movq 32(%1), %%mm4\n"
26325 + " movntq %%mm4, 32(%2)\n"
26326 + " movq 40(%1), %%mm5\n"
26327 + " movntq %%mm5, 40(%2)\n"
26328 + " movq 48(%1), %%mm6\n"
26329 + " movntq %%mm6, 48(%2)\n"
26330 + " movq 56(%1), %%mm7\n"
26331 + " movntq %%mm7, 56(%2)\n"
26332 ".section .fixup, \"ax\"\n"
26333 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26334 + "3:\n"
26335 +
26336 +#ifdef CONFIG_PAX_KERNEXEC
26337 + " movl %%cr0, %0\n"
26338 + " movl %0, %%eax\n"
26339 + " andl $0xFFFEFFFF, %%eax\n"
26340 + " movl %%eax, %%cr0\n"
26341 +#endif
26342 +
26343 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26344 +
26345 +#ifdef CONFIG_PAX_KERNEXEC
26346 + " movl %0, %%cr0\n"
26347 +#endif
26348 +
26349 " jmp 2b\n"
26350 ".previous\n"
26351 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26352 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26353
26354 from += 64;
26355 to += 64;
26356 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26357 static void fast_copy_page(void *to, void *from)
26358 {
26359 int i;
26360 + unsigned long cr0;
26361
26362 kernel_fpu_begin();
26363
26364 __asm__ __volatile__ (
26365 - "1: prefetch (%0)\n"
26366 - " prefetch 64(%0)\n"
26367 - " prefetch 128(%0)\n"
26368 - " prefetch 192(%0)\n"
26369 - " prefetch 256(%0)\n"
26370 + "1: prefetch (%1)\n"
26371 + " prefetch 64(%1)\n"
26372 + " prefetch 128(%1)\n"
26373 + " prefetch 192(%1)\n"
26374 + " prefetch 256(%1)\n"
26375 "2: \n"
26376 ".section .fixup, \"ax\"\n"
26377 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26378 + "3: \n"
26379 +
26380 +#ifdef CONFIG_PAX_KERNEXEC
26381 + " movl %%cr0, %0\n"
26382 + " movl %0, %%eax\n"
26383 + " andl $0xFFFEFFFF, %%eax\n"
26384 + " movl %%eax, %%cr0\n"
26385 +#endif
26386 +
26387 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26388 +
26389 +#ifdef CONFIG_PAX_KERNEXEC
26390 + " movl %0, %%cr0\n"
26391 +#endif
26392 +
26393 " jmp 2b\n"
26394 ".previous\n"
26395 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26396 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26397
26398 for (i = 0; i < 4096/64; i++) {
26399 __asm__ __volatile__ (
26400 - "1: prefetch 320(%0)\n"
26401 - "2: movq (%0), %%mm0\n"
26402 - " movq 8(%0), %%mm1\n"
26403 - " movq 16(%0), %%mm2\n"
26404 - " movq 24(%0), %%mm3\n"
26405 - " movq %%mm0, (%1)\n"
26406 - " movq %%mm1, 8(%1)\n"
26407 - " movq %%mm2, 16(%1)\n"
26408 - " movq %%mm3, 24(%1)\n"
26409 - " movq 32(%0), %%mm0\n"
26410 - " movq 40(%0), %%mm1\n"
26411 - " movq 48(%0), %%mm2\n"
26412 - " movq 56(%0), %%mm3\n"
26413 - " movq %%mm0, 32(%1)\n"
26414 - " movq %%mm1, 40(%1)\n"
26415 - " movq %%mm2, 48(%1)\n"
26416 - " movq %%mm3, 56(%1)\n"
26417 + "1: prefetch 320(%1)\n"
26418 + "2: movq (%1), %%mm0\n"
26419 + " movq 8(%1), %%mm1\n"
26420 + " movq 16(%1), %%mm2\n"
26421 + " movq 24(%1), %%mm3\n"
26422 + " movq %%mm0, (%2)\n"
26423 + " movq %%mm1, 8(%2)\n"
26424 + " movq %%mm2, 16(%2)\n"
26425 + " movq %%mm3, 24(%2)\n"
26426 + " movq 32(%1), %%mm0\n"
26427 + " movq 40(%1), %%mm1\n"
26428 + " movq 48(%1), %%mm2\n"
26429 + " movq 56(%1), %%mm3\n"
26430 + " movq %%mm0, 32(%2)\n"
26431 + " movq %%mm1, 40(%2)\n"
26432 + " movq %%mm2, 48(%2)\n"
26433 + " movq %%mm3, 56(%2)\n"
26434 ".section .fixup, \"ax\"\n"
26435 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26436 + "3:\n"
26437 +
26438 +#ifdef CONFIG_PAX_KERNEXEC
26439 + " movl %%cr0, %0\n"
26440 + " movl %0, %%eax\n"
26441 + " andl $0xFFFEFFFF, %%eax\n"
26442 + " movl %%eax, %%cr0\n"
26443 +#endif
26444 +
26445 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26446 +
26447 +#ifdef CONFIG_PAX_KERNEXEC
26448 + " movl %0, %%cr0\n"
26449 +#endif
26450 +
26451 " jmp 2b\n"
26452 ".previous\n"
26453 _ASM_EXTABLE(1b, 3b)
26454 - : : "r" (from), "r" (to) : "memory");
26455 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26456
26457 from += 64;
26458 to += 64;
26459 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26460 index f6d13ee..aca5f0b 100644
26461 --- a/arch/x86/lib/msr-reg.S
26462 +++ b/arch/x86/lib/msr-reg.S
26463 @@ -3,6 +3,7 @@
26464 #include <asm/dwarf2.h>
26465 #include <asm/asm.h>
26466 #include <asm/msr.h>
26467 +#include <asm/alternative-asm.h>
26468
26469 #ifdef CONFIG_X86_64
26470 /*
26471 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26472 CFI_STARTPROC
26473 pushq_cfi %rbx
26474 pushq_cfi %rbp
26475 - movq %rdi, %r10 /* Save pointer */
26476 + movq %rdi, %r9 /* Save pointer */
26477 xorl %r11d, %r11d /* Return value */
26478 movl (%rdi), %eax
26479 movl 4(%rdi), %ecx
26480 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26481 movl 28(%rdi), %edi
26482 CFI_REMEMBER_STATE
26483 1: \op
26484 -2: movl %eax, (%r10)
26485 +2: movl %eax, (%r9)
26486 movl %r11d, %eax /* Return value */
26487 - movl %ecx, 4(%r10)
26488 - movl %edx, 8(%r10)
26489 - movl %ebx, 12(%r10)
26490 - movl %ebp, 20(%r10)
26491 - movl %esi, 24(%r10)
26492 - movl %edi, 28(%r10)
26493 + movl %ecx, 4(%r9)
26494 + movl %edx, 8(%r9)
26495 + movl %ebx, 12(%r9)
26496 + movl %ebp, 20(%r9)
26497 + movl %esi, 24(%r9)
26498 + movl %edi, 28(%r9)
26499 popq_cfi %rbp
26500 popq_cfi %rbx
26501 + pax_force_retaddr
26502 ret
26503 3:
26504 CFI_RESTORE_STATE
26505 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26506 index fc6ba17..04471c5 100644
26507 --- a/arch/x86/lib/putuser.S
26508 +++ b/arch/x86/lib/putuser.S
26509 @@ -16,7 +16,9 @@
26510 #include <asm/errno.h>
26511 #include <asm/asm.h>
26512 #include <asm/smap.h>
26513 -
26514 +#include <asm/segment.h>
26515 +#include <asm/pgtable.h>
26516 +#include <asm/alternative-asm.h>
26517
26518 /*
26519 * __put_user_X
26520 @@ -30,57 +32,125 @@
26521 * as they get called from within inline assembly.
26522 */
26523
26524 -#define ENTER CFI_STARTPROC ; \
26525 - GET_THREAD_INFO(%_ASM_BX)
26526 -#define EXIT ASM_CLAC ; \
26527 - ret ; \
26528 +#define ENTER CFI_STARTPROC
26529 +#define EXIT ASM_CLAC ; \
26530 + pax_force_retaddr ; \
26531 + ret ; \
26532 CFI_ENDPROC
26533
26534 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26535 +#define _DEST %_ASM_CX,%_ASM_BX
26536 +#else
26537 +#define _DEST %_ASM_CX
26538 +#endif
26539 +
26540 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26541 +#define __copyuser_seg gs;
26542 +#else
26543 +#define __copyuser_seg
26544 +#endif
26545 +
26546 .text
26547 ENTRY(__put_user_1)
26548 ENTER
26549 +
26550 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26551 + GET_THREAD_INFO(%_ASM_BX)
26552 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26553 jae bad_put_user
26554 ASM_STAC
26555 -1: movb %al,(%_ASM_CX)
26556 +
26557 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26558 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26559 + cmp %_ASM_BX,%_ASM_CX
26560 + jb 1234f
26561 + xor %ebx,%ebx
26562 +1234:
26563 +#endif
26564 +
26565 +#endif
26566 +
26567 +1: __copyuser_seg movb %al,(_DEST)
26568 xor %eax,%eax
26569 EXIT
26570 ENDPROC(__put_user_1)
26571
26572 ENTRY(__put_user_2)
26573 ENTER
26574 +
26575 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26576 + GET_THREAD_INFO(%_ASM_BX)
26577 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26578 sub $1,%_ASM_BX
26579 cmp %_ASM_BX,%_ASM_CX
26580 jae bad_put_user
26581 ASM_STAC
26582 -2: movw %ax,(%_ASM_CX)
26583 +
26584 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26585 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26586 + cmp %_ASM_BX,%_ASM_CX
26587 + jb 1234f
26588 + xor %ebx,%ebx
26589 +1234:
26590 +#endif
26591 +
26592 +#endif
26593 +
26594 +2: __copyuser_seg movw %ax,(_DEST)
26595 xor %eax,%eax
26596 EXIT
26597 ENDPROC(__put_user_2)
26598
26599 ENTRY(__put_user_4)
26600 ENTER
26601 +
26602 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26603 + GET_THREAD_INFO(%_ASM_BX)
26604 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26605 sub $3,%_ASM_BX
26606 cmp %_ASM_BX,%_ASM_CX
26607 jae bad_put_user
26608 ASM_STAC
26609 -3: movl %eax,(%_ASM_CX)
26610 +
26611 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26612 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26613 + cmp %_ASM_BX,%_ASM_CX
26614 + jb 1234f
26615 + xor %ebx,%ebx
26616 +1234:
26617 +#endif
26618 +
26619 +#endif
26620 +
26621 +3: __copyuser_seg movl %eax,(_DEST)
26622 xor %eax,%eax
26623 EXIT
26624 ENDPROC(__put_user_4)
26625
26626 ENTRY(__put_user_8)
26627 ENTER
26628 +
26629 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26630 + GET_THREAD_INFO(%_ASM_BX)
26631 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26632 sub $7,%_ASM_BX
26633 cmp %_ASM_BX,%_ASM_CX
26634 jae bad_put_user
26635 ASM_STAC
26636 -4: mov %_ASM_AX,(%_ASM_CX)
26637 +
26638 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26639 + mov $PAX_USER_SHADOW_BASE,%_ASM_BX
26640 + cmp %_ASM_BX,%_ASM_CX
26641 + jb 1234f
26642 + xor %ebx,%ebx
26643 +1234:
26644 +#endif
26645 +
26646 +#endif
26647 +
26648 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26649 #ifdef CONFIG_X86_32
26650 -5: movl %edx,4(%_ASM_CX)
26651 +5: __copyuser_seg movl %edx,4(_DEST)
26652 #endif
26653 xor %eax,%eax
26654 EXIT
26655 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26656 index 1cad221..de671ee 100644
26657 --- a/arch/x86/lib/rwlock.S
26658 +++ b/arch/x86/lib/rwlock.S
26659 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26660 FRAME
26661 0: LOCK_PREFIX
26662 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26663 +
26664 +#ifdef CONFIG_PAX_REFCOUNT
26665 + jno 1234f
26666 + LOCK_PREFIX
26667 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26668 + int $4
26669 +1234:
26670 + _ASM_EXTABLE(1234b, 1234b)
26671 +#endif
26672 +
26673 1: rep; nop
26674 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26675 jne 1b
26676 LOCK_PREFIX
26677 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26678 +
26679 +#ifdef CONFIG_PAX_REFCOUNT
26680 + jno 1234f
26681 + LOCK_PREFIX
26682 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26683 + int $4
26684 +1234:
26685 + _ASM_EXTABLE(1234b, 1234b)
26686 +#endif
26687 +
26688 jnz 0b
26689 ENDFRAME
26690 + pax_force_retaddr
26691 ret
26692 CFI_ENDPROC
26693 END(__write_lock_failed)
26694 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26695 FRAME
26696 0: LOCK_PREFIX
26697 READ_LOCK_SIZE(inc) (%__lock_ptr)
26698 +
26699 +#ifdef CONFIG_PAX_REFCOUNT
26700 + jno 1234f
26701 + LOCK_PREFIX
26702 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26703 + int $4
26704 +1234:
26705 + _ASM_EXTABLE(1234b, 1234b)
26706 +#endif
26707 +
26708 1: rep; nop
26709 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26710 js 1b
26711 LOCK_PREFIX
26712 READ_LOCK_SIZE(dec) (%__lock_ptr)
26713 +
26714 +#ifdef CONFIG_PAX_REFCOUNT
26715 + jno 1234f
26716 + LOCK_PREFIX
26717 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26718 + int $4
26719 +1234:
26720 + _ASM_EXTABLE(1234b, 1234b)
26721 +#endif
26722 +
26723 js 0b
26724 ENDFRAME
26725 + pax_force_retaddr
26726 ret
26727 CFI_ENDPROC
26728 END(__read_lock_failed)
26729 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26730 index 5dff5f0..cadebf4 100644
26731 --- a/arch/x86/lib/rwsem.S
26732 +++ b/arch/x86/lib/rwsem.S
26733 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26734 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26735 CFI_RESTORE __ASM_REG(dx)
26736 restore_common_regs
26737 + pax_force_retaddr
26738 ret
26739 CFI_ENDPROC
26740 ENDPROC(call_rwsem_down_read_failed)
26741 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26742 movq %rax,%rdi
26743 call rwsem_down_write_failed
26744 restore_common_regs
26745 + pax_force_retaddr
26746 ret
26747 CFI_ENDPROC
26748 ENDPROC(call_rwsem_down_write_failed)
26749 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26750 movq %rax,%rdi
26751 call rwsem_wake
26752 restore_common_regs
26753 -1: ret
26754 +1: pax_force_retaddr
26755 + ret
26756 CFI_ENDPROC
26757 ENDPROC(call_rwsem_wake)
26758
26759 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26760 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26761 CFI_RESTORE __ASM_REG(dx)
26762 restore_common_regs
26763 + pax_force_retaddr
26764 ret
26765 CFI_ENDPROC
26766 ENDPROC(call_rwsem_downgrade_wake)
26767 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26768 index a63efd6..ccecad8 100644
26769 --- a/arch/x86/lib/thunk_64.S
26770 +++ b/arch/x86/lib/thunk_64.S
26771 @@ -8,6 +8,7 @@
26772 #include <linux/linkage.h>
26773 #include <asm/dwarf2.h>
26774 #include <asm/calling.h>
26775 +#include <asm/alternative-asm.h>
26776
26777 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26778 .macro THUNK name, func, put_ret_addr_in_rdi=0
26779 @@ -41,5 +42,6 @@
26780 SAVE_ARGS
26781 restore:
26782 RESTORE_ARGS
26783 + pax_force_retaddr
26784 ret
26785 CFI_ENDPROC
26786 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26787 index f0312d7..9c39d63 100644
26788 --- a/arch/x86/lib/usercopy_32.c
26789 +++ b/arch/x86/lib/usercopy_32.c
26790 @@ -42,11 +42,13 @@ do { \
26791 int __d0; \
26792 might_fault(); \
26793 __asm__ __volatile__( \
26794 + __COPYUSER_SET_ES \
26795 ASM_STAC "\n" \
26796 "0: rep; stosl\n" \
26797 " movl %2,%0\n" \
26798 "1: rep; stosb\n" \
26799 "2: " ASM_CLAC "\n" \
26800 + __COPYUSER_RESTORE_ES \
26801 ".section .fixup,\"ax\"\n" \
26802 "3: lea 0(%2,%0,4),%0\n" \
26803 " jmp 2b\n" \
26804 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26805
26806 #ifdef CONFIG_X86_INTEL_USERCOPY
26807 static unsigned long
26808 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26809 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26810 {
26811 int d0, d1;
26812 __asm__ __volatile__(
26813 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26814 " .align 2,0x90\n"
26815 "3: movl 0(%4), %%eax\n"
26816 "4: movl 4(%4), %%edx\n"
26817 - "5: movl %%eax, 0(%3)\n"
26818 - "6: movl %%edx, 4(%3)\n"
26819 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26820 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26821 "7: movl 8(%4), %%eax\n"
26822 "8: movl 12(%4),%%edx\n"
26823 - "9: movl %%eax, 8(%3)\n"
26824 - "10: movl %%edx, 12(%3)\n"
26825 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26826 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26827 "11: movl 16(%4), %%eax\n"
26828 "12: movl 20(%4), %%edx\n"
26829 - "13: movl %%eax, 16(%3)\n"
26830 - "14: movl %%edx, 20(%3)\n"
26831 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26832 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26833 "15: movl 24(%4), %%eax\n"
26834 "16: movl 28(%4), %%edx\n"
26835 - "17: movl %%eax, 24(%3)\n"
26836 - "18: movl %%edx, 28(%3)\n"
26837 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26838 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26839 "19: movl 32(%4), %%eax\n"
26840 "20: movl 36(%4), %%edx\n"
26841 - "21: movl %%eax, 32(%3)\n"
26842 - "22: movl %%edx, 36(%3)\n"
26843 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26844 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26845 "23: movl 40(%4), %%eax\n"
26846 "24: movl 44(%4), %%edx\n"
26847 - "25: movl %%eax, 40(%3)\n"
26848 - "26: movl %%edx, 44(%3)\n"
26849 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26850 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26851 "27: movl 48(%4), %%eax\n"
26852 "28: movl 52(%4), %%edx\n"
26853 - "29: movl %%eax, 48(%3)\n"
26854 - "30: movl %%edx, 52(%3)\n"
26855 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26856 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26857 "31: movl 56(%4), %%eax\n"
26858 "32: movl 60(%4), %%edx\n"
26859 - "33: movl %%eax, 56(%3)\n"
26860 - "34: movl %%edx, 60(%3)\n"
26861 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26862 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26863 " addl $-64, %0\n"
26864 " addl $64, %4\n"
26865 " addl $64, %3\n"
26866 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26867 " shrl $2, %0\n"
26868 " andl $3, %%eax\n"
26869 " cld\n"
26870 + __COPYUSER_SET_ES
26871 "99: rep; movsl\n"
26872 "36: movl %%eax, %0\n"
26873 "37: rep; movsb\n"
26874 "100:\n"
26875 + __COPYUSER_RESTORE_ES
26876 ".section .fixup,\"ax\"\n"
26877 "101: lea 0(%%eax,%0,4),%0\n"
26878 " jmp 100b\n"
26879 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26880 }
26881
26882 static unsigned long
26883 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26884 +{
26885 + int d0, d1;
26886 + __asm__ __volatile__(
26887 + " .align 2,0x90\n"
26888 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26889 + " cmpl $67, %0\n"
26890 + " jbe 3f\n"
26891 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26892 + " .align 2,0x90\n"
26893 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26894 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26895 + "5: movl %%eax, 0(%3)\n"
26896 + "6: movl %%edx, 4(%3)\n"
26897 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26898 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26899 + "9: movl %%eax, 8(%3)\n"
26900 + "10: movl %%edx, 12(%3)\n"
26901 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26902 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26903 + "13: movl %%eax, 16(%3)\n"
26904 + "14: movl %%edx, 20(%3)\n"
26905 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26906 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26907 + "17: movl %%eax, 24(%3)\n"
26908 + "18: movl %%edx, 28(%3)\n"
26909 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26910 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26911 + "21: movl %%eax, 32(%3)\n"
26912 + "22: movl %%edx, 36(%3)\n"
26913 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26914 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26915 + "25: movl %%eax, 40(%3)\n"
26916 + "26: movl %%edx, 44(%3)\n"
26917 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26918 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26919 + "29: movl %%eax, 48(%3)\n"
26920 + "30: movl %%edx, 52(%3)\n"
26921 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26922 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26923 + "33: movl %%eax, 56(%3)\n"
26924 + "34: movl %%edx, 60(%3)\n"
26925 + " addl $-64, %0\n"
26926 + " addl $64, %4\n"
26927 + " addl $64, %3\n"
26928 + " cmpl $63, %0\n"
26929 + " ja 1b\n"
26930 + "35: movl %0, %%eax\n"
26931 + " shrl $2, %0\n"
26932 + " andl $3, %%eax\n"
26933 + " cld\n"
26934 + "99: rep; "__copyuser_seg" movsl\n"
26935 + "36: movl %%eax, %0\n"
26936 + "37: rep; "__copyuser_seg" movsb\n"
26937 + "100:\n"
26938 + ".section .fixup,\"ax\"\n"
26939 + "101: lea 0(%%eax,%0,4),%0\n"
26940 + " jmp 100b\n"
26941 + ".previous\n"
26942 + _ASM_EXTABLE(1b,100b)
26943 + _ASM_EXTABLE(2b,100b)
26944 + _ASM_EXTABLE(3b,100b)
26945 + _ASM_EXTABLE(4b,100b)
26946 + _ASM_EXTABLE(5b,100b)
26947 + _ASM_EXTABLE(6b,100b)
26948 + _ASM_EXTABLE(7b,100b)
26949 + _ASM_EXTABLE(8b,100b)
26950 + _ASM_EXTABLE(9b,100b)
26951 + _ASM_EXTABLE(10b,100b)
26952 + _ASM_EXTABLE(11b,100b)
26953 + _ASM_EXTABLE(12b,100b)
26954 + _ASM_EXTABLE(13b,100b)
26955 + _ASM_EXTABLE(14b,100b)
26956 + _ASM_EXTABLE(15b,100b)
26957 + _ASM_EXTABLE(16b,100b)
26958 + _ASM_EXTABLE(17b,100b)
26959 + _ASM_EXTABLE(18b,100b)
26960 + _ASM_EXTABLE(19b,100b)
26961 + _ASM_EXTABLE(20b,100b)
26962 + _ASM_EXTABLE(21b,100b)
26963 + _ASM_EXTABLE(22b,100b)
26964 + _ASM_EXTABLE(23b,100b)
26965 + _ASM_EXTABLE(24b,100b)
26966 + _ASM_EXTABLE(25b,100b)
26967 + _ASM_EXTABLE(26b,100b)
26968 + _ASM_EXTABLE(27b,100b)
26969 + _ASM_EXTABLE(28b,100b)
26970 + _ASM_EXTABLE(29b,100b)
26971 + _ASM_EXTABLE(30b,100b)
26972 + _ASM_EXTABLE(31b,100b)
26973 + _ASM_EXTABLE(32b,100b)
26974 + _ASM_EXTABLE(33b,100b)
26975 + _ASM_EXTABLE(34b,100b)
26976 + _ASM_EXTABLE(35b,100b)
26977 + _ASM_EXTABLE(36b,100b)
26978 + _ASM_EXTABLE(37b,100b)
26979 + _ASM_EXTABLE(99b,101b)
26980 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26981 + : "1"(to), "2"(from), "0"(size)
26982 + : "eax", "edx", "memory");
26983 + return size;
26984 +}
26985 +
26986 +static unsigned long __size_overflow(3)
26987 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26988 {
26989 int d0, d1;
26990 __asm__ __volatile__(
26991 " .align 2,0x90\n"
26992 - "0: movl 32(%4), %%eax\n"
26993 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26994 " cmpl $67, %0\n"
26995 " jbe 2f\n"
26996 - "1: movl 64(%4), %%eax\n"
26997 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26998 " .align 2,0x90\n"
26999 - "2: movl 0(%4), %%eax\n"
27000 - "21: movl 4(%4), %%edx\n"
27001 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27002 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27003 " movl %%eax, 0(%3)\n"
27004 " movl %%edx, 4(%3)\n"
27005 - "3: movl 8(%4), %%eax\n"
27006 - "31: movl 12(%4),%%edx\n"
27007 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27008 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27009 " movl %%eax, 8(%3)\n"
27010 " movl %%edx, 12(%3)\n"
27011 - "4: movl 16(%4), %%eax\n"
27012 - "41: movl 20(%4), %%edx\n"
27013 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27014 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27015 " movl %%eax, 16(%3)\n"
27016 " movl %%edx, 20(%3)\n"
27017 - "10: movl 24(%4), %%eax\n"
27018 - "51: movl 28(%4), %%edx\n"
27019 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27020 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27021 " movl %%eax, 24(%3)\n"
27022 " movl %%edx, 28(%3)\n"
27023 - "11: movl 32(%4), %%eax\n"
27024 - "61: movl 36(%4), %%edx\n"
27025 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27026 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27027 " movl %%eax, 32(%3)\n"
27028 " movl %%edx, 36(%3)\n"
27029 - "12: movl 40(%4), %%eax\n"
27030 - "71: movl 44(%4), %%edx\n"
27031 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27032 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27033 " movl %%eax, 40(%3)\n"
27034 " movl %%edx, 44(%3)\n"
27035 - "13: movl 48(%4), %%eax\n"
27036 - "81: movl 52(%4), %%edx\n"
27037 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27038 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27039 " movl %%eax, 48(%3)\n"
27040 " movl %%edx, 52(%3)\n"
27041 - "14: movl 56(%4), %%eax\n"
27042 - "91: movl 60(%4), %%edx\n"
27043 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27044 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27045 " movl %%eax, 56(%3)\n"
27046 " movl %%edx, 60(%3)\n"
27047 " addl $-64, %0\n"
27048 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27049 " shrl $2, %0\n"
27050 " andl $3, %%eax\n"
27051 " cld\n"
27052 - "6: rep; movsl\n"
27053 + "6: rep; "__copyuser_seg" movsl\n"
27054 " movl %%eax,%0\n"
27055 - "7: rep; movsb\n"
27056 + "7: rep; "__copyuser_seg" movsb\n"
27057 "8:\n"
27058 ".section .fixup,\"ax\"\n"
27059 "9: lea 0(%%eax,%0,4),%0\n"
27060 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
27061 * hyoshiok@miraclelinux.com
27062 */
27063
27064 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27065 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
27066 const void __user *from, unsigned long size)
27067 {
27068 int d0, d1;
27069
27070 __asm__ __volatile__(
27071 " .align 2,0x90\n"
27072 - "0: movl 32(%4), %%eax\n"
27073 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27074 " cmpl $67, %0\n"
27075 " jbe 2f\n"
27076 - "1: movl 64(%4), %%eax\n"
27077 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27078 " .align 2,0x90\n"
27079 - "2: movl 0(%4), %%eax\n"
27080 - "21: movl 4(%4), %%edx\n"
27081 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27082 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27083 " movnti %%eax, 0(%3)\n"
27084 " movnti %%edx, 4(%3)\n"
27085 - "3: movl 8(%4), %%eax\n"
27086 - "31: movl 12(%4),%%edx\n"
27087 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27088 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27089 " movnti %%eax, 8(%3)\n"
27090 " movnti %%edx, 12(%3)\n"
27091 - "4: movl 16(%4), %%eax\n"
27092 - "41: movl 20(%4), %%edx\n"
27093 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27094 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27095 " movnti %%eax, 16(%3)\n"
27096 " movnti %%edx, 20(%3)\n"
27097 - "10: movl 24(%4), %%eax\n"
27098 - "51: movl 28(%4), %%edx\n"
27099 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27100 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27101 " movnti %%eax, 24(%3)\n"
27102 " movnti %%edx, 28(%3)\n"
27103 - "11: movl 32(%4), %%eax\n"
27104 - "61: movl 36(%4), %%edx\n"
27105 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27106 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27107 " movnti %%eax, 32(%3)\n"
27108 " movnti %%edx, 36(%3)\n"
27109 - "12: movl 40(%4), %%eax\n"
27110 - "71: movl 44(%4), %%edx\n"
27111 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27112 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27113 " movnti %%eax, 40(%3)\n"
27114 " movnti %%edx, 44(%3)\n"
27115 - "13: movl 48(%4), %%eax\n"
27116 - "81: movl 52(%4), %%edx\n"
27117 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27118 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27119 " movnti %%eax, 48(%3)\n"
27120 " movnti %%edx, 52(%3)\n"
27121 - "14: movl 56(%4), %%eax\n"
27122 - "91: movl 60(%4), %%edx\n"
27123 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27124 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27125 " movnti %%eax, 56(%3)\n"
27126 " movnti %%edx, 60(%3)\n"
27127 " addl $-64, %0\n"
27128 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27129 " shrl $2, %0\n"
27130 " andl $3, %%eax\n"
27131 " cld\n"
27132 - "6: rep; movsl\n"
27133 + "6: rep; "__copyuser_seg" movsl\n"
27134 " movl %%eax,%0\n"
27135 - "7: rep; movsb\n"
27136 + "7: rep; "__copyuser_seg" movsb\n"
27137 "8:\n"
27138 ".section .fixup,\"ax\"\n"
27139 "9: lea 0(%%eax,%0,4),%0\n"
27140 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
27141 return size;
27142 }
27143
27144 -static unsigned long __copy_user_intel_nocache(void *to,
27145 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
27146 const void __user *from, unsigned long size)
27147 {
27148 int d0, d1;
27149
27150 __asm__ __volatile__(
27151 " .align 2,0x90\n"
27152 - "0: movl 32(%4), %%eax\n"
27153 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
27154 " cmpl $67, %0\n"
27155 " jbe 2f\n"
27156 - "1: movl 64(%4), %%eax\n"
27157 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
27158 " .align 2,0x90\n"
27159 - "2: movl 0(%4), %%eax\n"
27160 - "21: movl 4(%4), %%edx\n"
27161 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
27162 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
27163 " movnti %%eax, 0(%3)\n"
27164 " movnti %%edx, 4(%3)\n"
27165 - "3: movl 8(%4), %%eax\n"
27166 - "31: movl 12(%4),%%edx\n"
27167 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
27168 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
27169 " movnti %%eax, 8(%3)\n"
27170 " movnti %%edx, 12(%3)\n"
27171 - "4: movl 16(%4), %%eax\n"
27172 - "41: movl 20(%4), %%edx\n"
27173 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
27174 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
27175 " movnti %%eax, 16(%3)\n"
27176 " movnti %%edx, 20(%3)\n"
27177 - "10: movl 24(%4), %%eax\n"
27178 - "51: movl 28(%4), %%edx\n"
27179 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
27180 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
27181 " movnti %%eax, 24(%3)\n"
27182 " movnti %%edx, 28(%3)\n"
27183 - "11: movl 32(%4), %%eax\n"
27184 - "61: movl 36(%4), %%edx\n"
27185 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
27186 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
27187 " movnti %%eax, 32(%3)\n"
27188 " movnti %%edx, 36(%3)\n"
27189 - "12: movl 40(%4), %%eax\n"
27190 - "71: movl 44(%4), %%edx\n"
27191 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
27192 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
27193 " movnti %%eax, 40(%3)\n"
27194 " movnti %%edx, 44(%3)\n"
27195 - "13: movl 48(%4), %%eax\n"
27196 - "81: movl 52(%4), %%edx\n"
27197 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
27198 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
27199 " movnti %%eax, 48(%3)\n"
27200 " movnti %%edx, 52(%3)\n"
27201 - "14: movl 56(%4), %%eax\n"
27202 - "91: movl 60(%4), %%edx\n"
27203 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
27204 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
27205 " movnti %%eax, 56(%3)\n"
27206 " movnti %%edx, 60(%3)\n"
27207 " addl $-64, %0\n"
27208 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
27209 " shrl $2, %0\n"
27210 " andl $3, %%eax\n"
27211 " cld\n"
27212 - "6: rep; movsl\n"
27213 + "6: rep; "__copyuser_seg" movsl\n"
27214 " movl %%eax,%0\n"
27215 - "7: rep; movsb\n"
27216 + "7: rep; "__copyuser_seg" movsb\n"
27217 "8:\n"
27218 ".section .fixup,\"ax\"\n"
27219 "9: lea 0(%%eax,%0,4),%0\n"
27220 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
27221 */
27222 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
27223 unsigned long size);
27224 -unsigned long __copy_user_intel(void __user *to, const void *from,
27225 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
27226 + unsigned long size);
27227 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
27228 unsigned long size);
27229 unsigned long __copy_user_zeroing_intel_nocache(void *to,
27230 const void __user *from, unsigned long size);
27231 #endif /* CONFIG_X86_INTEL_USERCOPY */
27232
27233 /* Generic arbitrary sized copy. */
27234 -#define __copy_user(to, from, size) \
27235 +#define __copy_user(to, from, size, prefix, set, restore) \
27236 do { \
27237 int __d0, __d1, __d2; \
27238 __asm__ __volatile__( \
27239 + set \
27240 " cmp $7,%0\n" \
27241 " jbe 1f\n" \
27242 " movl %1,%0\n" \
27243 " negl %0\n" \
27244 " andl $7,%0\n" \
27245 " subl %0,%3\n" \
27246 - "4: rep; movsb\n" \
27247 + "4: rep; "prefix"movsb\n" \
27248 " movl %3,%0\n" \
27249 " shrl $2,%0\n" \
27250 " andl $3,%3\n" \
27251 " .align 2,0x90\n" \
27252 - "0: rep; movsl\n" \
27253 + "0: rep; "prefix"movsl\n" \
27254 " movl %3,%0\n" \
27255 - "1: rep; movsb\n" \
27256 + "1: rep; "prefix"movsb\n" \
27257 "2:\n" \
27258 + restore \
27259 ".section .fixup,\"ax\"\n" \
27260 "5: addl %3,%0\n" \
27261 " jmp 2b\n" \
27262 @@ -538,14 +650,14 @@ do { \
27263 " negl %0\n" \
27264 " andl $7,%0\n" \
27265 " subl %0,%3\n" \
27266 - "4: rep; movsb\n" \
27267 + "4: rep; "__copyuser_seg"movsb\n" \
27268 " movl %3,%0\n" \
27269 " shrl $2,%0\n" \
27270 " andl $3,%3\n" \
27271 " .align 2,0x90\n" \
27272 - "0: rep; movsl\n" \
27273 + "0: rep; "__copyuser_seg"movsl\n" \
27274 " movl %3,%0\n" \
27275 - "1: rep; movsb\n" \
27276 + "1: rep; "__copyuser_seg"movsb\n" \
27277 "2:\n" \
27278 ".section .fixup,\"ax\"\n" \
27279 "5: addl %3,%0\n" \
27280 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
27281 {
27282 stac();
27283 if (movsl_is_ok(to, from, n))
27284 - __copy_user(to, from, n);
27285 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
27286 else
27287 - n = __copy_user_intel(to, from, n);
27288 + n = __generic_copy_to_user_intel(to, from, n);
27289 clac();
27290 return n;
27291 }
27292 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
27293 {
27294 stac();
27295 if (movsl_is_ok(to, from, n))
27296 - __copy_user(to, from, n);
27297 + __copy_user(to, from, n, __copyuser_seg, "", "");
27298 else
27299 - n = __copy_user_intel((void __user *)to,
27300 - (const void *)from, n);
27301 + n = __generic_copy_from_user_intel(to, from, n);
27302 clac();
27303 return n;
27304 }
27305 @@ -632,66 +743,51 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
27306 if (n > 64 && cpu_has_xmm2)
27307 n = __copy_user_intel_nocache(to, from, n);
27308 else
27309 - __copy_user(to, from, n);
27310 + __copy_user(to, from, n, __copyuser_seg, "", "");
27311 #else
27312 - __copy_user(to, from, n);
27313 + __copy_user(to, from, n, __copyuser_seg, "", "");
27314 #endif
27315 clac();
27316 return n;
27317 }
27318 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27319
27320 -/**
27321 - * copy_to_user: - Copy a block of data into user space.
27322 - * @to: Destination address, in user space.
27323 - * @from: Source address, in kernel space.
27324 - * @n: Number of bytes to copy.
27325 - *
27326 - * Context: User context only. This function may sleep.
27327 - *
27328 - * Copy data from kernel space to user space.
27329 - *
27330 - * Returns number of bytes that could not be copied.
27331 - * On success, this will be zero.
27332 - */
27333 -unsigned long
27334 -copy_to_user(void __user *to, const void *from, unsigned long n)
27335 -{
27336 - if (access_ok(VERIFY_WRITE, to, n))
27337 - n = __copy_to_user(to, from, n);
27338 - return n;
27339 -}
27340 -EXPORT_SYMBOL(copy_to_user);
27341 -
27342 -/**
27343 - * copy_from_user: - Copy a block of data from user space.
27344 - * @to: Destination address, in kernel space.
27345 - * @from: Source address, in user space.
27346 - * @n: Number of bytes to copy.
27347 - *
27348 - * Context: User context only. This function may sleep.
27349 - *
27350 - * Copy data from user space to kernel space.
27351 - *
27352 - * Returns number of bytes that could not be copied.
27353 - * On success, this will be zero.
27354 - *
27355 - * If some data could not be copied, this function will pad the copied
27356 - * data to the requested size using zero bytes.
27357 - */
27358 -unsigned long
27359 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27360 -{
27361 - if (access_ok(VERIFY_READ, from, n))
27362 - n = __copy_from_user(to, from, n);
27363 - else
27364 - memset(to, 0, n);
27365 - return n;
27366 -}
27367 -EXPORT_SYMBOL(_copy_from_user);
27368 -
27369 void copy_from_user_overflow(void)
27370 {
27371 WARN(1, "Buffer overflow detected!\n");
27372 }
27373 EXPORT_SYMBOL(copy_from_user_overflow);
27374 +
27375 +void copy_to_user_overflow(void)
27376 +{
27377 + WARN(1, "Buffer overflow detected!\n");
27378 +}
27379 +EXPORT_SYMBOL(copy_to_user_overflow);
27380 +
27381 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27382 +void __set_fs(mm_segment_t x)
27383 +{
27384 + switch (x.seg) {
27385 + case 0:
27386 + loadsegment(gs, 0);
27387 + break;
27388 + case TASK_SIZE_MAX:
27389 + loadsegment(gs, __USER_DS);
27390 + break;
27391 + case -1UL:
27392 + loadsegment(gs, __KERNEL_DS);
27393 + break;
27394 + default:
27395 + BUG();
27396 + }
27397 + return;
27398 +}
27399 +EXPORT_SYMBOL(__set_fs);
27400 +
27401 +void set_fs(mm_segment_t x)
27402 +{
27403 + current_thread_info()->addr_limit = x;
27404 + __set_fs(x);
27405 +}
27406 +EXPORT_SYMBOL(set_fs);
27407 +#endif
27408 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27409 index 906fea3..ee8a097 100644
27410 --- a/arch/x86/lib/usercopy_64.c
27411 +++ b/arch/x86/lib/usercopy_64.c
27412 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27413 _ASM_EXTABLE(0b,3b)
27414 _ASM_EXTABLE(1b,2b)
27415 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27416 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27417 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27418 [zero] "r" (0UL), [eight] "r" (8UL));
27419 clac();
27420 return size;
27421 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27422 }
27423 EXPORT_SYMBOL(clear_user);
27424
27425 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27426 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27427 {
27428 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27429 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27430 - }
27431 - return len;
27432 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27433 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27434 + return len;
27435 }
27436 EXPORT_SYMBOL(copy_in_user);
27437
27438 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27439 * it is not necessary to optimize tail handling.
27440 */
27441 unsigned long
27442 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27443 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27444 {
27445 char c;
27446 unsigned zero_len;
27447 @@ -87,3 +86,15 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27448 clac();
27449 return len;
27450 }
27451 +
27452 +void copy_from_user_overflow(void)
27453 +{
27454 + WARN(1, "Buffer overflow detected!\n");
27455 +}
27456 +EXPORT_SYMBOL(copy_from_user_overflow);
27457 +
27458 +void copy_to_user_overflow(void)
27459 +{
27460 + WARN(1, "Buffer overflow detected!\n");
27461 +}
27462 +EXPORT_SYMBOL(copy_to_user_overflow);
27463 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27464 index 903ec1e..c4166b2 100644
27465 --- a/arch/x86/mm/extable.c
27466 +++ b/arch/x86/mm/extable.c
27467 @@ -6,12 +6,24 @@
27468 static inline unsigned long
27469 ex_insn_addr(const struct exception_table_entry *x)
27470 {
27471 - return (unsigned long)&x->insn + x->insn;
27472 + unsigned long reloc = 0;
27473 +
27474 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27475 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27476 +#endif
27477 +
27478 + return (unsigned long)&x->insn + x->insn + reloc;
27479 }
27480 static inline unsigned long
27481 ex_fixup_addr(const struct exception_table_entry *x)
27482 {
27483 - return (unsigned long)&x->fixup + x->fixup;
27484 + unsigned long reloc = 0;
27485 +
27486 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27487 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27488 +#endif
27489 +
27490 + return (unsigned long)&x->fixup + x->fixup + reloc;
27491 }
27492
27493 int fixup_exception(struct pt_regs *regs)
27494 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27495 unsigned long new_ip;
27496
27497 #ifdef CONFIG_PNPBIOS
27498 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27499 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27500 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27501 extern u32 pnp_bios_is_utter_crap;
27502 pnp_bios_is_utter_crap = 1;
27503 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27504 i += 4;
27505 p->fixup -= i;
27506 i += 4;
27507 +
27508 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27509 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27510 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27511 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27512 +#endif
27513 +
27514 }
27515 }
27516
27517 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27518 index fb674fd..223a693 100644
27519 --- a/arch/x86/mm/fault.c
27520 +++ b/arch/x86/mm/fault.c
27521 @@ -13,12 +13,19 @@
27522 #include <linux/perf_event.h> /* perf_sw_event */
27523 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27524 #include <linux/prefetch.h> /* prefetchw */
27525 +#include <linux/unistd.h>
27526 +#include <linux/compiler.h>
27527
27528 #include <asm/traps.h> /* dotraplinkage, ... */
27529 #include <asm/pgalloc.h> /* pgd_*(), ... */
27530 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27531 #include <asm/fixmap.h> /* VSYSCALL_START */
27532 #include <asm/context_tracking.h> /* exception_enter(), ... */
27533 +#include <asm/tlbflush.h>
27534 +
27535 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27536 +#include <asm/stacktrace.h>
27537 +#endif
27538
27539 /*
27540 * Page fault error code bits:
27541 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27542 int ret = 0;
27543
27544 /* kprobe_running() needs smp_processor_id() */
27545 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27546 + if (kprobes_built_in() && !user_mode(regs)) {
27547 preempt_disable();
27548 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27549 ret = 1;
27550 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27551 return !instr_lo || (instr_lo>>1) == 1;
27552 case 0x00:
27553 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27554 - if (probe_kernel_address(instr, opcode))
27555 + if (user_mode(regs)) {
27556 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27557 + return 0;
27558 + } else if (probe_kernel_address(instr, opcode))
27559 return 0;
27560
27561 *prefetch = (instr_lo == 0xF) &&
27562 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27563 while (instr < max_instr) {
27564 unsigned char opcode;
27565
27566 - if (probe_kernel_address(instr, opcode))
27567 + if (user_mode(regs)) {
27568 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27569 + break;
27570 + } else if (probe_kernel_address(instr, opcode))
27571 break;
27572
27573 instr++;
27574 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27575 force_sig_info(si_signo, &info, tsk);
27576 }
27577
27578 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27579 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27580 +#endif
27581 +
27582 +#ifdef CONFIG_PAX_EMUTRAMP
27583 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27584 +#endif
27585 +
27586 +#ifdef CONFIG_PAX_PAGEEXEC
27587 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27588 +{
27589 + pgd_t *pgd;
27590 + pud_t *pud;
27591 + pmd_t *pmd;
27592 +
27593 + pgd = pgd_offset(mm, address);
27594 + if (!pgd_present(*pgd))
27595 + return NULL;
27596 + pud = pud_offset(pgd, address);
27597 + if (!pud_present(*pud))
27598 + return NULL;
27599 + pmd = pmd_offset(pud, address);
27600 + if (!pmd_present(*pmd))
27601 + return NULL;
27602 + return pmd;
27603 +}
27604 +#endif
27605 +
27606 DEFINE_SPINLOCK(pgd_lock);
27607 LIST_HEAD(pgd_list);
27608
27609 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27610 for (address = VMALLOC_START & PMD_MASK;
27611 address >= TASK_SIZE && address < FIXADDR_TOP;
27612 address += PMD_SIZE) {
27613 +
27614 +#ifdef CONFIG_PAX_PER_CPU_PGD
27615 + unsigned long cpu;
27616 +#else
27617 struct page *page;
27618 +#endif
27619
27620 spin_lock(&pgd_lock);
27621 +
27622 +#ifdef CONFIG_PAX_PER_CPU_PGD
27623 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27624 + pgd_t *pgd = get_cpu_pgd(cpu);
27625 + pmd_t *ret;
27626 +#else
27627 list_for_each_entry(page, &pgd_list, lru) {
27628 + pgd_t *pgd;
27629 spinlock_t *pgt_lock;
27630 pmd_t *ret;
27631
27632 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27633 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27634
27635 spin_lock(pgt_lock);
27636 - ret = vmalloc_sync_one(page_address(page), address);
27637 + pgd = page_address(page);
27638 +#endif
27639 +
27640 + ret = vmalloc_sync_one(pgd, address);
27641 +
27642 +#ifndef CONFIG_PAX_PER_CPU_PGD
27643 spin_unlock(pgt_lock);
27644 +#endif
27645
27646 if (!ret)
27647 break;
27648 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27649 * an interrupt in the middle of a task switch..
27650 */
27651 pgd_paddr = read_cr3();
27652 +
27653 +#ifdef CONFIG_PAX_PER_CPU_PGD
27654 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27655 +#endif
27656 +
27657 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27658 if (!pmd_k)
27659 return -1;
27660 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27661 * happen within a race in page table update. In the later
27662 * case just flush:
27663 */
27664 +
27665 +#ifdef CONFIG_PAX_PER_CPU_PGD
27666 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27667 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27668 +#else
27669 pgd = pgd_offset(current->active_mm, address);
27670 +#endif
27671 +
27672 pgd_ref = pgd_offset_k(address);
27673 if (pgd_none(*pgd_ref))
27674 return -1;
27675 @@ -541,7 +612,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27676 static int is_errata100(struct pt_regs *regs, unsigned long address)
27677 {
27678 #ifdef CONFIG_X86_64
27679 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27680 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27681 return 1;
27682 #endif
27683 return 0;
27684 @@ -568,7 +639,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27685 }
27686
27687 static const char nx_warning[] = KERN_CRIT
27688 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27689 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27690
27691 static void
27692 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27693 @@ -577,15 +648,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27694 if (!oops_may_print())
27695 return;
27696
27697 - if (error_code & PF_INSTR) {
27698 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27699 unsigned int level;
27700
27701 pte_t *pte = lookup_address(address, &level);
27702
27703 if (pte && pte_present(*pte) && !pte_exec(*pte))
27704 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27705 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27706 }
27707
27708 +#ifdef CONFIG_PAX_KERNEXEC
27709 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27710 + if (current->signal->curr_ip)
27711 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27712 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27713 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27714 + else
27715 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27716 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27717 + }
27718 +#endif
27719 +
27720 printk(KERN_ALERT "BUG: unable to handle kernel ");
27721 if (address < PAGE_SIZE)
27722 printk(KERN_CONT "NULL pointer dereference");
27723 @@ -748,6 +831,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27724 return;
27725 }
27726 #endif
27727 +
27728 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27729 + if (pax_is_fetch_fault(regs, error_code, address)) {
27730 +
27731 +#ifdef CONFIG_PAX_EMUTRAMP
27732 + switch (pax_handle_fetch_fault(regs)) {
27733 + case 2:
27734 + return;
27735 + }
27736 +#endif
27737 +
27738 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27739 + do_group_exit(SIGKILL);
27740 + }
27741 +#endif
27742 +
27743 /* Kernel addresses are always protection faults: */
27744 if (address >= TASK_SIZE)
27745 error_code |= PF_PROT;
27746 @@ -833,7 +932,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27747 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27748 printk(KERN_ERR
27749 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27750 - tsk->comm, tsk->pid, address);
27751 + tsk->comm, task_pid_nr(tsk), address);
27752 code = BUS_MCEERR_AR;
27753 }
27754 #endif
27755 @@ -896,6 +995,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27756 return 1;
27757 }
27758
27759 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27760 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27761 +{
27762 + pte_t *pte;
27763 + pmd_t *pmd;
27764 + spinlock_t *ptl;
27765 + unsigned char pte_mask;
27766 +
27767 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27768 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27769 + return 0;
27770 +
27771 + /* PaX: it's our fault, let's handle it if we can */
27772 +
27773 + /* PaX: take a look at read faults before acquiring any locks */
27774 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27775 + /* instruction fetch attempt from a protected page in user mode */
27776 + up_read(&mm->mmap_sem);
27777 +
27778 +#ifdef CONFIG_PAX_EMUTRAMP
27779 + switch (pax_handle_fetch_fault(regs)) {
27780 + case 2:
27781 + return 1;
27782 + }
27783 +#endif
27784 +
27785 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27786 + do_group_exit(SIGKILL);
27787 + }
27788 +
27789 + pmd = pax_get_pmd(mm, address);
27790 + if (unlikely(!pmd))
27791 + return 0;
27792 +
27793 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27794 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27795 + pte_unmap_unlock(pte, ptl);
27796 + return 0;
27797 + }
27798 +
27799 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27800 + /* write attempt to a protected page in user mode */
27801 + pte_unmap_unlock(pte, ptl);
27802 + return 0;
27803 + }
27804 +
27805 +#ifdef CONFIG_SMP
27806 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27807 +#else
27808 + if (likely(address > get_limit(regs->cs)))
27809 +#endif
27810 + {
27811 + set_pte(pte, pte_mkread(*pte));
27812 + __flush_tlb_one(address);
27813 + pte_unmap_unlock(pte, ptl);
27814 + up_read(&mm->mmap_sem);
27815 + return 1;
27816 + }
27817 +
27818 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27819 +
27820 + /*
27821 + * PaX: fill DTLB with user rights and retry
27822 + */
27823 + __asm__ __volatile__ (
27824 + "orb %2,(%1)\n"
27825 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27826 +/*
27827 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27828 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27829 + * page fault when examined during a TLB load attempt. this is true not only
27830 + * for PTEs holding a non-present entry but also present entries that will
27831 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27832 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27833 + * for our target pages since their PTEs are simply not in the TLBs at all.
27834 +
27835 + * the best thing in omitting it is that we gain around 15-20% speed in the
27836 + * fast path of the page fault handler and can get rid of tracing since we
27837 + * can no longer flush unintended entries.
27838 + */
27839 + "invlpg (%0)\n"
27840 +#endif
27841 + __copyuser_seg"testb $0,(%0)\n"
27842 + "xorb %3,(%1)\n"
27843 + :
27844 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27845 + : "memory", "cc");
27846 + pte_unmap_unlock(pte, ptl);
27847 + up_read(&mm->mmap_sem);
27848 + return 1;
27849 +}
27850 +#endif
27851 +
27852 /*
27853 * Handle a spurious fault caused by a stale TLB entry.
27854 *
27855 @@ -968,6 +1160,9 @@ int show_unhandled_signals = 1;
27856 static inline int
27857 access_error(unsigned long error_code, struct vm_area_struct *vma)
27858 {
27859 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27860 + return 1;
27861 +
27862 if (error_code & PF_WRITE) {
27863 /* write, present and write, not present: */
27864 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27865 @@ -996,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27866 if (error_code & PF_USER)
27867 return false;
27868
27869 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27870 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27871 return false;
27872
27873 return true;
27874 @@ -1012,18 +1207,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27875 {
27876 struct vm_area_struct *vma;
27877 struct task_struct *tsk;
27878 - unsigned long address;
27879 struct mm_struct *mm;
27880 int fault;
27881 int write = error_code & PF_WRITE;
27882 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27883 (write ? FAULT_FLAG_WRITE : 0);
27884
27885 - tsk = current;
27886 - mm = tsk->mm;
27887 -
27888 /* Get the faulting address: */
27889 - address = read_cr2();
27890 + unsigned long address = read_cr2();
27891 +
27892 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27893 + if (!user_mode(regs) && address < 2 * PAX_USER_SHADOW_BASE) {
27894 + if (!search_exception_tables(regs->ip)) {
27895 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27896 + bad_area_nosemaphore(regs, error_code, address);
27897 + return;
27898 + }
27899 + if (address < PAX_USER_SHADOW_BASE) {
27900 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27901 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27902 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27903 + } else
27904 + address -= PAX_USER_SHADOW_BASE;
27905 + }
27906 +#endif
27907 +
27908 + tsk = current;
27909 + mm = tsk->mm;
27910
27911 /*
27912 * Detect and handle instructions that would cause a page fault for
27913 @@ -1084,7 +1294,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27914 * User-mode registers count as a user access even for any
27915 * potential system fault or CPU buglet:
27916 */
27917 - if (user_mode_vm(regs)) {
27918 + if (user_mode(regs)) {
27919 local_irq_enable();
27920 error_code |= PF_USER;
27921 } else {
27922 @@ -1146,6 +1356,11 @@ retry:
27923 might_sleep();
27924 }
27925
27926 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27927 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27928 + return;
27929 +#endif
27930 +
27931 vma = find_vma(mm, address);
27932 if (unlikely(!vma)) {
27933 bad_area(regs, error_code, address);
27934 @@ -1157,18 +1372,24 @@ retry:
27935 bad_area(regs, error_code, address);
27936 return;
27937 }
27938 - if (error_code & PF_USER) {
27939 - /*
27940 - * Accessing the stack below %sp is always a bug.
27941 - * The large cushion allows instructions like enter
27942 - * and pusha to work. ("enter $65535, $31" pushes
27943 - * 32 pointers and then decrements %sp by 65535.)
27944 - */
27945 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27946 - bad_area(regs, error_code, address);
27947 - return;
27948 - }
27949 + /*
27950 + * Accessing the stack below %sp is always a bug.
27951 + * The large cushion allows instructions like enter
27952 + * and pusha to work. ("enter $65535, $31" pushes
27953 + * 32 pointers and then decrements %sp by 65535.)
27954 + */
27955 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27956 + bad_area(regs, error_code, address);
27957 + return;
27958 }
27959 +
27960 +#ifdef CONFIG_PAX_SEGMEXEC
27961 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27962 + bad_area(regs, error_code, address);
27963 + return;
27964 + }
27965 +#endif
27966 +
27967 if (unlikely(expand_stack(vma, address))) {
27968 bad_area(regs, error_code, address);
27969 return;
27970 @@ -1232,3 +1453,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27971 __do_page_fault(regs, error_code);
27972 exception_exit(regs);
27973 }
27974 +
27975 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27976 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27977 +{
27978 + struct mm_struct *mm = current->mm;
27979 + unsigned long ip = regs->ip;
27980 +
27981 + if (v8086_mode(regs))
27982 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27983 +
27984 +#ifdef CONFIG_PAX_PAGEEXEC
27985 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27986 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27987 + return true;
27988 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27989 + return true;
27990 + return false;
27991 + }
27992 +#endif
27993 +
27994 +#ifdef CONFIG_PAX_SEGMEXEC
27995 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27996 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27997 + return true;
27998 + return false;
27999 + }
28000 +#endif
28001 +
28002 + return false;
28003 +}
28004 +#endif
28005 +
28006 +#ifdef CONFIG_PAX_EMUTRAMP
28007 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
28008 +{
28009 + int err;
28010 +
28011 + do { /* PaX: libffi trampoline emulation */
28012 + unsigned char mov, jmp;
28013 + unsigned int addr1, addr2;
28014 +
28015 +#ifdef CONFIG_X86_64
28016 + if ((regs->ip + 9) >> 32)
28017 + break;
28018 +#endif
28019 +
28020 + err = get_user(mov, (unsigned char __user *)regs->ip);
28021 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28022 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28023 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28024 +
28025 + if (err)
28026 + break;
28027 +
28028 + if (mov == 0xB8 && jmp == 0xE9) {
28029 + regs->ax = addr1;
28030 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28031 + return 2;
28032 + }
28033 + } while (0);
28034 +
28035 + do { /* PaX: gcc trampoline emulation #1 */
28036 + unsigned char mov1, mov2;
28037 + unsigned short jmp;
28038 + unsigned int addr1, addr2;
28039 +
28040 +#ifdef CONFIG_X86_64
28041 + if ((regs->ip + 11) >> 32)
28042 + break;
28043 +#endif
28044 +
28045 + err = get_user(mov1, (unsigned char __user *)regs->ip);
28046 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28047 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
28048 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28049 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
28050 +
28051 + if (err)
28052 + break;
28053 +
28054 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
28055 + regs->cx = addr1;
28056 + regs->ax = addr2;
28057 + regs->ip = addr2;
28058 + return 2;
28059 + }
28060 + } while (0);
28061 +
28062 + do { /* PaX: gcc trampoline emulation #2 */
28063 + unsigned char mov, jmp;
28064 + unsigned int addr1, addr2;
28065 +
28066 +#ifdef CONFIG_X86_64
28067 + if ((regs->ip + 9) >> 32)
28068 + break;
28069 +#endif
28070 +
28071 + err = get_user(mov, (unsigned char __user *)regs->ip);
28072 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
28073 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
28074 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
28075 +
28076 + if (err)
28077 + break;
28078 +
28079 + if (mov == 0xB9 && jmp == 0xE9) {
28080 + regs->cx = addr1;
28081 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
28082 + return 2;
28083 + }
28084 + } while (0);
28085 +
28086 + return 1; /* PaX in action */
28087 +}
28088 +
28089 +#ifdef CONFIG_X86_64
28090 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
28091 +{
28092 + int err;
28093 +
28094 + do { /* PaX: libffi trampoline emulation */
28095 + unsigned short mov1, mov2, jmp1;
28096 + unsigned char stcclc, jmp2;
28097 + unsigned long addr1, addr2;
28098 +
28099 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28100 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28101 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28102 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28103 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
28104 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
28105 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
28106 +
28107 + if (err)
28108 + break;
28109 +
28110 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28111 + regs->r11 = addr1;
28112 + regs->r10 = addr2;
28113 + if (stcclc == 0xF8)
28114 + regs->flags &= ~X86_EFLAGS_CF;
28115 + else
28116 + regs->flags |= X86_EFLAGS_CF;
28117 + regs->ip = addr1;
28118 + return 2;
28119 + }
28120 + } while (0);
28121 +
28122 + do { /* PaX: gcc trampoline emulation #1 */
28123 + unsigned short mov1, mov2, jmp1;
28124 + unsigned char jmp2;
28125 + unsigned int addr1;
28126 + unsigned long addr2;
28127 +
28128 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28129 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
28130 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
28131 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
28132 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
28133 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
28134 +
28135 + if (err)
28136 + break;
28137 +
28138 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28139 + regs->r11 = addr1;
28140 + regs->r10 = addr2;
28141 + regs->ip = addr1;
28142 + return 2;
28143 + }
28144 + } while (0);
28145 +
28146 + do { /* PaX: gcc trampoline emulation #2 */
28147 + unsigned short mov1, mov2, jmp1;
28148 + unsigned char jmp2;
28149 + unsigned long addr1, addr2;
28150 +
28151 + err = get_user(mov1, (unsigned short __user *)regs->ip);
28152 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
28153 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
28154 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
28155 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
28156 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
28157 +
28158 + if (err)
28159 + break;
28160 +
28161 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
28162 + regs->r11 = addr1;
28163 + regs->r10 = addr2;
28164 + regs->ip = addr1;
28165 + return 2;
28166 + }
28167 + } while (0);
28168 +
28169 + return 1; /* PaX in action */
28170 +}
28171 +#endif
28172 +
28173 +/*
28174 + * PaX: decide what to do with offenders (regs->ip = fault address)
28175 + *
28176 + * returns 1 when task should be killed
28177 + * 2 when gcc trampoline was detected
28178 + */
28179 +static int pax_handle_fetch_fault(struct pt_regs *regs)
28180 +{
28181 + if (v8086_mode(regs))
28182 + return 1;
28183 +
28184 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
28185 + return 1;
28186 +
28187 +#ifdef CONFIG_X86_32
28188 + return pax_handle_fetch_fault_32(regs);
28189 +#else
28190 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
28191 + return pax_handle_fetch_fault_32(regs);
28192 + else
28193 + return pax_handle_fetch_fault_64(regs);
28194 +#endif
28195 +}
28196 +#endif
28197 +
28198 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28199 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
28200 +{
28201 + long i;
28202 +
28203 + printk(KERN_ERR "PAX: bytes at PC: ");
28204 + for (i = 0; i < 20; i++) {
28205 + unsigned char c;
28206 + if (get_user(c, (unsigned char __force_user *)pc+i))
28207 + printk(KERN_CONT "?? ");
28208 + else
28209 + printk(KERN_CONT "%02x ", c);
28210 + }
28211 + printk("\n");
28212 +
28213 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
28214 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
28215 + unsigned long c;
28216 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
28217 +#ifdef CONFIG_X86_32
28218 + printk(KERN_CONT "???????? ");
28219 +#else
28220 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
28221 + printk(KERN_CONT "???????? ???????? ");
28222 + else
28223 + printk(KERN_CONT "???????????????? ");
28224 +#endif
28225 + } else {
28226 +#ifdef CONFIG_X86_64
28227 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
28228 + printk(KERN_CONT "%08x ", (unsigned int)c);
28229 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
28230 + } else
28231 +#endif
28232 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
28233 + }
28234 + }
28235 + printk("\n");
28236 +}
28237 +#endif
28238 +
28239 +/**
28240 + * probe_kernel_write(): safely attempt to write to a location
28241 + * @dst: address to write to
28242 + * @src: pointer to the data that shall be written
28243 + * @size: size of the data chunk
28244 + *
28245 + * Safely write to address @dst from the buffer at @src. If a kernel fault
28246 + * happens, handle that and return -EFAULT.
28247 + */
28248 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
28249 +{
28250 + long ret;
28251 + mm_segment_t old_fs = get_fs();
28252 +
28253 + set_fs(KERNEL_DS);
28254 + pagefault_disable();
28255 + pax_open_kernel();
28256 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
28257 + pax_close_kernel();
28258 + pagefault_enable();
28259 + set_fs(old_fs);
28260 +
28261 + return ret ? -EFAULT : 0;
28262 +}
28263 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
28264 index dd74e46..7d26398 100644
28265 --- a/arch/x86/mm/gup.c
28266 +++ b/arch/x86/mm/gup.c
28267 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
28268 addr = start;
28269 len = (unsigned long) nr_pages << PAGE_SHIFT;
28270 end = start + len;
28271 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28272 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
28273 (void __user *)start, len)))
28274 return 0;
28275
28276 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
28277 index 6f31ee5..8ee4164 100644
28278 --- a/arch/x86/mm/highmem_32.c
28279 +++ b/arch/x86/mm/highmem_32.c
28280 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
28281 idx = type + KM_TYPE_NR*smp_processor_id();
28282 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28283 BUG_ON(!pte_none(*(kmap_pte-idx)));
28284 +
28285 + pax_open_kernel();
28286 set_pte(kmap_pte-idx, mk_pte(page, prot));
28287 + pax_close_kernel();
28288 +
28289 arch_flush_lazy_mmu_mode();
28290
28291 return (void *)vaddr;
28292 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
28293 index ae1aa71..56316db 100644
28294 --- a/arch/x86/mm/hugetlbpage.c
28295 +++ b/arch/x86/mm/hugetlbpage.c
28296 @@ -279,6 +279,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
28297 info.flags = 0;
28298 info.length = len;
28299 info.low_limit = TASK_UNMAPPED_BASE;
28300 +
28301 +#ifdef CONFIG_PAX_RANDMMAP
28302 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28303 + info.low_limit += current->mm->delta_mmap;
28304 +#endif
28305 +
28306 info.high_limit = TASK_SIZE;
28307 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
28308 info.align_offset = 0;
28309 @@ -311,6 +317,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
28310 VM_BUG_ON(addr != -ENOMEM);
28311 info.flags = 0;
28312 info.low_limit = TASK_UNMAPPED_BASE;
28313 +
28314 +#ifdef CONFIG_PAX_RANDMMAP
28315 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
28316 + info.low_limit += current->mm->delta_mmap;
28317 +#endif
28318 +
28319 info.high_limit = TASK_SIZE;
28320 addr = vm_unmapped_area(&info);
28321 }
28322 @@ -325,10 +337,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28323 struct hstate *h = hstate_file(file);
28324 struct mm_struct *mm = current->mm;
28325 struct vm_area_struct *vma;
28326 + unsigned long pax_task_size = TASK_SIZE;
28327 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28328
28329 if (len & ~huge_page_mask(h))
28330 return -EINVAL;
28331 - if (len > TASK_SIZE)
28332 +
28333 +#ifdef CONFIG_PAX_SEGMEXEC
28334 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28335 + pax_task_size = SEGMEXEC_TASK_SIZE;
28336 +#endif
28337 +
28338 + pax_task_size -= PAGE_SIZE;
28339 +
28340 + if (len > pax_task_size)
28341 return -ENOMEM;
28342
28343 if (flags & MAP_FIXED) {
28344 @@ -337,11 +359,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28345 return addr;
28346 }
28347
28348 +#ifdef CONFIG_PAX_RANDMMAP
28349 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28350 +#endif
28351 +
28352 if (addr) {
28353 addr = ALIGN(addr, huge_page_size(h));
28354 vma = find_vma(mm, addr);
28355 - if (TASK_SIZE - len >= addr &&
28356 - (!vma || addr + len <= vma->vm_start))
28357 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28358 return addr;
28359 }
28360 if (mm->get_unmapped_area == arch_get_unmapped_area)
28361 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28362 index d7aea41..0fc945b 100644
28363 --- a/arch/x86/mm/init.c
28364 +++ b/arch/x86/mm/init.c
28365 @@ -4,6 +4,7 @@
28366 #include <linux/swap.h>
28367 #include <linux/memblock.h>
28368 #include <linux/bootmem.h> /* for max_low_pfn */
28369 +#include <linux/tboot.h>
28370
28371 #include <asm/cacheflush.h>
28372 #include <asm/e820.h>
28373 @@ -16,6 +17,8 @@
28374 #include <asm/tlb.h>
28375 #include <asm/proto.h>
28376 #include <asm/dma.h> /* for MAX_DMA_PFN */
28377 +#include <asm/desc.h>
28378 +#include <asm/bios_ebda.h>
28379
28380 unsigned long __initdata pgt_buf_start;
28381 unsigned long __meminitdata pgt_buf_end;
28382 @@ -44,7 +47,7 @@ static void __init find_early_table_space(struct map_range *mr, int nr_range)
28383 {
28384 int i;
28385 unsigned long puds = 0, pmds = 0, ptes = 0, tables;
28386 - unsigned long start = 0, good_end;
28387 + unsigned long start = 0x100000, good_end;
28388 phys_addr_t base;
28389
28390 for (i = 0; i < nr_range; i++) {
28391 @@ -321,10 +324,40 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
28392 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28393 * mmio resources as well as potential bios/acpi data regions.
28394 */
28395 +
28396 +#ifdef CONFIG_GRKERNSEC_KMEM
28397 +static unsigned int ebda_start __read_only;
28398 +static unsigned int ebda_end __read_only;
28399 +#endif
28400 +
28401 int devmem_is_allowed(unsigned long pagenr)
28402 {
28403 - if (pagenr < 256)
28404 +#ifdef CONFIG_GRKERNSEC_KMEM
28405 + /* allow BDA */
28406 + if (!pagenr)
28407 return 1;
28408 + /* allow EBDA */
28409 + if (pagenr >= ebda_start && pagenr < ebda_end)
28410 + return 1;
28411 + /* if tboot is in use, allow access to its hardcoded serial log range */
28412 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28413 + return 1;
28414 +#else
28415 + if (!pagenr)
28416 + return 1;
28417 +#ifdef CONFIG_VM86
28418 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28419 + return 1;
28420 +#endif
28421 +#endif
28422 +
28423 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28424 + return 1;
28425 +#ifdef CONFIG_GRKERNSEC_KMEM
28426 + /* throw out everything else below 1MB */
28427 + if (pagenr <= 256)
28428 + return 0;
28429 +#endif
28430 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28431 return 0;
28432 if (!page_is_ram(pagenr))
28433 @@ -381,8 +414,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28434 #endif
28435 }
28436
28437 +#ifdef CONFIG_GRKERNSEC_KMEM
28438 +static inline void gr_init_ebda(void)
28439 +{
28440 + unsigned int ebda_addr;
28441 + unsigned int ebda_size = 0;
28442 +
28443 + ebda_addr = get_bios_ebda();
28444 + if (ebda_addr) {
28445 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28446 + ebda_size <<= 10;
28447 + }
28448 + if (ebda_addr && ebda_size) {
28449 + ebda_start = ebda_addr >> PAGE_SHIFT;
28450 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28451 + } else {
28452 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28453 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28454 + }
28455 +}
28456 +#else
28457 +static inline void gr_init_ebda(void) { }
28458 +#endif
28459 +
28460 void free_initmem(void)
28461 {
28462 +#ifdef CONFIG_PAX_KERNEXEC
28463 +#ifdef CONFIG_X86_32
28464 + /* PaX: limit KERNEL_CS to actual size */
28465 + unsigned long addr, limit;
28466 + struct desc_struct d;
28467 + int cpu;
28468 +#else
28469 + pgd_t *pgd;
28470 + pud_t *pud;
28471 + pmd_t *pmd;
28472 + unsigned long addr, end;
28473 +#endif
28474 +#endif
28475 +
28476 + gr_init_ebda();
28477 +
28478 +#ifdef CONFIG_PAX_KERNEXEC
28479 +#ifdef CONFIG_X86_32
28480 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28481 + limit = (limit - 1UL) >> PAGE_SHIFT;
28482 +
28483 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28484 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28485 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28486 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28487 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28488 + }
28489 +
28490 + /* PaX: make KERNEL_CS read-only */
28491 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28492 + if (!paravirt_enabled())
28493 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28494 +/*
28495 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28496 + pgd = pgd_offset_k(addr);
28497 + pud = pud_offset(pgd, addr);
28498 + pmd = pmd_offset(pud, addr);
28499 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28500 + }
28501 +*/
28502 +#ifdef CONFIG_X86_PAE
28503 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28504 +/*
28505 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28506 + pgd = pgd_offset_k(addr);
28507 + pud = pud_offset(pgd, addr);
28508 + pmd = pmd_offset(pud, addr);
28509 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28510 + }
28511 +*/
28512 +#endif
28513 +
28514 +#ifdef CONFIG_MODULES
28515 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28516 +#endif
28517 +
28518 +#else
28519 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28520 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28521 + pgd = pgd_offset_k(addr);
28522 + pud = pud_offset(pgd, addr);
28523 + pmd = pmd_offset(pud, addr);
28524 + if (!pmd_present(*pmd))
28525 + continue;
28526 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28527 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28528 + else
28529 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28530 + }
28531 +
28532 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28533 + end = addr + KERNEL_IMAGE_SIZE;
28534 + for (; addr < end; addr += PMD_SIZE) {
28535 + pgd = pgd_offset_k(addr);
28536 + pud = pud_offset(pgd, addr);
28537 + pmd = pmd_offset(pud, addr);
28538 + if (!pmd_present(*pmd))
28539 + continue;
28540 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28541 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28542 + }
28543 +#endif
28544 +
28545 + flush_tlb_all();
28546 +#endif
28547 +
28548 free_init_pages("unused kernel memory",
28549 (unsigned long)(&__init_begin),
28550 (unsigned long)(&__init_end));
28551 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28552 index 745d66b..56bf568 100644
28553 --- a/arch/x86/mm/init_32.c
28554 +++ b/arch/x86/mm/init_32.c
28555 @@ -73,36 +73,6 @@ static __init void *alloc_low_page(void)
28556 }
28557
28558 /*
28559 - * Creates a middle page table and puts a pointer to it in the
28560 - * given global directory entry. This only returns the gd entry
28561 - * in non-PAE compilation mode, since the middle layer is folded.
28562 - */
28563 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28564 -{
28565 - pud_t *pud;
28566 - pmd_t *pmd_table;
28567 -
28568 -#ifdef CONFIG_X86_PAE
28569 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28570 - if (after_bootmem)
28571 - pmd_table = (pmd_t *)alloc_bootmem_pages(PAGE_SIZE);
28572 - else
28573 - pmd_table = (pmd_t *)alloc_low_page();
28574 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28575 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28576 - pud = pud_offset(pgd, 0);
28577 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28578 -
28579 - return pmd_table;
28580 - }
28581 -#endif
28582 - pud = pud_offset(pgd, 0);
28583 - pmd_table = pmd_offset(pud, 0);
28584 -
28585 - return pmd_table;
28586 -}
28587 -
28588 -/*
28589 * Create a page table and place a pointer to it in a middle page
28590 * directory entry:
28591 */
28592 @@ -122,13 +92,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28593 page_table = (pte_t *)alloc_low_page();
28594
28595 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28596 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28597 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28598 +#else
28599 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28600 +#endif
28601 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28602 }
28603
28604 return pte_offset_kernel(pmd, 0);
28605 }
28606
28607 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28608 +{
28609 + pud_t *pud;
28610 + pmd_t *pmd_table;
28611 +
28612 + pud = pud_offset(pgd, 0);
28613 + pmd_table = pmd_offset(pud, 0);
28614 +
28615 + return pmd_table;
28616 +}
28617 +
28618 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28619 {
28620 int pgd_idx = pgd_index(vaddr);
28621 @@ -202,6 +187,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28622 int pgd_idx, pmd_idx;
28623 unsigned long vaddr;
28624 pgd_t *pgd;
28625 + pud_t *pud;
28626 pmd_t *pmd;
28627 pte_t *pte = NULL;
28628
28629 @@ -211,8 +197,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28630 pgd = pgd_base + pgd_idx;
28631
28632 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28633 - pmd = one_md_table_init(pgd);
28634 - pmd = pmd + pmd_index(vaddr);
28635 + pud = pud_offset(pgd, vaddr);
28636 + pmd = pmd_offset(pud, vaddr);
28637 +
28638 +#ifdef CONFIG_X86_PAE
28639 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28640 +#endif
28641 +
28642 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28643 pmd++, pmd_idx++) {
28644 pte = page_table_kmap_check(one_page_table_init(pmd),
28645 @@ -224,11 +215,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28646 }
28647 }
28648
28649 -static inline int is_kernel_text(unsigned long addr)
28650 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28651 {
28652 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28653 - return 1;
28654 - return 0;
28655 + if ((start > ktla_ktva((unsigned long)_etext) ||
28656 + end <= ktla_ktva((unsigned long)_stext)) &&
28657 + (start > ktla_ktva((unsigned long)_einittext) ||
28658 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28659 +
28660 +#ifdef CONFIG_ACPI_SLEEP
28661 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28662 +#endif
28663 +
28664 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28665 + return 0;
28666 + return 1;
28667 }
28668
28669 /*
28670 @@ -245,9 +245,10 @@ kernel_physical_mapping_init(unsigned long start,
28671 unsigned long last_map_addr = end;
28672 unsigned long start_pfn, end_pfn;
28673 pgd_t *pgd_base = swapper_pg_dir;
28674 - int pgd_idx, pmd_idx, pte_ofs;
28675 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28676 unsigned long pfn;
28677 pgd_t *pgd;
28678 + pud_t *pud;
28679 pmd_t *pmd;
28680 pte_t *pte;
28681 unsigned pages_2m, pages_4k;
28682 @@ -280,8 +281,13 @@ repeat:
28683 pfn = start_pfn;
28684 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28685 pgd = pgd_base + pgd_idx;
28686 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28687 - pmd = one_md_table_init(pgd);
28688 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28689 + pud = pud_offset(pgd, 0);
28690 + pmd = pmd_offset(pud, 0);
28691 +
28692 +#ifdef CONFIG_X86_PAE
28693 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28694 +#endif
28695
28696 if (pfn >= end_pfn)
28697 continue;
28698 @@ -293,14 +299,13 @@ repeat:
28699 #endif
28700 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28701 pmd++, pmd_idx++) {
28702 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28703 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28704
28705 /*
28706 * Map with big pages if possible, otherwise
28707 * create normal page tables:
28708 */
28709 if (use_pse) {
28710 - unsigned int addr2;
28711 pgprot_t prot = PAGE_KERNEL_LARGE;
28712 /*
28713 * first pass will use the same initial
28714 @@ -310,11 +315,7 @@ repeat:
28715 __pgprot(PTE_IDENT_ATTR |
28716 _PAGE_PSE);
28717
28718 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28719 - PAGE_OFFSET + PAGE_SIZE-1;
28720 -
28721 - if (is_kernel_text(addr) ||
28722 - is_kernel_text(addr2))
28723 + if (is_kernel_text(address, address + PMD_SIZE))
28724 prot = PAGE_KERNEL_LARGE_EXEC;
28725
28726 pages_2m++;
28727 @@ -331,7 +332,7 @@ repeat:
28728 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28729 pte += pte_ofs;
28730 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28731 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28732 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28733 pgprot_t prot = PAGE_KERNEL;
28734 /*
28735 * first pass will use the same initial
28736 @@ -339,7 +340,7 @@ repeat:
28737 */
28738 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28739
28740 - if (is_kernel_text(addr))
28741 + if (is_kernel_text(address, address + PAGE_SIZE))
28742 prot = PAGE_KERNEL_EXEC;
28743
28744 pages_4k++;
28745 @@ -465,7 +466,7 @@ void __init native_pagetable_init(void)
28746
28747 pud = pud_offset(pgd, va);
28748 pmd = pmd_offset(pud, va);
28749 - if (!pmd_present(*pmd))
28750 + if (!pmd_present(*pmd) || pmd_huge(*pmd))
28751 break;
28752
28753 pte = pte_offset_kernel(pmd, va);
28754 @@ -514,12 +515,10 @@ void __init early_ioremap_page_table_range_init(void)
28755
28756 static void __init pagetable_init(void)
28757 {
28758 - pgd_t *pgd_base = swapper_pg_dir;
28759 -
28760 - permanent_kmaps_init(pgd_base);
28761 + permanent_kmaps_init(swapper_pg_dir);
28762 }
28763
28764 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28765 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28766 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28767
28768 /* user-defined highmem size */
28769 @@ -728,6 +727,12 @@ void __init mem_init(void)
28770
28771 pci_iommu_alloc();
28772
28773 +#ifdef CONFIG_PAX_PER_CPU_PGD
28774 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28775 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28776 + KERNEL_PGD_PTRS);
28777 +#endif
28778 +
28779 #ifdef CONFIG_FLATMEM
28780 BUG_ON(!mem_map);
28781 #endif
28782 @@ -754,7 +759,7 @@ void __init mem_init(void)
28783 reservedpages++;
28784
28785 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28786 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28787 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28788 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28789
28790 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28791 @@ -795,10 +800,10 @@ void __init mem_init(void)
28792 ((unsigned long)&__init_end -
28793 (unsigned long)&__init_begin) >> 10,
28794
28795 - (unsigned long)&_etext, (unsigned long)&_edata,
28796 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28797 + (unsigned long)&_sdata, (unsigned long)&_edata,
28798 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28799
28800 - (unsigned long)&_text, (unsigned long)&_etext,
28801 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28802 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28803
28804 /*
28805 @@ -876,6 +881,7 @@ void set_kernel_text_rw(void)
28806 if (!kernel_set_to_readonly)
28807 return;
28808
28809 + start = ktla_ktva(start);
28810 pr_debug("Set kernel text: %lx - %lx for read write\n",
28811 start, start+size);
28812
28813 @@ -890,6 +896,7 @@ void set_kernel_text_ro(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 only\n",
28819 start, start+size);
28820
28821 @@ -918,6 +925,7 @@ void mark_rodata_ro(void)
28822 unsigned long start = PFN_ALIGN(_text);
28823 unsigned long size = PFN_ALIGN(_etext) - start;
28824
28825 + start = ktla_ktva(start);
28826 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28827 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28828 size >> 10);
28829 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28830 index 75c9a6a..498d677 100644
28831 --- a/arch/x86/mm/init_64.c
28832 +++ b/arch/x86/mm/init_64.c
28833 @@ -74,7 +74,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28834 * around without checking the pgd every time.
28835 */
28836
28837 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28838 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28839 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28840
28841 int force_personality32;
28842 @@ -107,12 +107,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28843
28844 for (address = start; address <= end; address += PGDIR_SIZE) {
28845 const pgd_t *pgd_ref = pgd_offset_k(address);
28846 +
28847 +#ifdef CONFIG_PAX_PER_CPU_PGD
28848 + unsigned long cpu;
28849 +#else
28850 struct page *page;
28851 +#endif
28852
28853 if (pgd_none(*pgd_ref))
28854 continue;
28855
28856 spin_lock(&pgd_lock);
28857 +
28858 +#ifdef CONFIG_PAX_PER_CPU_PGD
28859 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28860 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28861 +#else
28862 list_for_each_entry(page, &pgd_list, lru) {
28863 pgd_t *pgd;
28864 spinlock_t *pgt_lock;
28865 @@ -121,6 +131,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28866 /* the pgt_lock only for Xen */
28867 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28868 spin_lock(pgt_lock);
28869 +#endif
28870
28871 if (pgd_none(*pgd))
28872 set_pgd(pgd, *pgd_ref);
28873 @@ -128,7 +139,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28874 BUG_ON(pgd_page_vaddr(*pgd)
28875 != pgd_page_vaddr(*pgd_ref));
28876
28877 +#ifndef CONFIG_PAX_PER_CPU_PGD
28878 spin_unlock(pgt_lock);
28879 +#endif
28880 +
28881 }
28882 spin_unlock(&pgd_lock);
28883 }
28884 @@ -161,7 +175,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28885 {
28886 if (pgd_none(*pgd)) {
28887 pud_t *pud = (pud_t *)spp_getpage();
28888 - pgd_populate(&init_mm, pgd, pud);
28889 + pgd_populate_kernel(&init_mm, pgd, pud);
28890 if (pud != pud_offset(pgd, 0))
28891 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28892 pud, pud_offset(pgd, 0));
28893 @@ -173,7 +187,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28894 {
28895 if (pud_none(*pud)) {
28896 pmd_t *pmd = (pmd_t *) spp_getpage();
28897 - pud_populate(&init_mm, pud, pmd);
28898 + pud_populate_kernel(&init_mm, pud, pmd);
28899 if (pmd != pmd_offset(pud, 0))
28900 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28901 pmd, pmd_offset(pud, 0));
28902 @@ -202,7 +216,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28903 pmd = fill_pmd(pud, vaddr);
28904 pte = fill_pte(pmd, vaddr);
28905
28906 + pax_open_kernel();
28907 set_pte(pte, new_pte);
28908 + pax_close_kernel();
28909
28910 /*
28911 * It's enough to flush this one mapping.
28912 @@ -261,14 +277,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28913 pgd = pgd_offset_k((unsigned long)__va(phys));
28914 if (pgd_none(*pgd)) {
28915 pud = (pud_t *) spp_getpage();
28916 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28917 - _PAGE_USER));
28918 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28919 }
28920 pud = pud_offset(pgd, (unsigned long)__va(phys));
28921 if (pud_none(*pud)) {
28922 pmd = (pmd_t *) spp_getpage();
28923 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28924 - _PAGE_USER));
28925 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28926 }
28927 pmd = pmd_offset(pud, phys);
28928 BUG_ON(!pmd_none(*pmd));
28929 @@ -329,7 +343,7 @@ static __ref void *alloc_low_page(unsigned long *phys)
28930 if (pfn >= pgt_buf_top)
28931 panic("alloc_low_page: ran out of memory");
28932
28933 - adr = early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28934 + adr = (void __force_kernel *)early_memremap(pfn * PAGE_SIZE, PAGE_SIZE);
28935 clear_page(adr);
28936 *phys = pfn * PAGE_SIZE;
28937 return adr;
28938 @@ -345,7 +359,7 @@ static __ref void *map_low_page(void *virt)
28939
28940 phys = __pa(virt);
28941 left = phys & (PAGE_SIZE - 1);
28942 - adr = early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28943 + adr = (void __force_kernel *)early_memremap(phys & PAGE_MASK, PAGE_SIZE);
28944 adr = (void *)(((unsigned long)adr) | left);
28945
28946 return adr;
28947 @@ -553,7 +567,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28948 unmap_low_page(pmd);
28949
28950 spin_lock(&init_mm.page_table_lock);
28951 - pud_populate(&init_mm, pud, __va(pmd_phys));
28952 + pud_populate_kernel(&init_mm, pud, __va(pmd_phys));
28953 spin_unlock(&init_mm.page_table_lock);
28954 }
28955 __flush_tlb_all();
28956 @@ -599,7 +613,7 @@ kernel_physical_mapping_init(unsigned long start,
28957 unmap_low_page(pud);
28958
28959 spin_lock(&init_mm.page_table_lock);
28960 - pgd_populate(&init_mm, pgd, __va(pud_phys));
28961 + pgd_populate_kernel(&init_mm, pgd, __va(pud_phys));
28962 spin_unlock(&init_mm.page_table_lock);
28963 pgd_changed = true;
28964 }
28965 @@ -693,6 +707,12 @@ void __init mem_init(void)
28966
28967 pci_iommu_alloc();
28968
28969 +#ifdef CONFIG_PAX_PER_CPU_PGD
28970 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28971 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28972 + KERNEL_PGD_PTRS);
28973 +#endif
28974 +
28975 /* clear_bss() already clear the empty_zero_page */
28976
28977 reservedpages = 0;
28978 @@ -856,8 +876,8 @@ int kern_addr_valid(unsigned long addr)
28979 static struct vm_area_struct gate_vma = {
28980 .vm_start = VSYSCALL_START,
28981 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28982 - .vm_page_prot = PAGE_READONLY_EXEC,
28983 - .vm_flags = VM_READ | VM_EXEC
28984 + .vm_page_prot = PAGE_READONLY,
28985 + .vm_flags = VM_READ
28986 };
28987
28988 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28989 @@ -891,7 +911,7 @@ int in_gate_area_no_mm(unsigned long addr)
28990
28991 const char *arch_vma_name(struct vm_area_struct *vma)
28992 {
28993 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28994 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28995 return "[vdso]";
28996 if (vma == &gate_vma)
28997 return "[vsyscall]";
28998 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28999 index 7b179b4..6bd17777 100644
29000 --- a/arch/x86/mm/iomap_32.c
29001 +++ b/arch/x86/mm/iomap_32.c
29002 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
29003 type = kmap_atomic_idx_push();
29004 idx = type + KM_TYPE_NR * smp_processor_id();
29005 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29006 +
29007 + pax_open_kernel();
29008 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
29009 + pax_close_kernel();
29010 +
29011 arch_flush_lazy_mmu_mode();
29012
29013 return (void *)vaddr;
29014 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
29015 index 78fe3f1..73b95e2 100644
29016 --- a/arch/x86/mm/ioremap.c
29017 +++ b/arch/x86/mm/ioremap.c
29018 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
29019 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
29020 int is_ram = page_is_ram(pfn);
29021
29022 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
29023 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
29024 return NULL;
29025 WARN_ON_ONCE(is_ram);
29026 }
29027 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
29028 *
29029 * Caller must ensure there is only one unmapping for the same pointer.
29030 */
29031 -void iounmap(volatile void __iomem *addr)
29032 +void iounmap(const volatile void __iomem *addr)
29033 {
29034 struct vm_struct *p, *o;
29035
29036 @@ -315,6 +315,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29037
29038 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
29039 if (page_is_ram(start >> PAGE_SHIFT))
29040 +#ifdef CONFIG_HIGHMEM
29041 + if ((start >> PAGE_SHIFT) < max_low_pfn)
29042 +#endif
29043 return __va(phys);
29044
29045 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
29046 @@ -327,6 +330,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
29047 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
29048 {
29049 if (page_is_ram(phys >> PAGE_SHIFT))
29050 +#ifdef CONFIG_HIGHMEM
29051 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
29052 +#endif
29053 return;
29054
29055 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
29056 @@ -344,7 +350,7 @@ static int __init early_ioremap_debug_setup(char *str)
29057 early_param("early_ioremap_debug", early_ioremap_debug_setup);
29058
29059 static __initdata int after_paging_init;
29060 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
29061 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
29062
29063 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
29064 {
29065 @@ -381,8 +387,7 @@ void __init early_ioremap_init(void)
29066 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
29067
29068 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
29069 - memset(bm_pte, 0, sizeof(bm_pte));
29070 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
29071 + pmd_populate_user(&init_mm, pmd, bm_pte);
29072
29073 /*
29074 * The boot-ioremap range spans multiple pmds, for which
29075 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
29076 index d87dd6d..bf3fa66 100644
29077 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
29078 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
29079 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
29080 * memory (e.g. tracked pages)? For now, we need this to avoid
29081 * invoking kmemcheck for PnP BIOS calls.
29082 */
29083 - if (regs->flags & X86_VM_MASK)
29084 + if (v8086_mode(regs))
29085 return false;
29086 - if (regs->cs != __KERNEL_CS)
29087 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
29088 return false;
29089
29090 pte = kmemcheck_pte_lookup(address);
29091 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
29092 index 845df68..1d8d29f 100644
29093 --- a/arch/x86/mm/mmap.c
29094 +++ b/arch/x86/mm/mmap.c
29095 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
29096 * Leave an at least ~128 MB hole with possible stack randomization.
29097 */
29098 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
29099 -#define MAX_GAP (TASK_SIZE/6*5)
29100 +#define MAX_GAP (pax_task_size/6*5)
29101
29102 static int mmap_is_legacy(void)
29103 {
29104 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
29105 return rnd << PAGE_SHIFT;
29106 }
29107
29108 -static unsigned long mmap_base(void)
29109 +static unsigned long mmap_base(struct mm_struct *mm)
29110 {
29111 unsigned long gap = rlimit(RLIMIT_STACK);
29112 + unsigned long pax_task_size = TASK_SIZE;
29113 +
29114 +#ifdef CONFIG_PAX_SEGMEXEC
29115 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29116 + pax_task_size = SEGMEXEC_TASK_SIZE;
29117 +#endif
29118
29119 if (gap < MIN_GAP)
29120 gap = MIN_GAP;
29121 else if (gap > MAX_GAP)
29122 gap = MAX_GAP;
29123
29124 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
29125 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
29126 }
29127
29128 /*
29129 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
29130 * does, but not when emulating X86_32
29131 */
29132 -static unsigned long mmap_legacy_base(void)
29133 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
29134 {
29135 - if (mmap_is_ia32())
29136 + if (mmap_is_ia32()) {
29137 +
29138 +#ifdef CONFIG_PAX_SEGMEXEC
29139 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29140 + return SEGMEXEC_TASK_UNMAPPED_BASE;
29141 + else
29142 +#endif
29143 +
29144 return TASK_UNMAPPED_BASE;
29145 - else
29146 + } else
29147 return TASK_UNMAPPED_BASE + mmap_rnd();
29148 }
29149
29150 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
29151 void arch_pick_mmap_layout(struct mm_struct *mm)
29152 {
29153 if (mmap_is_legacy()) {
29154 - mm->mmap_base = mmap_legacy_base();
29155 + mm->mmap_base = mmap_legacy_base(mm);
29156 +
29157 +#ifdef CONFIG_PAX_RANDMMAP
29158 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29159 + mm->mmap_base += mm->delta_mmap;
29160 +#endif
29161 +
29162 mm->get_unmapped_area = arch_get_unmapped_area;
29163 mm->unmap_area = arch_unmap_area;
29164 } else {
29165 - mm->mmap_base = mmap_base();
29166 + mm->mmap_base = mmap_base(mm);
29167 +
29168 +#ifdef CONFIG_PAX_RANDMMAP
29169 + if (mm->pax_flags & MF_PAX_RANDMMAP)
29170 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
29171 +#endif
29172 +
29173 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
29174 mm->unmap_area = arch_unmap_area_topdown;
29175 }
29176 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
29177 index dc0b727..f612039 100644
29178 --- a/arch/x86/mm/mmio-mod.c
29179 +++ b/arch/x86/mm/mmio-mod.c
29180 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
29181 break;
29182 default:
29183 {
29184 - unsigned char *ip = (unsigned char *)instptr;
29185 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
29186 my_trace->opcode = MMIO_UNKNOWN_OP;
29187 my_trace->width = 0;
29188 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
29189 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
29190 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29191 void __iomem *addr)
29192 {
29193 - static atomic_t next_id;
29194 + static atomic_unchecked_t next_id;
29195 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
29196 /* These are page-unaligned. */
29197 struct mmiotrace_map map = {
29198 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
29199 .private = trace
29200 },
29201 .phys = offset,
29202 - .id = atomic_inc_return(&next_id)
29203 + .id = atomic_inc_return_unchecked(&next_id)
29204 };
29205 map.map_id = trace->id;
29206
29207 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
29208 ioremap_trace_core(offset, size, addr);
29209 }
29210
29211 -static void iounmap_trace_core(volatile void __iomem *addr)
29212 +static void iounmap_trace_core(const volatile void __iomem *addr)
29213 {
29214 struct mmiotrace_map map = {
29215 .phys = 0,
29216 @@ -328,7 +328,7 @@ not_enabled:
29217 }
29218 }
29219
29220 -void mmiotrace_iounmap(volatile void __iomem *addr)
29221 +void mmiotrace_iounmap(const volatile void __iomem *addr)
29222 {
29223 might_sleep();
29224 if (is_enabled()) /* recheck and proper locking in *_core() */
29225 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
29226 index 8504f36..5fc68f2 100644
29227 --- a/arch/x86/mm/numa.c
29228 +++ b/arch/x86/mm/numa.c
29229 @@ -478,7 +478,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
29230 return true;
29231 }
29232
29233 -static int __init numa_register_memblks(struct numa_meminfo *mi)
29234 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
29235 {
29236 unsigned long uninitialized_var(pfn_align);
29237 int i, nid;
29238 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
29239 index b008656..773eac2 100644
29240 --- a/arch/x86/mm/pageattr-test.c
29241 +++ b/arch/x86/mm/pageattr-test.c
29242 @@ -36,7 +36,7 @@ enum {
29243
29244 static int pte_testbit(pte_t pte)
29245 {
29246 - return pte_flags(pte) & _PAGE_UNUSED1;
29247 + return pte_flags(pte) & _PAGE_CPA_TEST;
29248 }
29249
29250 struct split_state {
29251 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
29252 index a718e0d..77419bc 100644
29253 --- a/arch/x86/mm/pageattr.c
29254 +++ b/arch/x86/mm/pageattr.c
29255 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29256 */
29257 #ifdef CONFIG_PCI_BIOS
29258 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
29259 - pgprot_val(forbidden) |= _PAGE_NX;
29260 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29261 #endif
29262
29263 /*
29264 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29265 * Does not cover __inittext since that is gone later on. On
29266 * 64bit we do not enforce !NX on the low mapping
29267 */
29268 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
29269 - pgprot_val(forbidden) |= _PAGE_NX;
29270 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
29271 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29272
29273 +#ifdef CONFIG_DEBUG_RODATA
29274 /*
29275 * The .rodata section needs to be read-only. Using the pfn
29276 * catches all aliases.
29277 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29278 if (within(pfn, __pa((unsigned long)__start_rodata) >> PAGE_SHIFT,
29279 __pa((unsigned long)__end_rodata) >> PAGE_SHIFT))
29280 pgprot_val(forbidden) |= _PAGE_RW;
29281 +#endif
29282
29283 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
29284 /*
29285 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
29286 }
29287 #endif
29288
29289 +#ifdef CONFIG_PAX_KERNEXEC
29290 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
29291 + pgprot_val(forbidden) |= _PAGE_RW;
29292 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
29293 + }
29294 +#endif
29295 +
29296 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
29297
29298 return prot;
29299 @@ -369,23 +378,37 @@ EXPORT_SYMBOL_GPL(lookup_address);
29300 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
29301 {
29302 /* change init_mm */
29303 + pax_open_kernel();
29304 set_pte_atomic(kpte, pte);
29305 +
29306 #ifdef CONFIG_X86_32
29307 if (!SHARED_KERNEL_PMD) {
29308 +
29309 +#ifdef CONFIG_PAX_PER_CPU_PGD
29310 + unsigned long cpu;
29311 +#else
29312 struct page *page;
29313 +#endif
29314
29315 +#ifdef CONFIG_PAX_PER_CPU_PGD
29316 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29317 + pgd_t *pgd = get_cpu_pgd(cpu);
29318 +#else
29319 list_for_each_entry(page, &pgd_list, lru) {
29320 - pgd_t *pgd;
29321 + pgd_t *pgd = (pgd_t *)page_address(page);
29322 +#endif
29323 +
29324 pud_t *pud;
29325 pmd_t *pmd;
29326
29327 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
29328 + pgd += pgd_index(address);
29329 pud = pud_offset(pgd, address);
29330 pmd = pmd_offset(pud, address);
29331 set_pte_atomic((pte_t *)pmd, pte);
29332 }
29333 }
29334 #endif
29335 + pax_close_kernel();
29336 }
29337
29338 static int
29339 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
29340 index 0eb572e..92f5c1e 100644
29341 --- a/arch/x86/mm/pat.c
29342 +++ b/arch/x86/mm/pat.c
29343 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
29344
29345 if (!entry) {
29346 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
29347 - current->comm, current->pid, start, end - 1);
29348 + current->comm, task_pid_nr(current), start, end - 1);
29349 return -EINVAL;
29350 }
29351
29352 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
29353
29354 while (cursor < to) {
29355 if (!devmem_is_allowed(pfn)) {
29356 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29357 - current->comm, from, to - 1);
29358 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29359 + current->comm, from, to - 1, cursor);
29360 return 0;
29361 }
29362 cursor += PAGE_SIZE;
29363 @@ -570,7 +570,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29364 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29365 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29366 "for [mem %#010Lx-%#010Lx]\n",
29367 - current->comm, current->pid,
29368 + current->comm, task_pid_nr(current),
29369 cattr_name(flags),
29370 base, (unsigned long long)(base + size-1));
29371 return -EINVAL;
29372 @@ -605,7 +605,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29373 flags = lookup_memtype(paddr);
29374 if (want_flags != flags) {
29375 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29376 - current->comm, current->pid,
29377 + current->comm, task_pid_nr(current),
29378 cattr_name(want_flags),
29379 (unsigned long long)paddr,
29380 (unsigned long long)(paddr + size - 1),
29381 @@ -627,7 +627,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29382 free_memtype(paddr, paddr + size);
29383 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29384 " for [mem %#010Lx-%#010Lx], got %s\n",
29385 - current->comm, current->pid,
29386 + current->comm, task_pid_nr(current),
29387 cattr_name(want_flags),
29388 (unsigned long long)paddr,
29389 (unsigned long long)(paddr + size - 1),
29390 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29391 index 9f0614d..92ae64a 100644
29392 --- a/arch/x86/mm/pf_in.c
29393 +++ b/arch/x86/mm/pf_in.c
29394 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29395 int i;
29396 enum reason_type rv = OTHERS;
29397
29398 - p = (unsigned char *)ins_addr;
29399 + p = (unsigned char *)ktla_ktva(ins_addr);
29400 p += skip_prefix(p, &prf);
29401 p += get_opcode(p, &opcode);
29402
29403 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29404 struct prefix_bits prf;
29405 int i;
29406
29407 - p = (unsigned char *)ins_addr;
29408 + p = (unsigned char *)ktla_ktva(ins_addr);
29409 p += skip_prefix(p, &prf);
29410 p += get_opcode(p, &opcode);
29411
29412 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29413 struct prefix_bits prf;
29414 int i;
29415
29416 - p = (unsigned char *)ins_addr;
29417 + p = (unsigned char *)ktla_ktva(ins_addr);
29418 p += skip_prefix(p, &prf);
29419 p += get_opcode(p, &opcode);
29420
29421 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29422 struct prefix_bits prf;
29423 int i;
29424
29425 - p = (unsigned char *)ins_addr;
29426 + p = (unsigned char *)ktla_ktva(ins_addr);
29427 p += skip_prefix(p, &prf);
29428 p += get_opcode(p, &opcode);
29429 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29430 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29431 struct prefix_bits prf;
29432 int i;
29433
29434 - p = (unsigned char *)ins_addr;
29435 + p = (unsigned char *)ktla_ktva(ins_addr);
29436 p += skip_prefix(p, &prf);
29437 p += get_opcode(p, &opcode);
29438 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29439 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29440 index e27fbf8..213e72b 100644
29441 --- a/arch/x86/mm/pgtable.c
29442 +++ b/arch/x86/mm/pgtable.c
29443 @@ -58,6 +58,13 @@ void ___pte_free_tlb(struct mmu_gather *tlb, struct page *pte)
29444 void ___pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd)
29445 {
29446 paravirt_release_pmd(__pa(pmd) >> PAGE_SHIFT);
29447 + /*
29448 + * NOTE! For PAE, any changes to the top page-directory-pointer-table
29449 + * entries need a full cr3 reload to flush.
29450 + */
29451 +#ifdef CONFIG_X86_PAE
29452 + tlb->need_flush_all = 1;
29453 +#endif
29454 tlb_remove_page(tlb, virt_to_page(pmd));
29455 }
29456
29457 @@ -84,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29458 list_del(&page->lru);
29459 }
29460
29461 -#define UNSHARED_PTRS_PER_PGD \
29462 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29463 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29464 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29465
29466 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29467 +{
29468 + unsigned int count = USER_PGD_PTRS;
29469
29470 + while (count--)
29471 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29472 +}
29473 +#endif
29474 +
29475 +#ifdef CONFIG_PAX_PER_CPU_PGD
29476 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29477 +{
29478 + unsigned int count = USER_PGD_PTRS;
29479 +
29480 + while (count--) {
29481 + pgd_t pgd;
29482 +
29483 +#ifdef CONFIG_X86_64
29484 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29485 +#else
29486 + pgd = *src++;
29487 +#endif
29488 +
29489 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29490 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29491 +#endif
29492 +
29493 + *dst++ = pgd;
29494 + }
29495 +
29496 +}
29497 +#endif
29498 +
29499 +#ifdef CONFIG_X86_64
29500 +#define pxd_t pud_t
29501 +#define pyd_t pgd_t
29502 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29503 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29504 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29505 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29506 +#define PYD_SIZE PGDIR_SIZE
29507 +#else
29508 +#define pxd_t pmd_t
29509 +#define pyd_t pud_t
29510 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29511 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29512 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29513 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29514 +#define PYD_SIZE PUD_SIZE
29515 +#endif
29516 +
29517 +#ifdef CONFIG_PAX_PER_CPU_PGD
29518 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29519 +static inline void pgd_dtor(pgd_t *pgd) {}
29520 +#else
29521 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29522 {
29523 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29524 @@ -128,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29525 pgd_list_del(pgd);
29526 spin_unlock(&pgd_lock);
29527 }
29528 +#endif
29529
29530 /*
29531 * List of all pgd's needed for non-PAE so it can invalidate entries
29532 @@ -140,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29533 * -- nyc
29534 */
29535
29536 -#ifdef CONFIG_X86_PAE
29537 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29538 /*
29539 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29540 * updating the top-level pagetable entries to guarantee the
29541 @@ -152,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29542 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29543 * and initialize the kernel pmds here.
29544 */
29545 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29546 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29547
29548 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29549 {
29550 @@ -170,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29551 */
29552 flush_tlb_mm(mm);
29553 }
29554 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29555 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29556 #else /* !CONFIG_X86_PAE */
29557
29558 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29559 -#define PREALLOCATED_PMDS 0
29560 +#define PREALLOCATED_PXDS 0
29561
29562 #endif /* CONFIG_X86_PAE */
29563
29564 -static void free_pmds(pmd_t *pmds[])
29565 +static void free_pxds(pxd_t *pxds[])
29566 {
29567 int i;
29568
29569 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29570 - if (pmds[i])
29571 - free_page((unsigned long)pmds[i]);
29572 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29573 + if (pxds[i])
29574 + free_page((unsigned long)pxds[i]);
29575 }
29576
29577 -static int preallocate_pmds(pmd_t *pmds[])
29578 +static int preallocate_pxds(pxd_t *pxds[])
29579 {
29580 int i;
29581 bool failed = false;
29582
29583 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29584 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29585 - if (pmd == NULL)
29586 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29587 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29588 + if (pxd == NULL)
29589 failed = true;
29590 - pmds[i] = pmd;
29591 + pxds[i] = pxd;
29592 }
29593
29594 if (failed) {
29595 - free_pmds(pmds);
29596 + free_pxds(pxds);
29597 return -ENOMEM;
29598 }
29599
29600 @@ -212,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29601 * preallocate which never got a corresponding vma will need to be
29602 * freed manually.
29603 */
29604 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29605 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29606 {
29607 int i;
29608
29609 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29610 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29611 pgd_t pgd = pgdp[i];
29612
29613 if (pgd_val(pgd) != 0) {
29614 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29615 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29616
29617 - pgdp[i] = native_make_pgd(0);
29618 + set_pgd(pgdp + i, native_make_pgd(0));
29619
29620 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29621 - pmd_free(mm, pmd);
29622 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29623 + pxd_free(mm, pxd);
29624 }
29625 }
29626 }
29627
29628 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29629 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29630 {
29631 - pud_t *pud;
29632 + pyd_t *pyd;
29633 unsigned long addr;
29634 int i;
29635
29636 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29637 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29638 return;
29639
29640 - pud = pud_offset(pgd, 0);
29641 +#ifdef CONFIG_X86_64
29642 + pyd = pyd_offset(mm, 0L);
29643 +#else
29644 + pyd = pyd_offset(pgd, 0L);
29645 +#endif
29646
29647 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29648 - i++, pud++, addr += PUD_SIZE) {
29649 - pmd_t *pmd = pmds[i];
29650 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29651 + i++, pyd++, addr += PYD_SIZE) {
29652 + pxd_t *pxd = pxds[i];
29653
29654 if (i >= KERNEL_PGD_BOUNDARY)
29655 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29656 - sizeof(pmd_t) * PTRS_PER_PMD);
29657 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29658 + sizeof(pxd_t) * PTRS_PER_PMD);
29659
29660 - pud_populate(mm, pud, pmd);
29661 + pyd_populate(mm, pyd, pxd);
29662 }
29663 }
29664
29665 pgd_t *pgd_alloc(struct mm_struct *mm)
29666 {
29667 pgd_t *pgd;
29668 - pmd_t *pmds[PREALLOCATED_PMDS];
29669 + pxd_t *pxds[PREALLOCATED_PXDS];
29670
29671 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29672
29673 @@ -265,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29674
29675 mm->pgd = pgd;
29676
29677 - if (preallocate_pmds(pmds) != 0)
29678 + if (preallocate_pxds(pxds) != 0)
29679 goto out_free_pgd;
29680
29681 if (paravirt_pgd_alloc(mm) != 0)
29682 - goto out_free_pmds;
29683 + goto out_free_pxds;
29684
29685 /*
29686 * Make sure that pre-populating the pmds is atomic with
29687 @@ -279,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29688 spin_lock(&pgd_lock);
29689
29690 pgd_ctor(mm, pgd);
29691 - pgd_prepopulate_pmd(mm, pgd, pmds);
29692 + pgd_prepopulate_pxd(mm, pgd, pxds);
29693
29694 spin_unlock(&pgd_lock);
29695
29696 return pgd;
29697
29698 -out_free_pmds:
29699 - free_pmds(pmds);
29700 +out_free_pxds:
29701 + free_pxds(pxds);
29702 out_free_pgd:
29703 free_page((unsigned long)pgd);
29704 out:
29705 @@ -295,7 +363,7 @@ out:
29706
29707 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29708 {
29709 - pgd_mop_up_pmds(mm, pgd);
29710 + pgd_mop_up_pxds(mm, pgd);
29711 pgd_dtor(pgd);
29712 paravirt_pgd_free(mm, pgd);
29713 free_page((unsigned long)pgd);
29714 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29715 index a69bcb8..19068ab 100644
29716 --- a/arch/x86/mm/pgtable_32.c
29717 +++ b/arch/x86/mm/pgtable_32.c
29718 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29719 return;
29720 }
29721 pte = pte_offset_kernel(pmd, vaddr);
29722 +
29723 + pax_open_kernel();
29724 if (pte_val(pteval))
29725 set_pte_at(&init_mm, vaddr, pte, pteval);
29726 else
29727 pte_clear(&init_mm, vaddr, pte);
29728 + pax_close_kernel();
29729
29730 /*
29731 * It's enough to flush this one mapping.
29732 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29733 index d2e2735..5c6586f 100644
29734 --- a/arch/x86/mm/physaddr.c
29735 +++ b/arch/x86/mm/physaddr.c
29736 @@ -8,7 +8,7 @@
29737
29738 #ifdef CONFIG_X86_64
29739
29740 -unsigned long __phys_addr(unsigned long x)
29741 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29742 {
29743 if (x >= __START_KERNEL_map) {
29744 x -= __START_KERNEL_map;
29745 @@ -45,7 +45,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29746 #else
29747
29748 #ifdef CONFIG_DEBUG_VIRTUAL
29749 -unsigned long __phys_addr(unsigned long x)
29750 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29751 {
29752 /* VMALLOC_* aren't constants */
29753 VIRTUAL_BUG_ON(x < PAGE_OFFSET);
29754 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29755 index 410531d..0f16030 100644
29756 --- a/arch/x86/mm/setup_nx.c
29757 +++ b/arch/x86/mm/setup_nx.c
29758 @@ -5,8 +5,10 @@
29759 #include <asm/pgtable.h>
29760 #include <asm/proto.h>
29761
29762 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29763 static int disable_nx __cpuinitdata;
29764
29765 +#ifndef CONFIG_PAX_PAGEEXEC
29766 /*
29767 * noexec = on|off
29768 *
29769 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29770 return 0;
29771 }
29772 early_param("noexec", noexec_setup);
29773 +#endif
29774 +
29775 +#endif
29776
29777 void __cpuinit x86_configure_nx(void)
29778 {
29779 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29780 if (cpu_has_nx && !disable_nx)
29781 __supported_pte_mask |= _PAGE_NX;
29782 else
29783 +#endif
29784 __supported_pte_mask &= ~_PAGE_NX;
29785 }
29786
29787 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29788 index 13a6b29..c2fff23 100644
29789 --- a/arch/x86/mm/tlb.c
29790 +++ b/arch/x86/mm/tlb.c
29791 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29792 BUG();
29793 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29794 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29795 +
29796 +#ifndef CONFIG_PAX_PER_CPU_PGD
29797 load_cr3(swapper_pg_dir);
29798 +#endif
29799 +
29800 }
29801 }
29802 EXPORT_SYMBOL_GPL(leave_mm);
29803 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29804 index 877b9a1..a8ecf42 100644
29805 --- a/arch/x86/net/bpf_jit.S
29806 +++ b/arch/x86/net/bpf_jit.S
29807 @@ -9,6 +9,7 @@
29808 */
29809 #include <linux/linkage.h>
29810 #include <asm/dwarf2.h>
29811 +#include <asm/alternative-asm.h>
29812
29813 /*
29814 * Calling convention :
29815 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29816 jle bpf_slow_path_word
29817 mov (SKBDATA,%rsi),%eax
29818 bswap %eax /* ntohl() */
29819 + pax_force_retaddr
29820 ret
29821
29822 sk_load_half:
29823 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29824 jle bpf_slow_path_half
29825 movzwl (SKBDATA,%rsi),%eax
29826 rol $8,%ax # ntohs()
29827 + pax_force_retaddr
29828 ret
29829
29830 sk_load_byte:
29831 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29832 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29833 jle bpf_slow_path_byte
29834 movzbl (SKBDATA,%rsi),%eax
29835 + pax_force_retaddr
29836 ret
29837
29838 /**
29839 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29840 movzbl (SKBDATA,%rsi),%ebx
29841 and $15,%bl
29842 shl $2,%bl
29843 + pax_force_retaddr
29844 ret
29845
29846 /* rsi contains offset and can be scratched */
29847 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29848 js bpf_error
29849 mov -12(%rbp),%eax
29850 bswap %eax
29851 + pax_force_retaddr
29852 ret
29853
29854 bpf_slow_path_half:
29855 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29856 mov -12(%rbp),%ax
29857 rol $8,%ax
29858 movzwl %ax,%eax
29859 + pax_force_retaddr
29860 ret
29861
29862 bpf_slow_path_byte:
29863 bpf_slow_path_common(1)
29864 js bpf_error
29865 movzbl -12(%rbp),%eax
29866 + pax_force_retaddr
29867 ret
29868
29869 bpf_slow_path_byte_msh:
29870 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29871 and $15,%al
29872 shl $2,%al
29873 xchg %eax,%ebx
29874 + pax_force_retaddr
29875 ret
29876
29877 #define sk_negative_common(SIZE) \
29878 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29879 sk_negative_common(4)
29880 mov (%rax), %eax
29881 bswap %eax
29882 + pax_force_retaddr
29883 ret
29884
29885 bpf_slow_path_half_neg:
29886 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29887 mov (%rax),%ax
29888 rol $8,%ax
29889 movzwl %ax,%eax
29890 + pax_force_retaddr
29891 ret
29892
29893 bpf_slow_path_byte_neg:
29894 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29895 .globl sk_load_byte_negative_offset
29896 sk_negative_common(1)
29897 movzbl (%rax), %eax
29898 + pax_force_retaddr
29899 ret
29900
29901 bpf_slow_path_byte_msh_neg:
29902 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29903 and $15,%al
29904 shl $2,%al
29905 xchg %eax,%ebx
29906 + pax_force_retaddr
29907 ret
29908
29909 bpf_error:
29910 @@ -197,4 +210,5 @@ bpf_error:
29911 xor %eax,%eax
29912 mov -8(%rbp),%rbx
29913 leaveq
29914 + pax_force_retaddr
29915 ret
29916 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29917 index d11a470..3f9adff3 100644
29918 --- a/arch/x86/net/bpf_jit_comp.c
29919 +++ b/arch/x86/net/bpf_jit_comp.c
29920 @@ -12,6 +12,7 @@
29921 #include <linux/netdevice.h>
29922 #include <linux/filter.h>
29923 #include <linux/if_vlan.h>
29924 +#include <linux/random.h>
29925
29926 /*
29927 * Conventions :
29928 @@ -49,13 +50,87 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29929 return ptr + len;
29930 }
29931
29932 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29933 +#define MAX_INSTR_CODE_SIZE 96
29934 +#else
29935 +#define MAX_INSTR_CODE_SIZE 64
29936 +#endif
29937 +
29938 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29939
29940 #define EMIT1(b1) EMIT(b1, 1)
29941 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29942 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29943 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29944 +
29945 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29946 +/* original constant will appear in ecx */
29947 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29948 +do { \
29949 + /* mov ecx, randkey */ \
29950 + EMIT1(0xb9); \
29951 + EMIT(_key, 4); \
29952 + /* xor ecx, randkey ^ off */ \
29953 + EMIT2(0x81, 0xf1); \
29954 + EMIT((_key) ^ (_off), 4); \
29955 +} while (0)
29956 +
29957 +#define EMIT1_off32(b1, _off) \
29958 +do { \
29959 + switch (b1) { \
29960 + case 0x05: /* add eax, imm32 */ \
29961 + case 0x2d: /* sub eax, imm32 */ \
29962 + case 0x25: /* and eax, imm32 */ \
29963 + case 0x0d: /* or eax, imm32 */ \
29964 + case 0xb8: /* mov eax, imm32 */ \
29965 + case 0x3d: /* cmp eax, imm32 */ \
29966 + case 0xa9: /* test eax, imm32 */ \
29967 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29968 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29969 + break; \
29970 + case 0xbb: /* mov ebx, imm32 */ \
29971 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29972 + /* mov ebx, ecx */ \
29973 + EMIT2(0x89, 0xcb); \
29974 + break; \
29975 + case 0xbe: /* mov esi, imm32 */ \
29976 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29977 + /* mov esi, ecx */ \
29978 + EMIT2(0x89, 0xce); \
29979 + break; \
29980 + case 0xe9: /* jmp rel imm32 */ \
29981 + EMIT1(b1); \
29982 + EMIT(_off, 4); \
29983 + /* prevent fall-through, we're not called if off = 0 */ \
29984 + EMIT(0xcccccccc, 4); \
29985 + EMIT(0xcccccccc, 4); \
29986 + break; \
29987 + default: \
29988 + EMIT1(b1); \
29989 + EMIT(_off, 4); \
29990 + } \
29991 +} while (0)
29992 +
29993 +#define EMIT2_off32(b1, b2, _off) \
29994 +do { \
29995 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29996 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29997 + EMIT(randkey, 4); \
29998 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29999 + EMIT((_off) - randkey, 4); \
30000 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
30001 + DILUTE_CONST_SEQUENCE(_off, randkey); \
30002 + /* imul eax, ecx */ \
30003 + EMIT3(0x0f, 0xaf, 0xc1); \
30004 + } else { \
30005 + EMIT2(b1, b2); \
30006 + EMIT(_off, 4); \
30007 + } \
30008 +} while (0)
30009 +#else
30010 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
30011 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
30012 +#endif
30013
30014 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
30015 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
30016 @@ -90,6 +165,24 @@ do { \
30017 #define X86_JBE 0x76
30018 #define X86_JA 0x77
30019
30020 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30021 +#define APPEND_FLOW_VERIFY() \
30022 +do { \
30023 + /* mov ecx, randkey */ \
30024 + EMIT1(0xb9); \
30025 + EMIT(randkey, 4); \
30026 + /* cmp ecx, randkey */ \
30027 + EMIT2(0x81, 0xf9); \
30028 + EMIT(randkey, 4); \
30029 + /* jz after 8 int 3s */ \
30030 + EMIT2(0x74, 0x08); \
30031 + EMIT(0xcccccccc, 4); \
30032 + EMIT(0xcccccccc, 4); \
30033 +} while (0)
30034 +#else
30035 +#define APPEND_FLOW_VERIFY() do { } while (0)
30036 +#endif
30037 +
30038 #define EMIT_COND_JMP(op, offset) \
30039 do { \
30040 if (is_near(offset)) \
30041 @@ -97,6 +190,7 @@ do { \
30042 else { \
30043 EMIT2(0x0f, op + 0x10); \
30044 EMIT(offset, 4); /* jxx .+off32 */ \
30045 + APPEND_FLOW_VERIFY(); \
30046 } \
30047 } while (0)
30048
30049 @@ -121,12 +215,17 @@ static inline void bpf_flush_icache(void *start, void *end)
30050 set_fs(old_fs);
30051 }
30052
30053 +struct bpf_jit_work {
30054 + struct work_struct work;
30055 + void *image;
30056 +};
30057 +
30058 #define CHOOSE_LOAD_FUNC(K, func) \
30059 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
30060
30061 void bpf_jit_compile(struct sk_filter *fp)
30062 {
30063 - u8 temp[64];
30064 + u8 temp[MAX_INSTR_CODE_SIZE];
30065 u8 *prog;
30066 unsigned int proglen, oldproglen = 0;
30067 int ilen, i;
30068 @@ -139,6 +238,9 @@ void bpf_jit_compile(struct sk_filter *fp)
30069 unsigned int *addrs;
30070 const struct sock_filter *filter = fp->insns;
30071 int flen = fp->len;
30072 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30073 + unsigned int randkey;
30074 +#endif
30075
30076 if (!bpf_jit_enable)
30077 return;
30078 @@ -147,11 +249,19 @@ void bpf_jit_compile(struct sk_filter *fp)
30079 if (addrs == NULL)
30080 return;
30081
30082 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
30083 + if (!fp->work)
30084 + goto out;
30085 +
30086 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30087 + randkey = get_random_int();
30088 +#endif
30089 +
30090 /* Before first pass, make a rough estimation of addrs[]
30091 - * each bpf instruction is translated to less than 64 bytes
30092 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
30093 */
30094 for (proglen = 0, i = 0; i < flen; i++) {
30095 - proglen += 64;
30096 + proglen += MAX_INSTR_CODE_SIZE;
30097 addrs[i] = proglen;
30098 }
30099 cleanup_addr = proglen; /* epilogue address */
30100 @@ -261,10 +371,8 @@ void bpf_jit_compile(struct sk_filter *fp)
30101 case BPF_S_ALU_MUL_K: /* A *= K */
30102 if (is_imm8(K))
30103 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
30104 - else {
30105 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
30106 - EMIT(K, 4);
30107 - }
30108 + else
30109 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
30110 break;
30111 case BPF_S_ALU_DIV_X: /* A /= X; */
30112 seen |= SEEN_XREG;
30113 @@ -304,13 +412,23 @@ void bpf_jit_compile(struct sk_filter *fp)
30114 break;
30115 case BPF_S_ALU_MOD_K: /* A %= K; */
30116 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
30117 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30118 + DILUTE_CONST_SEQUENCE(K, randkey);
30119 +#else
30120 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
30121 +#endif
30122 EMIT2(0xf7, 0xf1); /* div %ecx */
30123 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
30124 break;
30125 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
30126 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
30127 + DILUTE_CONST_SEQUENCE(K, randkey);
30128 + // imul rax, rcx
30129 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
30130 +#else
30131 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
30132 EMIT(K, 4);
30133 +#endif
30134 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
30135 break;
30136 case BPF_S_ALU_AND_X:
30137 @@ -564,8 +682,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
30138 if (is_imm8(K)) {
30139 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
30140 } else {
30141 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
30142 - EMIT(K, 4);
30143 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
30144 }
30145 } else {
30146 EMIT2(0x89,0xde); /* mov %ebx,%esi */
30147 @@ -648,17 +765,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30148 break;
30149 default:
30150 /* hmm, too complex filter, give up with jit compiler */
30151 - goto out;
30152 + goto error;
30153 }
30154 ilen = prog - temp;
30155 if (image) {
30156 if (unlikely(proglen + ilen > oldproglen)) {
30157 pr_err("bpb_jit_compile fatal error\n");
30158 - kfree(addrs);
30159 - module_free(NULL, image);
30160 - return;
30161 + module_free_exec(NULL, image);
30162 + goto error;
30163 }
30164 + pax_open_kernel();
30165 memcpy(image + proglen, temp, ilen);
30166 + pax_close_kernel();
30167 }
30168 proglen += ilen;
30169 addrs[i] = proglen;
30170 @@ -679,11 +797,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30171 break;
30172 }
30173 if (proglen == oldproglen) {
30174 - image = module_alloc(max_t(unsigned int,
30175 - proglen,
30176 - sizeof(struct work_struct)));
30177 + image = module_alloc_exec(proglen);
30178 if (!image)
30179 - goto out;
30180 + goto error;
30181 }
30182 oldproglen = proglen;
30183 }
30184 @@ -699,7 +815,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
30185 bpf_flush_icache(image, image + proglen);
30186
30187 fp->bpf_func = (void *)image;
30188 - }
30189 + } else
30190 +error:
30191 + kfree(fp->work);
30192 +
30193 out:
30194 kfree(addrs);
30195 return;
30196 @@ -707,18 +826,20 @@ out:
30197
30198 static void jit_free_defer(struct work_struct *arg)
30199 {
30200 - module_free(NULL, arg);
30201 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
30202 + kfree(arg);
30203 }
30204
30205 /* run from softirq, we must use a work_struct to call
30206 - * module_free() from process context
30207 + * module_free_exec() from process context
30208 */
30209 void bpf_jit_free(struct sk_filter *fp)
30210 {
30211 if (fp->bpf_func != sk_run_filter) {
30212 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
30213 + struct work_struct *work = &fp->work->work;
30214
30215 INIT_WORK(work, jit_free_defer);
30216 + fp->work->image = fp->bpf_func;
30217 schedule_work(work);
30218 }
30219 }
30220 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
30221 index d6aa6e8..266395a 100644
30222 --- a/arch/x86/oprofile/backtrace.c
30223 +++ b/arch/x86/oprofile/backtrace.c
30224 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
30225 struct stack_frame_ia32 *fp;
30226 unsigned long bytes;
30227
30228 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30229 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30230 if (bytes != sizeof(bufhead))
30231 return NULL;
30232
30233 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
30234 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
30235
30236 oprofile_add_trace(bufhead[0].return_address);
30237
30238 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
30239 struct stack_frame bufhead[2];
30240 unsigned long bytes;
30241
30242 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
30243 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
30244 if (bytes != sizeof(bufhead))
30245 return NULL;
30246
30247 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
30248 {
30249 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
30250
30251 - if (!user_mode_vm(regs)) {
30252 + if (!user_mode(regs)) {
30253 unsigned long stack = kernel_stack_pointer(regs);
30254 if (depth)
30255 dump_trace(NULL, regs, (unsigned long *)stack, 0,
30256 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
30257 index 48768df..ba9143c 100644
30258 --- a/arch/x86/oprofile/nmi_int.c
30259 +++ b/arch/x86/oprofile/nmi_int.c
30260 @@ -23,6 +23,7 @@
30261 #include <asm/nmi.h>
30262 #include <asm/msr.h>
30263 #include <asm/apic.h>
30264 +#include <asm/pgtable.h>
30265
30266 #include "op_counter.h"
30267 #include "op_x86_model.h"
30268 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
30269 if (ret)
30270 return ret;
30271
30272 - if (!model->num_virt_counters)
30273 - model->num_virt_counters = model->num_counters;
30274 + if (!model->num_virt_counters) {
30275 + pax_open_kernel();
30276 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
30277 + pax_close_kernel();
30278 + }
30279
30280 mux_init(ops);
30281
30282 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
30283 index b2b9443..be58856 100644
30284 --- a/arch/x86/oprofile/op_model_amd.c
30285 +++ b/arch/x86/oprofile/op_model_amd.c
30286 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
30287 num_counters = AMD64_NUM_COUNTERS;
30288 }
30289
30290 - op_amd_spec.num_counters = num_counters;
30291 - op_amd_spec.num_controls = num_counters;
30292 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30293 + pax_open_kernel();
30294 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
30295 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
30296 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
30297 + pax_close_kernel();
30298
30299 return 0;
30300 }
30301 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
30302 index d90528e..0127e2b 100644
30303 --- a/arch/x86/oprofile/op_model_ppro.c
30304 +++ b/arch/x86/oprofile/op_model_ppro.c
30305 @@ -19,6 +19,7 @@
30306 #include <asm/msr.h>
30307 #include <asm/apic.h>
30308 #include <asm/nmi.h>
30309 +#include <asm/pgtable.h>
30310
30311 #include "op_x86_model.h"
30312 #include "op_counter.h"
30313 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
30314
30315 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
30316
30317 - op_arch_perfmon_spec.num_counters = num_counters;
30318 - op_arch_perfmon_spec.num_controls = num_counters;
30319 + pax_open_kernel();
30320 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
30321 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
30322 + pax_close_kernel();
30323 }
30324
30325 static int arch_perfmon_init(struct oprofile_operations *ignore)
30326 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
30327 index 71e8a67..6a313bb 100644
30328 --- a/arch/x86/oprofile/op_x86_model.h
30329 +++ b/arch/x86/oprofile/op_x86_model.h
30330 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
30331 void (*switch_ctrl)(struct op_x86_model_spec const *model,
30332 struct op_msrs const * const msrs);
30333 #endif
30334 -};
30335 +} __do_const;
30336
30337 struct op_counter_config;
30338
30339 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
30340 index e9e6ed5..e47ae67 100644
30341 --- a/arch/x86/pci/amd_bus.c
30342 +++ b/arch/x86/pci/amd_bus.c
30343 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
30344 return NOTIFY_OK;
30345 }
30346
30347 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
30348 +static struct notifier_block amd_cpu_notifier = {
30349 .notifier_call = amd_cpu_notify,
30350 };
30351
30352 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30353 index 372e9b8..e775a6c 100644
30354 --- a/arch/x86/pci/irq.c
30355 +++ b/arch/x86/pci/irq.c
30356 @@ -50,7 +50,7 @@ struct irq_router {
30357 struct irq_router_handler {
30358 u16 vendor;
30359 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30360 -};
30361 +} __do_const;
30362
30363 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30364 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30365 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30366 return 0;
30367 }
30368
30369 -static __initdata struct irq_router_handler pirq_routers[] = {
30370 +static __initconst const struct irq_router_handler pirq_routers[] = {
30371 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30372 { PCI_VENDOR_ID_AL, ali_router_probe },
30373 { PCI_VENDOR_ID_ITE, ite_router_probe },
30374 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30375 static void __init pirq_find_router(struct irq_router *r)
30376 {
30377 struct irq_routing_table *rt = pirq_table;
30378 - struct irq_router_handler *h;
30379 + const struct irq_router_handler *h;
30380
30381 #ifdef CONFIG_PCI_BIOS
30382 if (!rt->signature) {
30383 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30384 return 0;
30385 }
30386
30387 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30388 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30389 {
30390 .callback = fix_broken_hp_bios_irq9,
30391 .ident = "HP Pavilion N5400 Series Laptop",
30392 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30393 index 6eb18c4..20d83de 100644
30394 --- a/arch/x86/pci/mrst.c
30395 +++ b/arch/x86/pci/mrst.c
30396 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30397 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30398 pci_mmcfg_late_init();
30399 pcibios_enable_irq = mrst_pci_irq_enable;
30400 - pci_root_ops = pci_mrst_ops;
30401 + pax_open_kernel();
30402 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30403 + pax_close_kernel();
30404 pci_soc_mode = 1;
30405 /* Continue with standard init */
30406 return 1;
30407 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30408 index c77b24a..c979855 100644
30409 --- a/arch/x86/pci/pcbios.c
30410 +++ b/arch/x86/pci/pcbios.c
30411 @@ -79,7 +79,7 @@ union bios32 {
30412 static struct {
30413 unsigned long address;
30414 unsigned short segment;
30415 -} bios32_indirect = { 0, __KERNEL_CS };
30416 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30417
30418 /*
30419 * Returns the entry point for the given service, NULL on error
30420 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30421 unsigned long length; /* %ecx */
30422 unsigned long entry; /* %edx */
30423 unsigned long flags;
30424 + struct desc_struct d, *gdt;
30425
30426 local_irq_save(flags);
30427 - __asm__("lcall *(%%edi); cld"
30428 +
30429 + gdt = get_cpu_gdt_table(smp_processor_id());
30430 +
30431 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30432 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30433 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30434 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30435 +
30436 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30437 : "=a" (return_code),
30438 "=b" (address),
30439 "=c" (length),
30440 "=d" (entry)
30441 : "0" (service),
30442 "1" (0),
30443 - "D" (&bios32_indirect));
30444 + "D" (&bios32_indirect),
30445 + "r"(__PCIBIOS_DS)
30446 + : "memory");
30447 +
30448 + pax_open_kernel();
30449 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30450 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30451 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30452 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30453 + pax_close_kernel();
30454 +
30455 local_irq_restore(flags);
30456
30457 switch (return_code) {
30458 - case 0:
30459 - return address + entry;
30460 - case 0x80: /* Not present */
30461 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30462 - return 0;
30463 - default: /* Shouldn't happen */
30464 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30465 - service, return_code);
30466 + case 0: {
30467 + int cpu;
30468 + unsigned char flags;
30469 +
30470 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30471 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30472 + printk(KERN_WARNING "bios32_service: not valid\n");
30473 return 0;
30474 + }
30475 + address = address + PAGE_OFFSET;
30476 + length += 16UL; /* some BIOSs underreport this... */
30477 + flags = 4;
30478 + if (length >= 64*1024*1024) {
30479 + length >>= PAGE_SHIFT;
30480 + flags |= 8;
30481 + }
30482 +
30483 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30484 + gdt = get_cpu_gdt_table(cpu);
30485 + pack_descriptor(&d, address, length, 0x9b, flags);
30486 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30487 + pack_descriptor(&d, address, length, 0x93, flags);
30488 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30489 + }
30490 + return entry;
30491 + }
30492 + case 0x80: /* Not present */
30493 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30494 + return 0;
30495 + default: /* Shouldn't happen */
30496 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30497 + service, return_code);
30498 + return 0;
30499 }
30500 }
30501
30502 static struct {
30503 unsigned long address;
30504 unsigned short segment;
30505 -} pci_indirect = { 0, __KERNEL_CS };
30506 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30507
30508 -static int pci_bios_present;
30509 +static int pci_bios_present __read_only;
30510
30511 static int check_pcibios(void)
30512 {
30513 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30514 unsigned long flags, pcibios_entry;
30515
30516 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30517 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30518 + pci_indirect.address = pcibios_entry;
30519
30520 local_irq_save(flags);
30521 - __asm__(
30522 - "lcall *(%%edi); cld\n\t"
30523 + __asm__("movw %w6, %%ds\n\t"
30524 + "lcall *%%ss:(%%edi); cld\n\t"
30525 + "push %%ss\n\t"
30526 + "pop %%ds\n\t"
30527 "jc 1f\n\t"
30528 "xor %%ah, %%ah\n"
30529 "1:"
30530 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30531 "=b" (ebx),
30532 "=c" (ecx)
30533 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30534 - "D" (&pci_indirect)
30535 + "D" (&pci_indirect),
30536 + "r" (__PCIBIOS_DS)
30537 : "memory");
30538 local_irq_restore(flags);
30539
30540 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30541
30542 switch (len) {
30543 case 1:
30544 - __asm__("lcall *(%%esi); cld\n\t"
30545 + __asm__("movw %w6, %%ds\n\t"
30546 + "lcall *%%ss:(%%esi); cld\n\t"
30547 + "push %%ss\n\t"
30548 + "pop %%ds\n\t"
30549 "jc 1f\n\t"
30550 "xor %%ah, %%ah\n"
30551 "1:"
30552 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30553 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30554 "b" (bx),
30555 "D" ((long)reg),
30556 - "S" (&pci_indirect));
30557 + "S" (&pci_indirect),
30558 + "r" (__PCIBIOS_DS));
30559 /*
30560 * Zero-extend the result beyond 8 bits, do not trust the
30561 * BIOS having done it:
30562 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30563 *value &= 0xff;
30564 break;
30565 case 2:
30566 - __asm__("lcall *(%%esi); cld\n\t"
30567 + __asm__("movw %w6, %%ds\n\t"
30568 + "lcall *%%ss:(%%esi); cld\n\t"
30569 + "push %%ss\n\t"
30570 + "pop %%ds\n\t"
30571 "jc 1f\n\t"
30572 "xor %%ah, %%ah\n"
30573 "1:"
30574 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30575 : "1" (PCIBIOS_READ_CONFIG_WORD),
30576 "b" (bx),
30577 "D" ((long)reg),
30578 - "S" (&pci_indirect));
30579 + "S" (&pci_indirect),
30580 + "r" (__PCIBIOS_DS));
30581 /*
30582 * Zero-extend the result beyond 16 bits, do not trust the
30583 * BIOS having done it:
30584 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30585 *value &= 0xffff;
30586 break;
30587 case 4:
30588 - __asm__("lcall *(%%esi); cld\n\t"
30589 + __asm__("movw %w6, %%ds\n\t"
30590 + "lcall *%%ss:(%%esi); cld\n\t"
30591 + "push %%ss\n\t"
30592 + "pop %%ds\n\t"
30593 "jc 1f\n\t"
30594 "xor %%ah, %%ah\n"
30595 "1:"
30596 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30597 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30598 "b" (bx),
30599 "D" ((long)reg),
30600 - "S" (&pci_indirect));
30601 + "S" (&pci_indirect),
30602 + "r" (__PCIBIOS_DS));
30603 break;
30604 }
30605
30606 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30607
30608 switch (len) {
30609 case 1:
30610 - __asm__("lcall *(%%esi); cld\n\t"
30611 + __asm__("movw %w6, %%ds\n\t"
30612 + "lcall *%%ss:(%%esi); cld\n\t"
30613 + "push %%ss\n\t"
30614 + "pop %%ds\n\t"
30615 "jc 1f\n\t"
30616 "xor %%ah, %%ah\n"
30617 "1:"
30618 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30619 "c" (value),
30620 "b" (bx),
30621 "D" ((long)reg),
30622 - "S" (&pci_indirect));
30623 + "S" (&pci_indirect),
30624 + "r" (__PCIBIOS_DS));
30625 break;
30626 case 2:
30627 - __asm__("lcall *(%%esi); cld\n\t"
30628 + __asm__("movw %w6, %%ds\n\t"
30629 + "lcall *%%ss:(%%esi); cld\n\t"
30630 + "push %%ss\n\t"
30631 + "pop %%ds\n\t"
30632 "jc 1f\n\t"
30633 "xor %%ah, %%ah\n"
30634 "1:"
30635 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30636 "c" (value),
30637 "b" (bx),
30638 "D" ((long)reg),
30639 - "S" (&pci_indirect));
30640 + "S" (&pci_indirect),
30641 + "r" (__PCIBIOS_DS));
30642 break;
30643 case 4:
30644 - __asm__("lcall *(%%esi); cld\n\t"
30645 + __asm__("movw %w6, %%ds\n\t"
30646 + "lcall *%%ss:(%%esi); cld\n\t"
30647 + "push %%ss\n\t"
30648 + "pop %%ds\n\t"
30649 "jc 1f\n\t"
30650 "xor %%ah, %%ah\n"
30651 "1:"
30652 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30653 "c" (value),
30654 "b" (bx),
30655 "D" ((long)reg),
30656 - "S" (&pci_indirect));
30657 + "S" (&pci_indirect),
30658 + "r" (__PCIBIOS_DS));
30659 break;
30660 }
30661
30662 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30663
30664 DBG("PCI: Fetching IRQ routing table... ");
30665 __asm__("push %%es\n\t"
30666 + "movw %w8, %%ds\n\t"
30667 "push %%ds\n\t"
30668 "pop %%es\n\t"
30669 - "lcall *(%%esi); cld\n\t"
30670 + "lcall *%%ss:(%%esi); cld\n\t"
30671 "pop %%es\n\t"
30672 + "push %%ss\n\t"
30673 + "pop %%ds\n"
30674 "jc 1f\n\t"
30675 "xor %%ah, %%ah\n"
30676 "1:"
30677 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30678 "1" (0),
30679 "D" ((long) &opt),
30680 "S" (&pci_indirect),
30681 - "m" (opt)
30682 + "m" (opt),
30683 + "r" (__PCIBIOS_DS)
30684 : "memory");
30685 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30686 if (ret & 0xff00)
30687 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30688 {
30689 int ret;
30690
30691 - __asm__("lcall *(%%esi); cld\n\t"
30692 + __asm__("movw %w5, %%ds\n\t"
30693 + "lcall *%%ss:(%%esi); cld\n\t"
30694 + "push %%ss\n\t"
30695 + "pop %%ds\n"
30696 "jc 1f\n\t"
30697 "xor %%ah, %%ah\n"
30698 "1:"
30699 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30700 : "0" (PCIBIOS_SET_PCI_HW_INT),
30701 "b" ((dev->bus->number << 8) | dev->devfn),
30702 "c" ((irq << 8) | (pin + 10)),
30703 - "S" (&pci_indirect));
30704 + "S" (&pci_indirect),
30705 + "r" (__PCIBIOS_DS));
30706 return !(ret & 0xff00);
30707 }
30708 EXPORT_SYMBOL(pcibios_set_irq_routing);
30709 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30710 index 40e4469..1ab536e 100644
30711 --- a/arch/x86/platform/efi/efi_32.c
30712 +++ b/arch/x86/platform/efi/efi_32.c
30713 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30714 {
30715 struct desc_ptr gdt_descr;
30716
30717 +#ifdef CONFIG_PAX_KERNEXEC
30718 + struct desc_struct d;
30719 +#endif
30720 +
30721 local_irq_save(efi_rt_eflags);
30722
30723 load_cr3(initial_page_table);
30724 __flush_tlb_all();
30725
30726 +#ifdef CONFIG_PAX_KERNEXEC
30727 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30728 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30729 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30730 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30731 +#endif
30732 +
30733 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30734 gdt_descr.size = GDT_SIZE - 1;
30735 load_gdt(&gdt_descr);
30736 @@ -58,6 +69,14 @@ void efi_call_phys_epilog(void)
30737 {
30738 struct desc_ptr gdt_descr;
30739
30740 +#ifdef CONFIG_PAX_KERNEXEC
30741 + struct desc_struct d;
30742 +
30743 + memset(&d, 0, sizeof d);
30744 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30745 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30746 +#endif
30747 +
30748 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30749 gdt_descr.size = GDT_SIZE - 1;
30750 load_gdt(&gdt_descr);
30751 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30752 index fbe66e6..eae5e38 100644
30753 --- a/arch/x86/platform/efi/efi_stub_32.S
30754 +++ b/arch/x86/platform/efi/efi_stub_32.S
30755 @@ -6,7 +6,9 @@
30756 */
30757
30758 #include <linux/linkage.h>
30759 +#include <linux/init.h>
30760 #include <asm/page_types.h>
30761 +#include <asm/segment.h>
30762
30763 /*
30764 * efi_call_phys(void *, ...) is a function with variable parameters.
30765 @@ -20,7 +22,7 @@
30766 * service functions will comply with gcc calling convention, too.
30767 */
30768
30769 -.text
30770 +__INIT
30771 ENTRY(efi_call_phys)
30772 /*
30773 * 0. The function can only be called in Linux kernel. So CS has been
30774 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30775 * The mapping of lower virtual memory has been created in prelog and
30776 * epilog.
30777 */
30778 - movl $1f, %edx
30779 - subl $__PAGE_OFFSET, %edx
30780 - jmp *%edx
30781 +#ifdef CONFIG_PAX_KERNEXEC
30782 + movl $(__KERNEXEC_EFI_DS), %edx
30783 + mov %edx, %ds
30784 + mov %edx, %es
30785 + mov %edx, %ss
30786 + addl $2f,(1f)
30787 + ljmp *(1f)
30788 +
30789 +__INITDATA
30790 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30791 +.previous
30792 +
30793 +2:
30794 + subl $2b,(1b)
30795 +#else
30796 + jmp 1f-__PAGE_OFFSET
30797 1:
30798 +#endif
30799
30800 /*
30801 * 2. Now on the top of stack is the return
30802 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30803 * parameter 2, ..., param n. To make things easy, we save the return
30804 * address of efi_call_phys in a global variable.
30805 */
30806 - popl %edx
30807 - movl %edx, saved_return_addr
30808 - /* get the function pointer into ECX*/
30809 - popl %ecx
30810 - movl %ecx, efi_rt_function_ptr
30811 - movl $2f, %edx
30812 - subl $__PAGE_OFFSET, %edx
30813 - pushl %edx
30814 + popl (saved_return_addr)
30815 + popl (efi_rt_function_ptr)
30816
30817 /*
30818 * 3. Clear PG bit in %CR0.
30819 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30820 /*
30821 * 5. Call the physical function.
30822 */
30823 - jmp *%ecx
30824 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30825
30826 -2:
30827 /*
30828 * 6. After EFI runtime service returns, control will return to
30829 * following instruction. We'd better readjust stack pointer first.
30830 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30831 movl %cr0, %edx
30832 orl $0x80000000, %edx
30833 movl %edx, %cr0
30834 - jmp 1f
30835 -1:
30836 +
30837 /*
30838 * 8. Now restore the virtual mode from flat mode by
30839 * adding EIP with PAGE_OFFSET.
30840 */
30841 - movl $1f, %edx
30842 - jmp *%edx
30843 +#ifdef CONFIG_PAX_KERNEXEC
30844 + movl $(__KERNEL_DS), %edx
30845 + mov %edx, %ds
30846 + mov %edx, %es
30847 + mov %edx, %ss
30848 + ljmp $(__KERNEL_CS),$1f
30849 +#else
30850 + jmp 1f+__PAGE_OFFSET
30851 +#endif
30852 1:
30853
30854 /*
30855 * 9. Balance the stack. And because EAX contain the return value,
30856 * we'd better not clobber it.
30857 */
30858 - leal efi_rt_function_ptr, %edx
30859 - movl (%edx), %ecx
30860 - pushl %ecx
30861 + pushl (efi_rt_function_ptr)
30862
30863 /*
30864 - * 10. Push the saved return address onto the stack and return.
30865 + * 10. Return to the saved return address.
30866 */
30867 - leal saved_return_addr, %edx
30868 - movl (%edx), %ecx
30869 - pushl %ecx
30870 - ret
30871 + jmpl *(saved_return_addr)
30872 ENDPROC(efi_call_phys)
30873 .previous
30874
30875 -.data
30876 +__INITDATA
30877 saved_return_addr:
30878 .long 0
30879 efi_rt_function_ptr:
30880 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30881 index 4c07cca..2c8427d 100644
30882 --- a/arch/x86/platform/efi/efi_stub_64.S
30883 +++ b/arch/x86/platform/efi/efi_stub_64.S
30884 @@ -7,6 +7,7 @@
30885 */
30886
30887 #include <linux/linkage.h>
30888 +#include <asm/alternative-asm.h>
30889
30890 #define SAVE_XMM \
30891 mov %rsp, %rax; \
30892 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30893 call *%rdi
30894 addq $32, %rsp
30895 RESTORE_XMM
30896 + pax_force_retaddr 0, 1
30897 ret
30898 ENDPROC(efi_call0)
30899
30900 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30901 call *%rdi
30902 addq $32, %rsp
30903 RESTORE_XMM
30904 + pax_force_retaddr 0, 1
30905 ret
30906 ENDPROC(efi_call1)
30907
30908 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30909 call *%rdi
30910 addq $32, %rsp
30911 RESTORE_XMM
30912 + pax_force_retaddr 0, 1
30913 ret
30914 ENDPROC(efi_call2)
30915
30916 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30917 call *%rdi
30918 addq $32, %rsp
30919 RESTORE_XMM
30920 + pax_force_retaddr 0, 1
30921 ret
30922 ENDPROC(efi_call3)
30923
30924 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30925 call *%rdi
30926 addq $32, %rsp
30927 RESTORE_XMM
30928 + pax_force_retaddr 0, 1
30929 ret
30930 ENDPROC(efi_call4)
30931
30932 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30933 call *%rdi
30934 addq $48, %rsp
30935 RESTORE_XMM
30936 + pax_force_retaddr 0, 1
30937 ret
30938 ENDPROC(efi_call5)
30939
30940 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30941 call *%rdi
30942 addq $48, %rsp
30943 RESTORE_XMM
30944 + pax_force_retaddr 0, 1
30945 ret
30946 ENDPROC(efi_call6)
30947 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30948 index e31bcd8..f12dc46 100644
30949 --- a/arch/x86/platform/mrst/mrst.c
30950 +++ b/arch/x86/platform/mrst/mrst.c
30951 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30952 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30953 int sfi_mrtc_num;
30954
30955 -static void mrst_power_off(void)
30956 +static __noreturn void mrst_power_off(void)
30957 {
30958 + BUG();
30959 }
30960
30961 -static void mrst_reboot(void)
30962 +static __noreturn void mrst_reboot(void)
30963 {
30964 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30965 + BUG();
30966 }
30967
30968 /* parse all the mtimer info to a static mtimer array */
30969 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30970 index d6ee929..3637cb5 100644
30971 --- a/arch/x86/platform/olpc/olpc_dt.c
30972 +++ b/arch/x86/platform/olpc/olpc_dt.c
30973 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30974 return res;
30975 }
30976
30977 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30978 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30979 .nextprop = olpc_dt_nextprop,
30980 .getproplen = olpc_dt_getproplen,
30981 .getproperty = olpc_dt_getproperty,
30982 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30983 index 3c68768..07e82b8 100644
30984 --- a/arch/x86/power/cpu.c
30985 +++ b/arch/x86/power/cpu.c
30986 @@ -134,7 +134,7 @@ static void do_fpu_end(void)
30987 static void fix_processor_context(void)
30988 {
30989 int cpu = smp_processor_id();
30990 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30991 + struct tss_struct *t = init_tss + cpu;
30992
30993 set_tss_desc(cpu, t); /*
30994 * This just modifies memory; should not be
30995 @@ -144,8 +144,6 @@ static void fix_processor_context(void)
30996 */
30997
30998 #ifdef CONFIG_X86_64
30999 - get_cpu_gdt_table(cpu)[GDT_ENTRY_TSS].type = 9;
31000 -
31001 syscall_init(); /* This sets MSR_*STAR and related */
31002 #endif
31003 load_TR_desc(); /* This does ltr */
31004 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
31005 index cbca565..bae7133 100644
31006 --- a/arch/x86/realmode/init.c
31007 +++ b/arch/x86/realmode/init.c
31008 @@ -62,7 +62,13 @@ void __init setup_real_mode(void)
31009 __va(real_mode_header->trampoline_header);
31010
31011 #ifdef CONFIG_X86_32
31012 - trampoline_header->start = __pa(startup_32_smp);
31013 + trampoline_header->start = __pa(ktla_ktva(startup_32_smp));
31014 +
31015 +#ifdef CONFIG_PAX_KERNEXEC
31016 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
31017 +#endif
31018 +
31019 + trampoline_header->boot_cs = __BOOT_CS;
31020 trampoline_header->gdt_limit = __BOOT_DS + 7;
31021 trampoline_header->gdt_base = __pa(boot_gdt);
31022 #else
31023 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
31024 index 8869287..d577672 100644
31025 --- a/arch/x86/realmode/rm/Makefile
31026 +++ b/arch/x86/realmode/rm/Makefile
31027 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
31028 $(call cc-option, -fno-unit-at-a-time)) \
31029 $(call cc-option, -fno-stack-protector) \
31030 $(call cc-option, -mpreferred-stack-boundary=2)
31031 +ifdef CONSTIFY_PLUGIN
31032 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
31033 +endif
31034 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
31035 GCOV_PROFILE := n
31036 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
31037 index a28221d..93c40f1 100644
31038 --- a/arch/x86/realmode/rm/header.S
31039 +++ b/arch/x86/realmode/rm/header.S
31040 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
31041 #endif
31042 /* APM/BIOS reboot */
31043 .long pa_machine_real_restart_asm
31044 -#ifdef CONFIG_X86_64
31045 +#ifdef CONFIG_X86_32
31046 + .long __KERNEL_CS
31047 +#else
31048 .long __KERNEL32_CS
31049 #endif
31050 END(real_mode_header)
31051 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
31052 index c1b2791..f9e31c7 100644
31053 --- a/arch/x86/realmode/rm/trampoline_32.S
31054 +++ b/arch/x86/realmode/rm/trampoline_32.S
31055 @@ -25,6 +25,12 @@
31056 #include <asm/page_types.h>
31057 #include "realmode.h"
31058
31059 +#ifdef CONFIG_PAX_KERNEXEC
31060 +#define ta(X) (X)
31061 +#else
31062 +#define ta(X) (pa_ ## X)
31063 +#endif
31064 +
31065 .text
31066 .code16
31067
31068 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
31069
31070 cli # We should be safe anyway
31071
31072 - movl tr_start, %eax # where we need to go
31073 -
31074 movl $0xA5A5A5A5, trampoline_status
31075 # write marker for master knows we're running
31076
31077 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
31078 movw $1, %dx # protected mode (PE) bit
31079 lmsw %dx # into protected mode
31080
31081 - ljmpl $__BOOT_CS, $pa_startup_32
31082 + ljmpl *(trampoline_header)
31083
31084 .section ".text32","ax"
31085 .code32
31086 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
31087 .balign 8
31088 GLOBAL(trampoline_header)
31089 tr_start: .space 4
31090 - tr_gdt_pad: .space 2
31091 + tr_boot_cs: .space 2
31092 tr_gdt: .space 6
31093 END(trampoline_header)
31094
31095 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
31096 index bb360dc..3e5945f 100644
31097 --- a/arch/x86/realmode/rm/trampoline_64.S
31098 +++ b/arch/x86/realmode/rm/trampoline_64.S
31099 @@ -107,7 +107,7 @@ ENTRY(startup_32)
31100 wrmsr
31101
31102 # Enable paging and in turn activate Long Mode
31103 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
31104 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
31105 movl %eax, %cr0
31106
31107 /*
31108 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
31109 index 79d67bd..c7e1b90 100644
31110 --- a/arch/x86/tools/relocs.c
31111 +++ b/arch/x86/tools/relocs.c
31112 @@ -12,10 +12,13 @@
31113 #include <regex.h>
31114 #include <tools/le_byteshift.h>
31115
31116 +#include "../../../include/generated/autoconf.h"
31117 +
31118 static void die(char *fmt, ...);
31119
31120 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
31121 static Elf32_Ehdr ehdr;
31122 +static Elf32_Phdr *phdr;
31123 static unsigned long reloc_count, reloc_idx;
31124 static unsigned long *relocs;
31125 static unsigned long reloc16_count, reloc16_idx;
31126 @@ -330,9 +333,39 @@ static void read_ehdr(FILE *fp)
31127 }
31128 }
31129
31130 +static void read_phdrs(FILE *fp)
31131 +{
31132 + unsigned int i;
31133 +
31134 + phdr = calloc(ehdr.e_phnum, sizeof(Elf32_Phdr));
31135 + if (!phdr) {
31136 + die("Unable to allocate %d program headers\n",
31137 + ehdr.e_phnum);
31138 + }
31139 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
31140 + die("Seek to %d failed: %s\n",
31141 + ehdr.e_phoff, strerror(errno));
31142 + }
31143 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
31144 + die("Cannot read ELF program headers: %s\n",
31145 + strerror(errno));
31146 + }
31147 + for(i = 0; i < ehdr.e_phnum; i++) {
31148 + phdr[i].p_type = elf32_to_cpu(phdr[i].p_type);
31149 + phdr[i].p_offset = elf32_to_cpu(phdr[i].p_offset);
31150 + phdr[i].p_vaddr = elf32_to_cpu(phdr[i].p_vaddr);
31151 + phdr[i].p_paddr = elf32_to_cpu(phdr[i].p_paddr);
31152 + phdr[i].p_filesz = elf32_to_cpu(phdr[i].p_filesz);
31153 + phdr[i].p_memsz = elf32_to_cpu(phdr[i].p_memsz);
31154 + phdr[i].p_flags = elf32_to_cpu(phdr[i].p_flags);
31155 + phdr[i].p_align = elf32_to_cpu(phdr[i].p_align);
31156 + }
31157 +
31158 +}
31159 +
31160 static void read_shdrs(FILE *fp)
31161 {
31162 - int i;
31163 + unsigned int i;
31164 Elf32_Shdr shdr;
31165
31166 secs = calloc(ehdr.e_shnum, sizeof(struct section));
31167 @@ -367,7 +400,7 @@ static void read_shdrs(FILE *fp)
31168
31169 static void read_strtabs(FILE *fp)
31170 {
31171 - int i;
31172 + unsigned int i;
31173 for (i = 0; i < ehdr.e_shnum; i++) {
31174 struct section *sec = &secs[i];
31175 if (sec->shdr.sh_type != SHT_STRTAB) {
31176 @@ -392,7 +425,7 @@ static void read_strtabs(FILE *fp)
31177
31178 static void read_symtabs(FILE *fp)
31179 {
31180 - int i,j;
31181 + unsigned int i,j;
31182 for (i = 0; i < ehdr.e_shnum; i++) {
31183 struct section *sec = &secs[i];
31184 if (sec->shdr.sh_type != SHT_SYMTAB) {
31185 @@ -423,9 +456,11 @@ static void read_symtabs(FILE *fp)
31186 }
31187
31188
31189 -static void read_relocs(FILE *fp)
31190 +static void read_relocs(FILE *fp, int use_real_mode)
31191 {
31192 - int i,j;
31193 + unsigned int i,j;
31194 + uint32_t base;
31195 +
31196 for (i = 0; i < ehdr.e_shnum; i++) {
31197 struct section *sec = &secs[i];
31198 if (sec->shdr.sh_type != SHT_REL) {
31199 @@ -445,9 +480,22 @@ static void read_relocs(FILE *fp)
31200 die("Cannot read symbol table: %s\n",
31201 strerror(errno));
31202 }
31203 + base = 0;
31204 +
31205 +#ifdef CONFIG_X86_32
31206 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
31207 + if (phdr[j].p_type != PT_LOAD )
31208 + continue;
31209 + 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)
31210 + continue;
31211 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
31212 + break;
31213 + }
31214 +#endif
31215 +
31216 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf32_Rel); j++) {
31217 Elf32_Rel *rel = &sec->reltab[j];
31218 - rel->r_offset = elf32_to_cpu(rel->r_offset);
31219 + rel->r_offset = elf32_to_cpu(rel->r_offset) + base;
31220 rel->r_info = elf32_to_cpu(rel->r_info);
31221 }
31222 }
31223 @@ -456,13 +504,13 @@ static void read_relocs(FILE *fp)
31224
31225 static void print_absolute_symbols(void)
31226 {
31227 - int i;
31228 + unsigned int i;
31229 printf("Absolute symbols\n");
31230 printf(" Num: Value Size Type Bind Visibility Name\n");
31231 for (i = 0; i < ehdr.e_shnum; i++) {
31232 struct section *sec = &secs[i];
31233 char *sym_strtab;
31234 - int j;
31235 + unsigned int j;
31236
31237 if (sec->shdr.sh_type != SHT_SYMTAB) {
31238 continue;
31239 @@ -489,14 +537,14 @@ static void print_absolute_symbols(void)
31240
31241 static void print_absolute_relocs(void)
31242 {
31243 - int i, printed = 0;
31244 + unsigned int i, printed = 0;
31245
31246 for (i = 0; i < ehdr.e_shnum; i++) {
31247 struct section *sec = &secs[i];
31248 struct section *sec_applies, *sec_symtab;
31249 char *sym_strtab;
31250 Elf32_Sym *sh_symtab;
31251 - int j;
31252 + unsigned int j;
31253 if (sec->shdr.sh_type != SHT_REL) {
31254 continue;
31255 }
31256 @@ -558,13 +606,13 @@ static void print_absolute_relocs(void)
31257 static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31258 int use_real_mode)
31259 {
31260 - int i;
31261 + unsigned int i;
31262 /* Walk through the relocations */
31263 for (i = 0; i < ehdr.e_shnum; i++) {
31264 char *sym_strtab;
31265 Elf32_Sym *sh_symtab;
31266 struct section *sec_applies, *sec_symtab;
31267 - int j;
31268 + unsigned int j;
31269 struct section *sec = &secs[i];
31270
31271 if (sec->shdr.sh_type != SHT_REL) {
31272 @@ -588,6 +636,24 @@ static void walk_relocs(void (*visit)(Elf32_Rel *rel, Elf32_Sym *sym),
31273 sym = &sh_symtab[ELF32_R_SYM(rel->r_info)];
31274 r_type = ELF32_R_TYPE(rel->r_info);
31275
31276 + if (!use_real_mode) {
31277 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31278 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31279 + continue;
31280 +
31281 +#if defined(CONFIG_PAX_KERNEXEC) && defined(CONFIG_X86_32)
31282 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31283 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31284 + continue;
31285 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31286 + continue;
31287 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31288 + continue;
31289 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31290 + continue;
31291 +#endif
31292 + }
31293 +
31294 shn_abs = sym->st_shndx == SHN_ABS;
31295
31296 switch (r_type) {
31297 @@ -681,7 +747,7 @@ static int write32(unsigned int v, FILE *f)
31298
31299 static void emit_relocs(int as_text, int use_real_mode)
31300 {
31301 - int i;
31302 + unsigned int i;
31303 /* Count how many relocations I have and allocate space for them. */
31304 reloc_count = 0;
31305 walk_relocs(count_reloc, use_real_mode);
31306 @@ -808,10 +874,11 @@ int main(int argc, char **argv)
31307 fname, strerror(errno));
31308 }
31309 read_ehdr(fp);
31310 + read_phdrs(fp);
31311 read_shdrs(fp);
31312 read_strtabs(fp);
31313 read_symtabs(fp);
31314 - read_relocs(fp);
31315 + read_relocs(fp, use_real_mode);
31316 if (show_absolute_syms) {
31317 print_absolute_symbols();
31318 goto out;
31319 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31320 index fd14be1..e3c79c0 100644
31321 --- a/arch/x86/vdso/Makefile
31322 +++ b/arch/x86/vdso/Makefile
31323 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31324 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31325 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31326
31327 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31328 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31329 GCOV_PROFILE := n
31330
31331 #
31332 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31333 index 0faad64..39ef157 100644
31334 --- a/arch/x86/vdso/vdso32-setup.c
31335 +++ b/arch/x86/vdso/vdso32-setup.c
31336 @@ -25,6 +25,7 @@
31337 #include <asm/tlbflush.h>
31338 #include <asm/vdso.h>
31339 #include <asm/proto.h>
31340 +#include <asm/mman.h>
31341
31342 enum {
31343 VDSO_DISABLED = 0,
31344 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31345 void enable_sep_cpu(void)
31346 {
31347 int cpu = get_cpu();
31348 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31349 + struct tss_struct *tss = init_tss + cpu;
31350
31351 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31352 put_cpu();
31353 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31354 gate_vma.vm_start = FIXADDR_USER_START;
31355 gate_vma.vm_end = FIXADDR_USER_END;
31356 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31357 - gate_vma.vm_page_prot = __P101;
31358 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31359
31360 return 0;
31361 }
31362 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31363 if (compat)
31364 addr = VDSO_HIGH_BASE;
31365 else {
31366 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31367 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31368 if (IS_ERR_VALUE(addr)) {
31369 ret = addr;
31370 goto up_fail;
31371 }
31372 }
31373
31374 - current->mm->context.vdso = (void *)addr;
31375 + current->mm->context.vdso = addr;
31376
31377 if (compat_uses_vma || !compat) {
31378 /*
31379 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31380 }
31381
31382 current_thread_info()->sysenter_return =
31383 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31384 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31385
31386 up_fail:
31387 if (ret)
31388 - current->mm->context.vdso = NULL;
31389 + current->mm->context.vdso = 0;
31390
31391 up_write(&mm->mmap_sem);
31392
31393 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31394
31395 const char *arch_vma_name(struct vm_area_struct *vma)
31396 {
31397 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31398 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31399 return "[vdso]";
31400 +
31401 +#ifdef CONFIG_PAX_SEGMEXEC
31402 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31403 + return "[vdso]";
31404 +#endif
31405 +
31406 return NULL;
31407 }
31408
31409 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31410 * Check to see if the corresponding task was created in compat vdso
31411 * mode.
31412 */
31413 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31414 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31415 return &gate_vma;
31416 return NULL;
31417 }
31418 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31419 index 431e875..cbb23f3 100644
31420 --- a/arch/x86/vdso/vma.c
31421 +++ b/arch/x86/vdso/vma.c
31422 @@ -16,8 +16,6 @@
31423 #include <asm/vdso.h>
31424 #include <asm/page.h>
31425
31426 -unsigned int __read_mostly vdso_enabled = 1;
31427 -
31428 extern char vdso_start[], vdso_end[];
31429 extern unsigned short vdso_sync_cpuid;
31430
31431 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31432 * unaligned here as a result of stack start randomization.
31433 */
31434 addr = PAGE_ALIGN(addr);
31435 - addr = align_vdso_addr(addr);
31436
31437 return addr;
31438 }
31439 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31440 unsigned size)
31441 {
31442 struct mm_struct *mm = current->mm;
31443 - unsigned long addr;
31444 + unsigned long addr = 0;
31445 int ret;
31446
31447 - if (!vdso_enabled)
31448 - return 0;
31449 -
31450 down_write(&mm->mmap_sem);
31451 +
31452 +#ifdef CONFIG_PAX_RANDMMAP
31453 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31454 +#endif
31455 +
31456 addr = vdso_addr(mm->start_stack, size);
31457 + addr = align_vdso_addr(addr);
31458 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31459 if (IS_ERR_VALUE(addr)) {
31460 ret = addr;
31461 goto up_fail;
31462 }
31463
31464 - current->mm->context.vdso = (void *)addr;
31465 + mm->context.vdso = addr;
31466
31467 ret = install_special_mapping(mm, addr, size,
31468 VM_READ|VM_EXEC|
31469 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31470 pages);
31471 - if (ret) {
31472 - current->mm->context.vdso = NULL;
31473 - goto up_fail;
31474 - }
31475 + if (ret)
31476 + mm->context.vdso = 0;
31477
31478 up_fail:
31479 up_write(&mm->mmap_sem);
31480 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31481 vdsox32_size);
31482 }
31483 #endif
31484 -
31485 -static __init int vdso_setup(char *s)
31486 -{
31487 - vdso_enabled = simple_strtoul(s, NULL, 0);
31488 - return 0;
31489 -}
31490 -__setup("vdso=", vdso_setup);
31491 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31492 index 2262003..3ee61cf 100644
31493 --- a/arch/x86/xen/enlighten.c
31494 +++ b/arch/x86/xen/enlighten.c
31495 @@ -100,8 +100,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31496
31497 struct shared_info xen_dummy_shared_info;
31498
31499 -void *xen_initial_gdt;
31500 -
31501 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31502 __read_mostly int xen_have_vector_callback;
31503 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31504 @@ -496,8 +494,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31505 {
31506 unsigned long va = dtr->address;
31507 unsigned int size = dtr->size + 1;
31508 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31509 - unsigned long frames[pages];
31510 + unsigned long frames[65536 / PAGE_SIZE];
31511 int f;
31512
31513 /*
31514 @@ -545,8 +542,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31515 {
31516 unsigned long va = dtr->address;
31517 unsigned int size = dtr->size + 1;
31518 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31519 - unsigned long frames[pages];
31520 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31521 int f;
31522
31523 /*
31524 @@ -554,7 +550,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31525 * 8-byte entries, or 16 4k pages..
31526 */
31527
31528 - BUG_ON(size > 65536);
31529 + BUG_ON(size > GDT_SIZE);
31530 BUG_ON(va & ~PAGE_MASK);
31531
31532 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31533 @@ -939,7 +935,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31534 return 0;
31535 }
31536
31537 -static void set_xen_basic_apic_ops(void)
31538 +static void __init set_xen_basic_apic_ops(void)
31539 {
31540 apic->read = xen_apic_read;
31541 apic->write = xen_apic_write;
31542 @@ -1245,30 +1241,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31543 #endif
31544 };
31545
31546 -static void xen_reboot(int reason)
31547 +static __noreturn void xen_reboot(int reason)
31548 {
31549 struct sched_shutdown r = { .reason = reason };
31550
31551 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31552 - BUG();
31553 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31554 + BUG();
31555 }
31556
31557 -static void xen_restart(char *msg)
31558 +static __noreturn void xen_restart(char *msg)
31559 {
31560 xen_reboot(SHUTDOWN_reboot);
31561 }
31562
31563 -static void xen_emergency_restart(void)
31564 +static __noreturn void xen_emergency_restart(void)
31565 {
31566 xen_reboot(SHUTDOWN_reboot);
31567 }
31568
31569 -static void xen_machine_halt(void)
31570 +static __noreturn void xen_machine_halt(void)
31571 {
31572 xen_reboot(SHUTDOWN_poweroff);
31573 }
31574
31575 -static void xen_machine_power_off(void)
31576 +static __noreturn void xen_machine_power_off(void)
31577 {
31578 if (pm_power_off)
31579 pm_power_off();
31580 @@ -1370,7 +1366,17 @@ asmlinkage void __init xen_start_kernel(void)
31581 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31582
31583 /* Work out if we support NX */
31584 - x86_configure_nx();
31585 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31586 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31587 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31588 + unsigned l, h;
31589 +
31590 + __supported_pte_mask |= _PAGE_NX;
31591 + rdmsr(MSR_EFER, l, h);
31592 + l |= EFER_NX;
31593 + wrmsr(MSR_EFER, l, h);
31594 + }
31595 +#endif
31596
31597 xen_setup_features();
31598
31599 @@ -1401,13 +1407,6 @@ asmlinkage void __init xen_start_kernel(void)
31600
31601 machine_ops = xen_machine_ops;
31602
31603 - /*
31604 - * The only reliable way to retain the initial address of the
31605 - * percpu gdt_page is to remember it here, so we can go and
31606 - * mark it RW later, when the initial percpu area is freed.
31607 - */
31608 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31609 -
31610 xen_smp_init();
31611
31612 #ifdef CONFIG_ACPI_NUMA
31613 @@ -1598,7 +1597,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31614 return NOTIFY_OK;
31615 }
31616
31617 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31618 +static struct notifier_block xen_hvm_cpu_notifier = {
31619 .notifier_call = xen_hvm_cpu_notify,
31620 };
31621
31622 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31623 index 01de35c..692023f 100644
31624 --- a/arch/x86/xen/mmu.c
31625 +++ b/arch/x86/xen/mmu.c
31626 @@ -1739,14 +1739,18 @@ static void *m2v(phys_addr_t maddr)
31627 }
31628
31629 /* Set the page permissions on an identity-mapped pages */
31630 -static void set_page_prot(void *addr, pgprot_t prot)
31631 +static void set_page_prot_flags(void *addr, pgprot_t prot, unsigned long flags)
31632 {
31633 unsigned long pfn = __pa(addr) >> PAGE_SHIFT;
31634 pte_t pte = pfn_pte(pfn, prot);
31635
31636 - if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, 0))
31637 + if (HYPERVISOR_update_va_mapping((unsigned long)addr, pte, flags))
31638 BUG();
31639 }
31640 +static void set_page_prot(void *addr, pgprot_t prot)
31641 +{
31642 + return set_page_prot_flags(addr, prot, UVMF_NONE);
31643 +}
31644 #ifdef CONFIG_X86_32
31645 static void __init xen_map_identity_early(pmd_t *pmd, unsigned long max_pfn)
31646 {
31647 @@ -1830,12 +1834,12 @@ static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
31648 unsigned long addr)
31649 {
31650 if (*pt_base == 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_base)++;
31655 }
31656 if (*pt_end == PFN_DOWN(__pa(addr))) {
31657 - set_page_prot((void *)addr, PAGE_KERNEL);
31658 + set_page_prot_flags((void *)addr, PAGE_KERNEL, UVMF_INVLPG);
31659 clear_page((void *)addr);
31660 (*pt_end)--;
31661 }
31662 @@ -1881,6 +1885,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31663 /* L3_k[510] -> level2_kernel_pgt
31664 * L3_i[511] -> level2_fixmap_pgt */
31665 convert_pfn_mfn(level3_kernel_pgt);
31666 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31667 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31668 + convert_pfn_mfn(level3_vmemmap_pgt);
31669
31670 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31671 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31672 @@ -1910,8 +1917,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31673 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31674 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31675 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31676 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31677 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31678 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31679 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31680 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31681 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31682 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31683 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31684
31685 @@ -2097,6 +2108,7 @@ static void __init xen_post_allocator_init(void)
31686 pv_mmu_ops.set_pud = xen_set_pud;
31687 #if PAGETABLE_LEVELS == 4
31688 pv_mmu_ops.set_pgd = xen_set_pgd;
31689 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31690 #endif
31691
31692 /* This will work as long as patching hasn't happened yet
31693 @@ -2178,6 +2190,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31694 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31695 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31696 .set_pgd = xen_set_pgd_hyper,
31697 + .set_pgd_batched = xen_set_pgd_hyper,
31698
31699 .alloc_pud = xen_alloc_pmd_init,
31700 .release_pud = xen_release_pmd_init,
31701 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31702 index 34bc4ce..c34aa24 100644
31703 --- a/arch/x86/xen/smp.c
31704 +++ b/arch/x86/xen/smp.c
31705 @@ -229,11 +229,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31706 {
31707 BUG_ON(smp_processor_id() != 0);
31708 native_smp_prepare_boot_cpu();
31709 -
31710 - /* We've switched to the "real" per-cpu gdt, so make sure the
31711 - old memory can be recycled */
31712 - make_lowmem_page_readwrite(xen_initial_gdt);
31713 -
31714 xen_filter_cpu_maps();
31715 xen_setup_vcpu_info_placement();
31716 }
31717 @@ -300,12 +295,12 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31718 gdt = get_cpu_gdt_table(cpu);
31719
31720 ctxt->flags = VGCF_IN_KERNEL;
31721 - ctxt->user_regs.ds = __USER_DS;
31722 - ctxt->user_regs.es = __USER_DS;
31723 + ctxt->user_regs.ds = __KERNEL_DS;
31724 + ctxt->user_regs.es = __KERNEL_DS;
31725 ctxt->user_regs.ss = __KERNEL_DS;
31726 #ifdef CONFIG_X86_32
31727 ctxt->user_regs.fs = __KERNEL_PERCPU;
31728 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31729 + savesegment(gs, ctxt->user_regs.gs);
31730 #else
31731 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31732 #endif
31733 @@ -355,13 +350,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31734 int rc;
31735
31736 per_cpu(current_task, cpu) = idle;
31737 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31738 #ifdef CONFIG_X86_32
31739 irq_ctx_init(cpu);
31740 #else
31741 clear_tsk_thread_flag(idle, TIF_FORK);
31742 - per_cpu(kernel_stack, cpu) =
31743 - (unsigned long)task_stack_page(idle) -
31744 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31745 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31746 #endif
31747 xen_setup_runstate_info(cpu);
31748 xen_setup_timer(cpu);
31749 @@ -630,7 +624,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31750
31751 void __init xen_smp_init(void)
31752 {
31753 - smp_ops = xen_smp_ops;
31754 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31755 xen_fill_possible_map();
31756 xen_init_spinlocks();
31757 }
31758 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31759 index 33ca6e4..0ded929 100644
31760 --- a/arch/x86/xen/xen-asm_32.S
31761 +++ b/arch/x86/xen/xen-asm_32.S
31762 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31763 ESP_OFFSET=4 # bytes pushed onto stack
31764
31765 /*
31766 - * Store vcpu_info pointer for easy access. Do it this way to
31767 - * avoid having to reload %fs
31768 + * Store vcpu_info pointer for easy access.
31769 */
31770 #ifdef CONFIG_SMP
31771 - GET_THREAD_INFO(%eax)
31772 - movl %ss:TI_cpu(%eax), %eax
31773 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31774 - mov %ss:xen_vcpu(%eax), %eax
31775 + push %fs
31776 + mov $(__KERNEL_PERCPU), %eax
31777 + mov %eax, %fs
31778 + mov PER_CPU_VAR(xen_vcpu), %eax
31779 + pop %fs
31780 #else
31781 movl %ss:xen_vcpu, %eax
31782 #endif
31783 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31784 index 7faed58..ba4427c 100644
31785 --- a/arch/x86/xen/xen-head.S
31786 +++ b/arch/x86/xen/xen-head.S
31787 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31788 #ifdef CONFIG_X86_32
31789 mov %esi,xen_start_info
31790 mov $init_thread_union+THREAD_SIZE,%esp
31791 +#ifdef CONFIG_SMP
31792 + movl $cpu_gdt_table,%edi
31793 + movl $__per_cpu_load,%eax
31794 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31795 + rorl $16,%eax
31796 + movb %al,__KERNEL_PERCPU + 4(%edi)
31797 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31798 + movl $__per_cpu_end - 1,%eax
31799 + subl $__per_cpu_start,%eax
31800 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31801 +#endif
31802 #else
31803 mov %rsi,xen_start_info
31804 mov $init_thread_union+THREAD_SIZE,%rsp
31805 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31806 index a95b417..b6dbd0b 100644
31807 --- a/arch/x86/xen/xen-ops.h
31808 +++ b/arch/x86/xen/xen-ops.h
31809 @@ -10,8 +10,6 @@
31810 extern const char xen_hypervisor_callback[];
31811 extern const char xen_failsafe_callback[];
31812
31813 -extern void *xen_initial_gdt;
31814 -
31815 struct trap_info;
31816 void xen_copy_trap_info(struct trap_info *traps);
31817
31818 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31819 index 525bd3d..ef888b1 100644
31820 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31821 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31822 @@ -119,9 +119,9 @@
31823 ----------------------------------------------------------------------*/
31824
31825 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31826 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31827 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31828 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31829 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31830
31831 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31832 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31833 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31834 index 2f33760..835e50a 100644
31835 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31836 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31837 @@ -11,6 +11,7 @@
31838 #ifndef _XTENSA_CORE_H
31839 #define _XTENSA_CORE_H
31840
31841 +#include <linux/const.h>
31842
31843 /****************************************************************************
31844 Parameters Useful for Any Code, USER or PRIVILEGED
31845 @@ -112,9 +113,9 @@
31846 ----------------------------------------------------------------------*/
31847
31848 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31849 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31850 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31851 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31852 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31853
31854 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31855 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31856 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31857 index af00795..2bb8105 100644
31858 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31859 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31860 @@ -11,6 +11,7 @@
31861 #ifndef _XTENSA_CORE_CONFIGURATION_H
31862 #define _XTENSA_CORE_CONFIGURATION_H
31863
31864 +#include <linux/const.h>
31865
31866 /****************************************************************************
31867 Parameters Useful for Any Code, USER or PRIVILEGED
31868 @@ -118,9 +119,9 @@
31869 ----------------------------------------------------------------------*/
31870
31871 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31872 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31873 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31874 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31875 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31876
31877 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31878 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31879 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31880 index 58916af..eb9dbcf6 100644
31881 --- a/block/blk-iopoll.c
31882 +++ b/block/blk-iopoll.c
31883 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31884 }
31885 EXPORT_SYMBOL(blk_iopoll_complete);
31886
31887 -static void blk_iopoll_softirq(struct softirq_action *h)
31888 +static void blk_iopoll_softirq(void)
31889 {
31890 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31891 int rearm = 0, budget = blk_iopoll_budget;
31892 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31893 return NOTIFY_OK;
31894 }
31895
31896 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31897 +static struct notifier_block blk_iopoll_cpu_notifier = {
31898 .notifier_call = blk_iopoll_cpu_notify,
31899 };
31900
31901 diff --git a/block/blk-map.c b/block/blk-map.c
31902 index 623e1cd..ca1e109 100644
31903 --- a/block/blk-map.c
31904 +++ b/block/blk-map.c
31905 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31906 if (!len || !kbuf)
31907 return -EINVAL;
31908
31909 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31910 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31911 if (do_copy)
31912 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31913 else
31914 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31915 index 467c8de..f3628c5 100644
31916 --- a/block/blk-softirq.c
31917 +++ b/block/blk-softirq.c
31918 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31919 * Softirq action handler - move entries to local list and loop over them
31920 * while passing them to the queue registered handler.
31921 */
31922 -static void blk_done_softirq(struct softirq_action *h)
31923 +static void blk_done_softirq(void)
31924 {
31925 struct list_head *cpu_list, local_list;
31926
31927 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31928 return NOTIFY_OK;
31929 }
31930
31931 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31932 +static struct notifier_block blk_cpu_notifier = {
31933 .notifier_call = blk_cpu_notify,
31934 };
31935
31936 diff --git a/block/bsg.c b/block/bsg.c
31937 index ff64ae3..593560c 100644
31938 --- a/block/bsg.c
31939 +++ b/block/bsg.c
31940 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31941 struct sg_io_v4 *hdr, struct bsg_device *bd,
31942 fmode_t has_write_perm)
31943 {
31944 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31945 + unsigned char *cmdptr;
31946 +
31947 if (hdr->request_len > BLK_MAX_CDB) {
31948 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31949 if (!rq->cmd)
31950 return -ENOMEM;
31951 - }
31952 + cmdptr = rq->cmd;
31953 + } else
31954 + cmdptr = tmpcmd;
31955
31956 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31957 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31958 hdr->request_len))
31959 return -EFAULT;
31960
31961 + if (cmdptr != rq->cmd)
31962 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31963 +
31964 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31965 if (blk_verify_command(rq->cmd, has_write_perm))
31966 return -EPERM;
31967 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31968 index 7c668c8..db3521c 100644
31969 --- a/block/compat_ioctl.c
31970 +++ b/block/compat_ioctl.c
31971 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31972 err |= __get_user(f->spec1, &uf->spec1);
31973 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31974 err |= __get_user(name, &uf->name);
31975 - f->name = compat_ptr(name);
31976 + f->name = (void __force_kernel *)compat_ptr(name);
31977 if (err) {
31978 err = -EFAULT;
31979 goto out;
31980 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31981 index b62fb88..bdab4c4 100644
31982 --- a/block/partitions/efi.c
31983 +++ b/block/partitions/efi.c
31984 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31985 if (!gpt)
31986 return NULL;
31987
31988 + if (!le32_to_cpu(gpt->num_partition_entries))
31989 + return NULL;
31990 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31991 + if (!pte)
31992 + return NULL;
31993 +
31994 count = le32_to_cpu(gpt->num_partition_entries) *
31995 le32_to_cpu(gpt->sizeof_partition_entry);
31996 - if (!count)
31997 - return NULL;
31998 - pte = kzalloc(count, GFP_KERNEL);
31999 - if (!pte)
32000 - return NULL;
32001 -
32002 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
32003 (u8 *) pte,
32004 count) < count) {
32005 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
32006 index 9a87daa..fb17486 100644
32007 --- a/block/scsi_ioctl.c
32008 +++ b/block/scsi_ioctl.c
32009 @@ -223,8 +223,20 @@ EXPORT_SYMBOL(blk_verify_command);
32010 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
32011 struct sg_io_hdr *hdr, fmode_t mode)
32012 {
32013 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
32014 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32015 + unsigned char *cmdptr;
32016 +
32017 + if (rq->cmd != rq->__cmd)
32018 + cmdptr = rq->cmd;
32019 + else
32020 + cmdptr = tmpcmd;
32021 +
32022 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
32023 return -EFAULT;
32024 +
32025 + if (cmdptr != rq->cmd)
32026 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
32027 +
32028 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
32029 return -EPERM;
32030
32031 @@ -433,6 +445,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32032 int err;
32033 unsigned int in_len, out_len, bytes, opcode, cmdlen;
32034 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
32035 + unsigned char tmpcmd[sizeof(rq->__cmd)];
32036 + unsigned char *cmdptr;
32037
32038 if (!sic)
32039 return -EINVAL;
32040 @@ -466,9 +480,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
32041 */
32042 err = -EFAULT;
32043 rq->cmd_len = cmdlen;
32044 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
32045 +
32046 + if (rq->cmd != rq->__cmd)
32047 + cmdptr = rq->cmd;
32048 + else
32049 + cmdptr = tmpcmd;
32050 +
32051 + if (copy_from_user(cmdptr, sic->data, cmdlen))
32052 goto error;
32053
32054 + if (rq->cmd != cmdptr)
32055 + memcpy(rq->cmd, cmdptr, cmdlen);
32056 +
32057 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
32058 goto error;
32059
32060 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
32061 index 7bdd61b..afec999 100644
32062 --- a/crypto/cryptd.c
32063 +++ b/crypto/cryptd.c
32064 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
32065
32066 struct cryptd_blkcipher_request_ctx {
32067 crypto_completion_t complete;
32068 -};
32069 +} __no_const;
32070
32071 struct cryptd_hash_ctx {
32072 struct crypto_shash *child;
32073 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
32074
32075 struct cryptd_aead_request_ctx {
32076 crypto_completion_t complete;
32077 -};
32078 +} __no_const;
32079
32080 static void cryptd_queue_worker(struct work_struct *work);
32081
32082 diff --git a/crypto/crypto_user.c b/crypto/crypto_user.c
32083 index f6d9baf..dfd511f 100644
32084 --- a/crypto/crypto_user.c
32085 +++ b/crypto/crypto_user.c
32086 @@ -30,6 +30,8 @@
32087
32088 #include "internal.h"
32089
32090 +#define null_terminated(x) (strnlen(x, sizeof(x)) < sizeof(x))
32091 +
32092 static DEFINE_MUTEX(crypto_cfg_mutex);
32093
32094 /* The crypto netlink socket */
32095 @@ -196,7 +198,10 @@ static int crypto_report(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
32096 struct crypto_dump_info info;
32097 int err;
32098
32099 - if (!p->cru_driver_name)
32100 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32101 + return -EINVAL;
32102 +
32103 + if (!p->cru_driver_name[0])
32104 return -EINVAL;
32105
32106 alg = crypto_alg_match(p, 1);
32107 @@ -260,6 +265,9 @@ static int crypto_update_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32108 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32109 LIST_HEAD(list);
32110
32111 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32112 + return -EINVAL;
32113 +
32114 if (priority && !strlen(p->cru_driver_name))
32115 return -EINVAL;
32116
32117 @@ -287,6 +295,9 @@ static int crypto_del_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32118 struct crypto_alg *alg;
32119 struct crypto_user_alg *p = nlmsg_data(nlh);
32120
32121 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32122 + return -EINVAL;
32123 +
32124 alg = crypto_alg_match(p, 1);
32125 if (!alg)
32126 return -ENOENT;
32127 @@ -368,6 +379,9 @@ static int crypto_add_alg(struct sk_buff *skb, struct nlmsghdr *nlh,
32128 struct crypto_user_alg *p = nlmsg_data(nlh);
32129 struct nlattr *priority = attrs[CRYPTOCFGA_PRIORITY_VAL];
32130
32131 + if (!null_terminated(p->cru_name) || !null_terminated(p->cru_driver_name))
32132 + return -EINVAL;
32133 +
32134 if (strlen(p->cru_driver_name))
32135 exact = 1;
32136
32137 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
32138 index f220d64..d359ad6 100644
32139 --- a/drivers/acpi/apei/apei-internal.h
32140 +++ b/drivers/acpi/apei/apei-internal.h
32141 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
32142 struct apei_exec_ins_type {
32143 u32 flags;
32144 apei_exec_ins_func_t run;
32145 -};
32146 +} __do_const;
32147
32148 struct apei_exec_context {
32149 u32 ip;
32150 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
32151 index e6defd8..c26a225 100644
32152 --- a/drivers/acpi/apei/cper.c
32153 +++ b/drivers/acpi/apei/cper.c
32154 @@ -38,12 +38,12 @@
32155 */
32156 u64 cper_next_record_id(void)
32157 {
32158 - static atomic64_t seq;
32159 + static atomic64_unchecked_t seq;
32160
32161 - if (!atomic64_read(&seq))
32162 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
32163 + if (!atomic64_read_unchecked(&seq))
32164 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
32165
32166 - return atomic64_inc_return(&seq);
32167 + return atomic64_inc_return_unchecked(&seq);
32168 }
32169 EXPORT_SYMBOL_GPL(cper_next_record_id);
32170
32171 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
32172 index be60399..778b33e8 100644
32173 --- a/drivers/acpi/bgrt.c
32174 +++ b/drivers/acpi/bgrt.c
32175 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
32176 return -ENODEV;
32177
32178 sysfs_bin_attr_init(&image_attr);
32179 - image_attr.private = bgrt_image;
32180 - image_attr.size = bgrt_image_size;
32181 + pax_open_kernel();
32182 + *(void **)&image_attr.private = bgrt_image;
32183 + *(size_t *)&image_attr.size = bgrt_image_size;
32184 + pax_close_kernel();
32185
32186 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
32187 if (!bgrt_kobj)
32188 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
32189 index cb96296..b81293b 100644
32190 --- a/drivers/acpi/blacklist.c
32191 +++ b/drivers/acpi/blacklist.c
32192 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
32193 u32 is_critical_error;
32194 };
32195
32196 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
32197 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
32198
32199 /*
32200 * POLICY: If *anything* doesn't work, put it on the blacklist.
32201 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
32202 return 0;
32203 }
32204
32205 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
32206 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
32207 {
32208 .callback = dmi_disable_osi_vista,
32209 .ident = "Fujitsu Siemens",
32210 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
32211 index 7586544..636a2f0 100644
32212 --- a/drivers/acpi/ec_sys.c
32213 +++ b/drivers/acpi/ec_sys.c
32214 @@ -12,6 +12,7 @@
32215 #include <linux/acpi.h>
32216 #include <linux/debugfs.h>
32217 #include <linux/module.h>
32218 +#include <linux/uaccess.h>
32219 #include "internal.h"
32220
32221 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
32222 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32223 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
32224 */
32225 unsigned int size = EC_SPACE_SIZE;
32226 - u8 *data = (u8 *) buf;
32227 + u8 data;
32228 loff_t init_off = *off;
32229 int err = 0;
32230
32231 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
32232 size = count;
32233
32234 while (size) {
32235 - err = ec_read(*off, &data[*off - init_off]);
32236 + err = ec_read(*off, &data);
32237 if (err)
32238 return err;
32239 + if (put_user(data, &buf[*off - init_off]))
32240 + return -EFAULT;
32241 *off += 1;
32242 size--;
32243 }
32244 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32245
32246 unsigned int size = count;
32247 loff_t init_off = *off;
32248 - u8 *data = (u8 *) buf;
32249 int err = 0;
32250
32251 if (*off >= EC_SPACE_SIZE)
32252 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
32253 }
32254
32255 while (size) {
32256 - u8 byte_write = data[*off - init_off];
32257 + u8 byte_write;
32258 + if (get_user(byte_write, &buf[*off - init_off]))
32259 + return -EFAULT;
32260 err = ec_write(*off, byte_write);
32261 if (err)
32262 return err;
32263 diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
32264 index e83311b..142b5cc 100644
32265 --- a/drivers/acpi/processor_driver.c
32266 +++ b/drivers/acpi/processor_driver.c
32267 @@ -558,7 +558,7 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
32268 return 0;
32269 #endif
32270
32271 - BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0));
32272 + BUG_ON(pr->id >= nr_cpu_ids);
32273
32274 /*
32275 * Buggy BIOS check
32276 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
32277 index ed9a1cc..f4a354c 100644
32278 --- a/drivers/acpi/processor_idle.c
32279 +++ b/drivers/acpi/processor_idle.c
32280 @@ -1005,7 +1005,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
32281 {
32282 int i, count = CPUIDLE_DRIVER_STATE_START;
32283 struct acpi_processor_cx *cx;
32284 - struct cpuidle_state *state;
32285 + cpuidle_state_no_const *state;
32286 struct cpuidle_driver *drv = &acpi_idle_driver;
32287
32288 if (!pr->flags.power_setup_done)
32289 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32290 index ea61ca9..3fdd70d 100644
32291 --- a/drivers/acpi/sysfs.c
32292 +++ b/drivers/acpi/sysfs.c
32293 @@ -420,11 +420,11 @@ static u32 num_counters;
32294 static struct attribute **all_attrs;
32295 static u32 acpi_gpe_count;
32296
32297 -static struct attribute_group interrupt_stats_attr_group = {
32298 +static attribute_group_no_const interrupt_stats_attr_group = {
32299 .name = "interrupts",
32300 };
32301
32302 -static struct kobj_attribute *counter_attrs;
32303 +static kobj_attribute_no_const *counter_attrs;
32304
32305 static void delete_gpe_attr_array(void)
32306 {
32307 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32308 index 6cd7805..07facb3 100644
32309 --- a/drivers/ata/libahci.c
32310 +++ b/drivers/ata/libahci.c
32311 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32312 }
32313 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32314
32315 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32316 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32317 struct ata_taskfile *tf, int is_cmd, u16 flags,
32318 unsigned long timeout_msec)
32319 {
32320 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32321 index 501c209..5f28b4d 100644
32322 --- a/drivers/ata/libata-core.c
32323 +++ b/drivers/ata/libata-core.c
32324 @@ -4784,7 +4784,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32325 struct ata_port *ap;
32326 unsigned int tag;
32327
32328 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32329 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32330 ap = qc->ap;
32331
32332 qc->flags = 0;
32333 @@ -4800,7 +4800,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32334 struct ata_port *ap;
32335 struct ata_link *link;
32336
32337 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32338 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32339 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32340 ap = qc->ap;
32341 link = qc->dev->link;
32342 @@ -5896,6 +5896,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32343 return;
32344
32345 spin_lock(&lock);
32346 + pax_open_kernel();
32347
32348 for (cur = ops->inherits; cur; cur = cur->inherits) {
32349 void **inherit = (void **)cur;
32350 @@ -5909,8 +5910,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32351 if (IS_ERR(*pp))
32352 *pp = NULL;
32353
32354 - ops->inherits = NULL;
32355 + *(struct ata_port_operations **)&ops->inherits = NULL;
32356
32357 + pax_close_kernel();
32358 spin_unlock(&lock);
32359 }
32360
32361 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32362 index 405022d..fb70e53 100644
32363 --- a/drivers/ata/pata_arasan_cf.c
32364 +++ b/drivers/ata/pata_arasan_cf.c
32365 @@ -864,7 +864,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32366 /* Handle platform specific quirks */
32367 if (pdata->quirk) {
32368 if (pdata->quirk & CF_BROKEN_PIO) {
32369 - ap->ops->set_piomode = NULL;
32370 + pax_open_kernel();
32371 + *(void **)&ap->ops->set_piomode = NULL;
32372 + pax_close_kernel();
32373 ap->pio_mask = 0;
32374 }
32375 if (pdata->quirk & CF_BROKEN_MWDMA)
32376 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32377 index f9b983a..887b9d8 100644
32378 --- a/drivers/atm/adummy.c
32379 +++ b/drivers/atm/adummy.c
32380 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32381 vcc->pop(vcc, skb);
32382 else
32383 dev_kfree_skb_any(skb);
32384 - atomic_inc(&vcc->stats->tx);
32385 + atomic_inc_unchecked(&vcc->stats->tx);
32386
32387 return 0;
32388 }
32389 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32390 index 77a7480..05cde58 100644
32391 --- a/drivers/atm/ambassador.c
32392 +++ b/drivers/atm/ambassador.c
32393 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32394 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32395
32396 // VC layer stats
32397 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32398 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32399
32400 // free the descriptor
32401 kfree (tx_descr);
32402 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32403 dump_skb ("<<<", vc, skb);
32404
32405 // VC layer stats
32406 - atomic_inc(&atm_vcc->stats->rx);
32407 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32408 __net_timestamp(skb);
32409 // end of our responsibility
32410 atm_vcc->push (atm_vcc, skb);
32411 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32412 } else {
32413 PRINTK (KERN_INFO, "dropped over-size frame");
32414 // should we count this?
32415 - atomic_inc(&atm_vcc->stats->rx_drop);
32416 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32417 }
32418
32419 } else {
32420 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32421 }
32422
32423 if (check_area (skb->data, skb->len)) {
32424 - atomic_inc(&atm_vcc->stats->tx_err);
32425 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32426 return -ENOMEM; // ?
32427 }
32428
32429 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32430 index b22d71c..d6e1049 100644
32431 --- a/drivers/atm/atmtcp.c
32432 +++ b/drivers/atm/atmtcp.c
32433 @@ -207,7 +207,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32434 if (vcc->pop) vcc->pop(vcc,skb);
32435 else dev_kfree_skb(skb);
32436 if (dev_data) return 0;
32437 - atomic_inc(&vcc->stats->tx_err);
32438 + atomic_inc_unchecked(&vcc->stats->tx_err);
32439 return -ENOLINK;
32440 }
32441 size = skb->len+sizeof(struct atmtcp_hdr);
32442 @@ -215,7 +215,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32443 if (!new_skb) {
32444 if (vcc->pop) vcc->pop(vcc,skb);
32445 else dev_kfree_skb(skb);
32446 - atomic_inc(&vcc->stats->tx_err);
32447 + atomic_inc_unchecked(&vcc->stats->tx_err);
32448 return -ENOBUFS;
32449 }
32450 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32451 @@ -226,8 +226,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32452 if (vcc->pop) vcc->pop(vcc,skb);
32453 else dev_kfree_skb(skb);
32454 out_vcc->push(out_vcc,new_skb);
32455 - atomic_inc(&vcc->stats->tx);
32456 - atomic_inc(&out_vcc->stats->rx);
32457 + atomic_inc_unchecked(&vcc->stats->tx);
32458 + atomic_inc_unchecked(&out_vcc->stats->rx);
32459 return 0;
32460 }
32461
32462 @@ -301,7 +301,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32463 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32464 read_unlock(&vcc_sklist_lock);
32465 if (!out_vcc) {
32466 - atomic_inc(&vcc->stats->tx_err);
32467 + atomic_inc_unchecked(&vcc->stats->tx_err);
32468 goto done;
32469 }
32470 skb_pull(skb,sizeof(struct atmtcp_hdr));
32471 @@ -313,8 +313,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32472 __net_timestamp(new_skb);
32473 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32474 out_vcc->push(out_vcc,new_skb);
32475 - atomic_inc(&vcc->stats->tx);
32476 - atomic_inc(&out_vcc->stats->rx);
32477 + atomic_inc_unchecked(&vcc->stats->tx);
32478 + atomic_inc_unchecked(&out_vcc->stats->rx);
32479 done:
32480 if (vcc->pop) vcc->pop(vcc,skb);
32481 else dev_kfree_skb(skb);
32482 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32483 index c1eb6fa..4c71be9 100644
32484 --- a/drivers/atm/eni.c
32485 +++ b/drivers/atm/eni.c
32486 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32487 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32488 vcc->dev->number);
32489 length = 0;
32490 - atomic_inc(&vcc->stats->rx_err);
32491 + atomic_inc_unchecked(&vcc->stats->rx_err);
32492 }
32493 else {
32494 length = ATM_CELL_SIZE-1; /* no HEC */
32495 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32496 size);
32497 }
32498 eff = length = 0;
32499 - atomic_inc(&vcc->stats->rx_err);
32500 + atomic_inc_unchecked(&vcc->stats->rx_err);
32501 }
32502 else {
32503 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32504 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32505 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32506 vcc->dev->number,vcc->vci,length,size << 2,descr);
32507 length = eff = 0;
32508 - atomic_inc(&vcc->stats->rx_err);
32509 + atomic_inc_unchecked(&vcc->stats->rx_err);
32510 }
32511 }
32512 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32513 @@ -767,7 +767,7 @@ rx_dequeued++;
32514 vcc->push(vcc,skb);
32515 pushed++;
32516 }
32517 - atomic_inc(&vcc->stats->rx);
32518 + atomic_inc_unchecked(&vcc->stats->rx);
32519 }
32520 wake_up(&eni_dev->rx_wait);
32521 }
32522 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32523 PCI_DMA_TODEVICE);
32524 if (vcc->pop) vcc->pop(vcc,skb);
32525 else dev_kfree_skb_irq(skb);
32526 - atomic_inc(&vcc->stats->tx);
32527 + atomic_inc_unchecked(&vcc->stats->tx);
32528 wake_up(&eni_dev->tx_wait);
32529 dma_complete++;
32530 }
32531 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32532 index b41c948..a002b17 100644
32533 --- a/drivers/atm/firestream.c
32534 +++ b/drivers/atm/firestream.c
32535 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32536 }
32537 }
32538
32539 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32540 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32541
32542 fs_dprintk (FS_DEBUG_TXMEM, "i");
32543 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32544 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32545 #endif
32546 skb_put (skb, qe->p1 & 0xffff);
32547 ATM_SKB(skb)->vcc = atm_vcc;
32548 - atomic_inc(&atm_vcc->stats->rx);
32549 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32550 __net_timestamp(skb);
32551 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32552 atm_vcc->push (atm_vcc, skb);
32553 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32554 kfree (pe);
32555 }
32556 if (atm_vcc)
32557 - atomic_inc(&atm_vcc->stats->rx_drop);
32558 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32559 break;
32560 case 0x1f: /* Reassembly abort: no buffers. */
32561 /* Silently increment error counter. */
32562 if (atm_vcc)
32563 - atomic_inc(&atm_vcc->stats->rx_drop);
32564 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32565 break;
32566 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32567 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32568 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32569 index 204814e..cede831 100644
32570 --- a/drivers/atm/fore200e.c
32571 +++ b/drivers/atm/fore200e.c
32572 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32573 #endif
32574 /* check error condition */
32575 if (*entry->status & STATUS_ERROR)
32576 - atomic_inc(&vcc->stats->tx_err);
32577 + atomic_inc_unchecked(&vcc->stats->tx_err);
32578 else
32579 - atomic_inc(&vcc->stats->tx);
32580 + atomic_inc_unchecked(&vcc->stats->tx);
32581 }
32582 }
32583
32584 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32585 if (skb == NULL) {
32586 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32587
32588 - atomic_inc(&vcc->stats->rx_drop);
32589 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32590 return -ENOMEM;
32591 }
32592
32593 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32594
32595 dev_kfree_skb_any(skb);
32596
32597 - atomic_inc(&vcc->stats->rx_drop);
32598 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32599 return -ENOMEM;
32600 }
32601
32602 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32603
32604 vcc->push(vcc, skb);
32605 - atomic_inc(&vcc->stats->rx);
32606 + atomic_inc_unchecked(&vcc->stats->rx);
32607
32608 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32609
32610 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32611 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32612 fore200e->atm_dev->number,
32613 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32614 - atomic_inc(&vcc->stats->rx_err);
32615 + atomic_inc_unchecked(&vcc->stats->rx_err);
32616 }
32617 }
32618
32619 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32620 goto retry_here;
32621 }
32622
32623 - atomic_inc(&vcc->stats->tx_err);
32624 + atomic_inc_unchecked(&vcc->stats->tx_err);
32625
32626 fore200e->tx_sat++;
32627 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32628 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32629 index 72b6960..cf9167a 100644
32630 --- a/drivers/atm/he.c
32631 +++ b/drivers/atm/he.c
32632 @@ -1699,7 +1699,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32633
32634 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32635 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32636 - atomic_inc(&vcc->stats->rx_drop);
32637 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32638 goto return_host_buffers;
32639 }
32640
32641 @@ -1726,7 +1726,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32642 RBRQ_LEN_ERR(he_dev->rbrq_head)
32643 ? "LEN_ERR" : "",
32644 vcc->vpi, vcc->vci);
32645 - atomic_inc(&vcc->stats->rx_err);
32646 + atomic_inc_unchecked(&vcc->stats->rx_err);
32647 goto return_host_buffers;
32648 }
32649
32650 @@ -1778,7 +1778,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32651 vcc->push(vcc, skb);
32652 spin_lock(&he_dev->global_lock);
32653
32654 - atomic_inc(&vcc->stats->rx);
32655 + atomic_inc_unchecked(&vcc->stats->rx);
32656
32657 return_host_buffers:
32658 ++pdus_assembled;
32659 @@ -2104,7 +2104,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32660 tpd->vcc->pop(tpd->vcc, tpd->skb);
32661 else
32662 dev_kfree_skb_any(tpd->skb);
32663 - atomic_inc(&tpd->vcc->stats->tx_err);
32664 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32665 }
32666 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32667 return;
32668 @@ -2516,7 +2516,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32669 vcc->pop(vcc, skb);
32670 else
32671 dev_kfree_skb_any(skb);
32672 - atomic_inc(&vcc->stats->tx_err);
32673 + atomic_inc_unchecked(&vcc->stats->tx_err);
32674 return -EINVAL;
32675 }
32676
32677 @@ -2527,7 +2527,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32678 vcc->pop(vcc, skb);
32679 else
32680 dev_kfree_skb_any(skb);
32681 - atomic_inc(&vcc->stats->tx_err);
32682 + atomic_inc_unchecked(&vcc->stats->tx_err);
32683 return -EINVAL;
32684 }
32685 #endif
32686 @@ -2539,7 +2539,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32687 vcc->pop(vcc, skb);
32688 else
32689 dev_kfree_skb_any(skb);
32690 - atomic_inc(&vcc->stats->tx_err);
32691 + atomic_inc_unchecked(&vcc->stats->tx_err);
32692 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32693 return -ENOMEM;
32694 }
32695 @@ -2581,7 +2581,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32696 vcc->pop(vcc, skb);
32697 else
32698 dev_kfree_skb_any(skb);
32699 - atomic_inc(&vcc->stats->tx_err);
32700 + atomic_inc_unchecked(&vcc->stats->tx_err);
32701 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32702 return -ENOMEM;
32703 }
32704 @@ -2612,7 +2612,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32705 __enqueue_tpd(he_dev, tpd, cid);
32706 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32707
32708 - atomic_inc(&vcc->stats->tx);
32709 + atomic_inc_unchecked(&vcc->stats->tx);
32710
32711 return 0;
32712 }
32713 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32714 index 1dc0519..1aadaf7 100644
32715 --- a/drivers/atm/horizon.c
32716 +++ b/drivers/atm/horizon.c
32717 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32718 {
32719 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32720 // VC layer stats
32721 - atomic_inc(&vcc->stats->rx);
32722 + atomic_inc_unchecked(&vcc->stats->rx);
32723 __net_timestamp(skb);
32724 // end of our responsibility
32725 vcc->push (vcc, skb);
32726 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32727 dev->tx_iovec = NULL;
32728
32729 // VC layer stats
32730 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32731 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32732
32733 // free the skb
32734 hrz_kfree_skb (skb);
32735 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32736 index 272f009..a18ba55 100644
32737 --- a/drivers/atm/idt77252.c
32738 +++ b/drivers/atm/idt77252.c
32739 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32740 else
32741 dev_kfree_skb(skb);
32742
32743 - atomic_inc(&vcc->stats->tx);
32744 + atomic_inc_unchecked(&vcc->stats->tx);
32745 }
32746
32747 atomic_dec(&scq->used);
32748 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32749 if ((sb = dev_alloc_skb(64)) == NULL) {
32750 printk("%s: Can't allocate buffers for aal0.\n",
32751 card->name);
32752 - atomic_add(i, &vcc->stats->rx_drop);
32753 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32754 break;
32755 }
32756 if (!atm_charge(vcc, sb->truesize)) {
32757 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32758 card->name);
32759 - atomic_add(i - 1, &vcc->stats->rx_drop);
32760 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32761 dev_kfree_skb(sb);
32762 break;
32763 }
32764 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32765 ATM_SKB(sb)->vcc = vcc;
32766 __net_timestamp(sb);
32767 vcc->push(vcc, sb);
32768 - atomic_inc(&vcc->stats->rx);
32769 + atomic_inc_unchecked(&vcc->stats->rx);
32770
32771 cell += ATM_CELL_PAYLOAD;
32772 }
32773 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32774 "(CDC: %08x)\n",
32775 card->name, len, rpp->len, readl(SAR_REG_CDC));
32776 recycle_rx_pool_skb(card, rpp);
32777 - atomic_inc(&vcc->stats->rx_err);
32778 + atomic_inc_unchecked(&vcc->stats->rx_err);
32779 return;
32780 }
32781 if (stat & SAR_RSQE_CRC) {
32782 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32783 recycle_rx_pool_skb(card, rpp);
32784 - atomic_inc(&vcc->stats->rx_err);
32785 + atomic_inc_unchecked(&vcc->stats->rx_err);
32786 return;
32787 }
32788 if (skb_queue_len(&rpp->queue) > 1) {
32789 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32790 RXPRINTK("%s: Can't alloc RX skb.\n",
32791 card->name);
32792 recycle_rx_pool_skb(card, rpp);
32793 - atomic_inc(&vcc->stats->rx_err);
32794 + atomic_inc_unchecked(&vcc->stats->rx_err);
32795 return;
32796 }
32797 if (!atm_charge(vcc, skb->truesize)) {
32798 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32799 __net_timestamp(skb);
32800
32801 vcc->push(vcc, skb);
32802 - atomic_inc(&vcc->stats->rx);
32803 + atomic_inc_unchecked(&vcc->stats->rx);
32804
32805 return;
32806 }
32807 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32808 __net_timestamp(skb);
32809
32810 vcc->push(vcc, skb);
32811 - atomic_inc(&vcc->stats->rx);
32812 + atomic_inc_unchecked(&vcc->stats->rx);
32813
32814 if (skb->truesize > SAR_FB_SIZE_3)
32815 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32816 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32817 if (vcc->qos.aal != ATM_AAL0) {
32818 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32819 card->name, vpi, vci);
32820 - atomic_inc(&vcc->stats->rx_drop);
32821 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32822 goto drop;
32823 }
32824
32825 if ((sb = dev_alloc_skb(64)) == NULL) {
32826 printk("%s: Can't allocate buffers for AAL0.\n",
32827 card->name);
32828 - atomic_inc(&vcc->stats->rx_err);
32829 + atomic_inc_unchecked(&vcc->stats->rx_err);
32830 goto drop;
32831 }
32832
32833 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32834 ATM_SKB(sb)->vcc = vcc;
32835 __net_timestamp(sb);
32836 vcc->push(vcc, sb);
32837 - atomic_inc(&vcc->stats->rx);
32838 + atomic_inc_unchecked(&vcc->stats->rx);
32839
32840 drop:
32841 skb_pull(queue, 64);
32842 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32843
32844 if (vc == NULL) {
32845 printk("%s: NULL connection in send().\n", card->name);
32846 - atomic_inc(&vcc->stats->tx_err);
32847 + atomic_inc_unchecked(&vcc->stats->tx_err);
32848 dev_kfree_skb(skb);
32849 return -EINVAL;
32850 }
32851 if (!test_bit(VCF_TX, &vc->flags)) {
32852 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32853 - atomic_inc(&vcc->stats->tx_err);
32854 + atomic_inc_unchecked(&vcc->stats->tx_err);
32855 dev_kfree_skb(skb);
32856 return -EINVAL;
32857 }
32858 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32859 break;
32860 default:
32861 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32862 - atomic_inc(&vcc->stats->tx_err);
32863 + atomic_inc_unchecked(&vcc->stats->tx_err);
32864 dev_kfree_skb(skb);
32865 return -EINVAL;
32866 }
32867
32868 if (skb_shinfo(skb)->nr_frags != 0) {
32869 printk("%s: No scatter-gather yet.\n", card->name);
32870 - atomic_inc(&vcc->stats->tx_err);
32871 + atomic_inc_unchecked(&vcc->stats->tx_err);
32872 dev_kfree_skb(skb);
32873 return -EINVAL;
32874 }
32875 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32876
32877 err = queue_skb(card, vc, skb, oam);
32878 if (err) {
32879 - atomic_inc(&vcc->stats->tx_err);
32880 + atomic_inc_unchecked(&vcc->stats->tx_err);
32881 dev_kfree_skb(skb);
32882 return err;
32883 }
32884 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32885 skb = dev_alloc_skb(64);
32886 if (!skb) {
32887 printk("%s: Out of memory in send_oam().\n", card->name);
32888 - atomic_inc(&vcc->stats->tx_err);
32889 + atomic_inc_unchecked(&vcc->stats->tx_err);
32890 return -ENOMEM;
32891 }
32892 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32893 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32894 index 4217f29..88f547a 100644
32895 --- a/drivers/atm/iphase.c
32896 +++ b/drivers/atm/iphase.c
32897 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32898 status = (u_short) (buf_desc_ptr->desc_mode);
32899 if (status & (RX_CER | RX_PTE | RX_OFL))
32900 {
32901 - atomic_inc(&vcc->stats->rx_err);
32902 + atomic_inc_unchecked(&vcc->stats->rx_err);
32903 IF_ERR(printk("IA: bad packet, dropping it");)
32904 if (status & RX_CER) {
32905 IF_ERR(printk(" cause: packet CRC error\n");)
32906 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32907 len = dma_addr - buf_addr;
32908 if (len > iadev->rx_buf_sz) {
32909 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32910 - atomic_inc(&vcc->stats->rx_err);
32911 + atomic_inc_unchecked(&vcc->stats->rx_err);
32912 goto out_free_desc;
32913 }
32914
32915 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32916 ia_vcc = INPH_IA_VCC(vcc);
32917 if (ia_vcc == NULL)
32918 {
32919 - atomic_inc(&vcc->stats->rx_err);
32920 + atomic_inc_unchecked(&vcc->stats->rx_err);
32921 atm_return(vcc, skb->truesize);
32922 dev_kfree_skb_any(skb);
32923 goto INCR_DLE;
32924 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32925 if ((length > iadev->rx_buf_sz) || (length >
32926 (skb->len - sizeof(struct cpcs_trailer))))
32927 {
32928 - atomic_inc(&vcc->stats->rx_err);
32929 + atomic_inc_unchecked(&vcc->stats->rx_err);
32930 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32931 length, skb->len);)
32932 atm_return(vcc, skb->truesize);
32933 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32934
32935 IF_RX(printk("rx_dle_intr: skb push");)
32936 vcc->push(vcc,skb);
32937 - atomic_inc(&vcc->stats->rx);
32938 + atomic_inc_unchecked(&vcc->stats->rx);
32939 iadev->rx_pkt_cnt++;
32940 }
32941 INCR_DLE:
32942 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32943 {
32944 struct k_sonet_stats *stats;
32945 stats = &PRIV(_ia_dev[board])->sonet_stats;
32946 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32947 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32948 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32949 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32950 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32951 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32952 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32953 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32954 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32955 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32956 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32957 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32958 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32959 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32960 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32961 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32962 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32963 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32964 }
32965 ia_cmds.status = 0;
32966 break;
32967 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32968 if ((desc == 0) || (desc > iadev->num_tx_desc))
32969 {
32970 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32971 - atomic_inc(&vcc->stats->tx);
32972 + atomic_inc_unchecked(&vcc->stats->tx);
32973 if (vcc->pop)
32974 vcc->pop(vcc, skb);
32975 else
32976 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32977 ATM_DESC(skb) = vcc->vci;
32978 skb_queue_tail(&iadev->tx_dma_q, skb);
32979
32980 - atomic_inc(&vcc->stats->tx);
32981 + atomic_inc_unchecked(&vcc->stats->tx);
32982 iadev->tx_pkt_cnt++;
32983 /* Increment transaction counter */
32984 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32985
32986 #if 0
32987 /* add flow control logic */
32988 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32989 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32990 if (iavcc->vc_desc_cnt > 10) {
32991 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32992 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32993 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32994 index fa7d701..1e404c7 100644
32995 --- a/drivers/atm/lanai.c
32996 +++ b/drivers/atm/lanai.c
32997 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32998 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32999 lanai_endtx(lanai, lvcc);
33000 lanai_free_skb(lvcc->tx.atmvcc, skb);
33001 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
33002 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
33003 }
33004
33005 /* Try to fill the buffer - don't call unless there is backlog */
33006 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
33007 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
33008 __net_timestamp(skb);
33009 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
33010 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
33011 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
33012 out:
33013 lvcc->rx.buf.ptr = end;
33014 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
33015 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33016 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
33017 "vcc %d\n", lanai->number, (unsigned int) s, vci);
33018 lanai->stats.service_rxnotaal5++;
33019 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33020 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33021 return 0;
33022 }
33023 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
33024 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33025 int bytes;
33026 read_unlock(&vcc_sklist_lock);
33027 DPRINTK("got trashed rx pdu on vci %d\n", vci);
33028 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33029 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33030 lvcc->stats.x.aal5.service_trash++;
33031 bytes = (SERVICE_GET_END(s) * 16) -
33032 (((unsigned long) lvcc->rx.buf.ptr) -
33033 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33034 }
33035 if (s & SERVICE_STREAM) {
33036 read_unlock(&vcc_sklist_lock);
33037 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33038 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33039 lvcc->stats.x.aal5.service_stream++;
33040 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
33041 "PDU on VCI %d!\n", lanai->number, vci);
33042 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
33043 return 0;
33044 }
33045 DPRINTK("got rx crc error on vci %d\n", vci);
33046 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
33047 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
33048 lvcc->stats.x.aal5.service_rxcrc++;
33049 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
33050 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
33051 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
33052 index ed1d2b7..8cffc1f 100644
33053 --- a/drivers/atm/nicstar.c
33054 +++ b/drivers/atm/nicstar.c
33055 @@ -1654,7 +1654,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33056 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
33057 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
33058 card->index);
33059 - atomic_inc(&vcc->stats->tx_err);
33060 + atomic_inc_unchecked(&vcc->stats->tx_err);
33061 dev_kfree_skb_any(skb);
33062 return -EINVAL;
33063 }
33064 @@ -1662,7 +1662,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33065 if (!vc->tx) {
33066 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
33067 card->index);
33068 - atomic_inc(&vcc->stats->tx_err);
33069 + atomic_inc_unchecked(&vcc->stats->tx_err);
33070 dev_kfree_skb_any(skb);
33071 return -EINVAL;
33072 }
33073 @@ -1670,14 +1670,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33074 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
33075 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
33076 card->index);
33077 - atomic_inc(&vcc->stats->tx_err);
33078 + atomic_inc_unchecked(&vcc->stats->tx_err);
33079 dev_kfree_skb_any(skb);
33080 return -EINVAL;
33081 }
33082
33083 if (skb_shinfo(skb)->nr_frags != 0) {
33084 printk("nicstar%d: No scatter-gather yet.\n", card->index);
33085 - atomic_inc(&vcc->stats->tx_err);
33086 + atomic_inc_unchecked(&vcc->stats->tx_err);
33087 dev_kfree_skb_any(skb);
33088 return -EINVAL;
33089 }
33090 @@ -1725,11 +1725,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
33091 }
33092
33093 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
33094 - atomic_inc(&vcc->stats->tx_err);
33095 + atomic_inc_unchecked(&vcc->stats->tx_err);
33096 dev_kfree_skb_any(skb);
33097 return -EIO;
33098 }
33099 - atomic_inc(&vcc->stats->tx);
33100 + atomic_inc_unchecked(&vcc->stats->tx);
33101
33102 return 0;
33103 }
33104 @@ -2046,14 +2046,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33105 printk
33106 ("nicstar%d: Can't allocate buffers for aal0.\n",
33107 card->index);
33108 - atomic_add(i, &vcc->stats->rx_drop);
33109 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
33110 break;
33111 }
33112 if (!atm_charge(vcc, sb->truesize)) {
33113 RXPRINTK
33114 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
33115 card->index);
33116 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33117 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
33118 dev_kfree_skb_any(sb);
33119 break;
33120 }
33121 @@ -2068,7 +2068,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33122 ATM_SKB(sb)->vcc = vcc;
33123 __net_timestamp(sb);
33124 vcc->push(vcc, sb);
33125 - atomic_inc(&vcc->stats->rx);
33126 + atomic_inc_unchecked(&vcc->stats->rx);
33127 cell += ATM_CELL_PAYLOAD;
33128 }
33129
33130 @@ -2085,7 +2085,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33131 if (iovb == NULL) {
33132 printk("nicstar%d: Out of iovec buffers.\n",
33133 card->index);
33134 - atomic_inc(&vcc->stats->rx_drop);
33135 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33136 recycle_rx_buf(card, skb);
33137 return;
33138 }
33139 @@ -2109,7 +2109,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33140 small or large buffer itself. */
33141 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
33142 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
33143 - atomic_inc(&vcc->stats->rx_err);
33144 + atomic_inc_unchecked(&vcc->stats->rx_err);
33145 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33146 NS_MAX_IOVECS);
33147 NS_PRV_IOVCNT(iovb) = 0;
33148 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33149 ("nicstar%d: Expected a small buffer, and this is not one.\n",
33150 card->index);
33151 which_list(card, skb);
33152 - atomic_inc(&vcc->stats->rx_err);
33153 + atomic_inc_unchecked(&vcc->stats->rx_err);
33154 recycle_rx_buf(card, skb);
33155 vc->rx_iov = NULL;
33156 recycle_iov_buf(card, iovb);
33157 @@ -2142,7 +2142,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33158 ("nicstar%d: Expected a large buffer, and this is not one.\n",
33159 card->index);
33160 which_list(card, skb);
33161 - atomic_inc(&vcc->stats->rx_err);
33162 + atomic_inc_unchecked(&vcc->stats->rx_err);
33163 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33164 NS_PRV_IOVCNT(iovb));
33165 vc->rx_iov = NULL;
33166 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33167 printk(" - PDU size mismatch.\n");
33168 else
33169 printk(".\n");
33170 - atomic_inc(&vcc->stats->rx_err);
33171 + atomic_inc_unchecked(&vcc->stats->rx_err);
33172 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
33173 NS_PRV_IOVCNT(iovb));
33174 vc->rx_iov = NULL;
33175 @@ -2179,7 +2179,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33176 /* skb points to a small buffer */
33177 if (!atm_charge(vcc, skb->truesize)) {
33178 push_rxbufs(card, skb);
33179 - atomic_inc(&vcc->stats->rx_drop);
33180 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33181 } else {
33182 skb_put(skb, len);
33183 dequeue_sm_buf(card, skb);
33184 @@ -2189,7 +2189,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33185 ATM_SKB(skb)->vcc = vcc;
33186 __net_timestamp(skb);
33187 vcc->push(vcc, skb);
33188 - atomic_inc(&vcc->stats->rx);
33189 + atomic_inc_unchecked(&vcc->stats->rx);
33190 }
33191 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
33192 struct sk_buff *sb;
33193 @@ -2200,7 +2200,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33194 if (len <= NS_SMBUFSIZE) {
33195 if (!atm_charge(vcc, sb->truesize)) {
33196 push_rxbufs(card, sb);
33197 - atomic_inc(&vcc->stats->rx_drop);
33198 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33199 } else {
33200 skb_put(sb, len);
33201 dequeue_sm_buf(card, sb);
33202 @@ -2210,7 +2210,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33203 ATM_SKB(sb)->vcc = vcc;
33204 __net_timestamp(sb);
33205 vcc->push(vcc, sb);
33206 - atomic_inc(&vcc->stats->rx);
33207 + atomic_inc_unchecked(&vcc->stats->rx);
33208 }
33209
33210 push_rxbufs(card, skb);
33211 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33212
33213 if (!atm_charge(vcc, skb->truesize)) {
33214 push_rxbufs(card, skb);
33215 - atomic_inc(&vcc->stats->rx_drop);
33216 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33217 } else {
33218 dequeue_lg_buf(card, skb);
33219 #ifdef NS_USE_DESTRUCTORS
33220 @@ -2232,7 +2232,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33221 ATM_SKB(skb)->vcc = vcc;
33222 __net_timestamp(skb);
33223 vcc->push(vcc, skb);
33224 - atomic_inc(&vcc->stats->rx);
33225 + atomic_inc_unchecked(&vcc->stats->rx);
33226 }
33227
33228 push_rxbufs(card, sb);
33229 @@ -2253,7 +2253,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33230 printk
33231 ("nicstar%d: Out of huge buffers.\n",
33232 card->index);
33233 - atomic_inc(&vcc->stats->rx_drop);
33234 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33235 recycle_iovec_rx_bufs(card,
33236 (struct iovec *)
33237 iovb->data,
33238 @@ -2304,7 +2304,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33239 card->hbpool.count++;
33240 } else
33241 dev_kfree_skb_any(hb);
33242 - atomic_inc(&vcc->stats->rx_drop);
33243 + atomic_inc_unchecked(&vcc->stats->rx_drop);
33244 } else {
33245 /* Copy the small buffer to the huge buffer */
33246 sb = (struct sk_buff *)iov->iov_base;
33247 @@ -2341,7 +2341,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
33248 #endif /* NS_USE_DESTRUCTORS */
33249 __net_timestamp(hb);
33250 vcc->push(vcc, hb);
33251 - atomic_inc(&vcc->stats->rx);
33252 + atomic_inc_unchecked(&vcc->stats->rx);
33253 }
33254 }
33255
33256 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
33257 index 0474a89..06ea4a1 100644
33258 --- a/drivers/atm/solos-pci.c
33259 +++ b/drivers/atm/solos-pci.c
33260 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
33261 }
33262 atm_charge(vcc, skb->truesize);
33263 vcc->push(vcc, skb);
33264 - atomic_inc(&vcc->stats->rx);
33265 + atomic_inc_unchecked(&vcc->stats->rx);
33266 break;
33267
33268 case PKT_STATUS:
33269 @@ -1117,7 +1117,7 @@ static uint32_t fpga_tx(struct solos_card *card)
33270 vcc = SKB_CB(oldskb)->vcc;
33271
33272 if (vcc) {
33273 - atomic_inc(&vcc->stats->tx);
33274 + atomic_inc_unchecked(&vcc->stats->tx);
33275 solos_pop(vcc, oldskb);
33276 } else {
33277 dev_kfree_skb_irq(oldskb);
33278 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
33279 index 0215934..ce9f5b1 100644
33280 --- a/drivers/atm/suni.c
33281 +++ b/drivers/atm/suni.c
33282 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
33283
33284
33285 #define ADD_LIMITED(s,v) \
33286 - atomic_add((v),&stats->s); \
33287 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33288 + atomic_add_unchecked((v),&stats->s); \
33289 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33290
33291
33292 static void suni_hz(unsigned long from_timer)
33293 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33294 index 5120a96..e2572bd 100644
33295 --- a/drivers/atm/uPD98402.c
33296 +++ b/drivers/atm/uPD98402.c
33297 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33298 struct sonet_stats tmp;
33299 int error = 0;
33300
33301 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33302 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33303 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33304 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33305 if (zero && !error) {
33306 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33307
33308
33309 #define ADD_LIMITED(s,v) \
33310 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33311 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33312 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33313 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33314 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33315 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33316
33317
33318 static void stat_event(struct atm_dev *dev)
33319 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33320 if (reason & uPD98402_INT_PFM) stat_event(dev);
33321 if (reason & uPD98402_INT_PCO) {
33322 (void) GET(PCOCR); /* clear interrupt cause */
33323 - atomic_add(GET(HECCT),
33324 + atomic_add_unchecked(GET(HECCT),
33325 &PRIV(dev)->sonet_stats.uncorr_hcs);
33326 }
33327 if ((reason & uPD98402_INT_RFO) &&
33328 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33329 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33330 uPD98402_INT_LOS),PIMR); /* enable them */
33331 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33332 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33333 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33334 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33335 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33336 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33337 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33338 return 0;
33339 }
33340
33341 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33342 index 969c3c2..9b72956 100644
33343 --- a/drivers/atm/zatm.c
33344 +++ b/drivers/atm/zatm.c
33345 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33346 }
33347 if (!size) {
33348 dev_kfree_skb_irq(skb);
33349 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33350 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33351 continue;
33352 }
33353 if (!atm_charge(vcc,skb->truesize)) {
33354 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33355 skb->len = size;
33356 ATM_SKB(skb)->vcc = vcc;
33357 vcc->push(vcc,skb);
33358 - atomic_inc(&vcc->stats->rx);
33359 + atomic_inc_unchecked(&vcc->stats->rx);
33360 }
33361 zout(pos & 0xffff,MTA(mbx));
33362 #if 0 /* probably a stupid idea */
33363 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33364 skb_queue_head(&zatm_vcc->backlog,skb);
33365 break;
33366 }
33367 - atomic_inc(&vcc->stats->tx);
33368 + atomic_inc_unchecked(&vcc->stats->tx);
33369 wake_up(&zatm_vcc->tx_wait);
33370 }
33371
33372 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33373 index 6856303..0602d70 100644
33374 --- a/drivers/base/bus.c
33375 +++ b/drivers/base/bus.c
33376 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33377 return -EINVAL;
33378
33379 mutex_lock(&subsys->p->mutex);
33380 - list_add_tail(&sif->node, &subsys->p->interfaces);
33381 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33382 if (sif->add_dev) {
33383 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33384 while ((dev = subsys_dev_iter_next(&iter)))
33385 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33386 subsys = sif->subsys;
33387
33388 mutex_lock(&subsys->p->mutex);
33389 - list_del_init(&sif->node);
33390 + pax_list_del_init((struct list_head *)&sif->node);
33391 if (sif->remove_dev) {
33392 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33393 while ((dev = subsys_dev_iter_next(&iter)))
33394 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33395 index 17cf7ca..7e553e1 100644
33396 --- a/drivers/base/devtmpfs.c
33397 +++ b/drivers/base/devtmpfs.c
33398 @@ -347,7 +347,7 @@ int devtmpfs_mount(const char *mntdir)
33399 if (!thread)
33400 return 0;
33401
33402 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33403 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33404 if (err)
33405 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33406 else
33407 diff --git a/drivers/base/node.c b/drivers/base/node.c
33408 index fac124a..66bd4ab 100644
33409 --- a/drivers/base/node.c
33410 +++ b/drivers/base/node.c
33411 @@ -625,7 +625,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33412 struct node_attr {
33413 struct device_attribute attr;
33414 enum node_states state;
33415 -};
33416 +} __do_const;
33417
33418 static ssize_t show_node_state(struct device *dev,
33419 struct device_attribute *attr, char *buf)
33420 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33421 index acc3a8d..981c236 100644
33422 --- a/drivers/base/power/domain.c
33423 +++ b/drivers/base/power/domain.c
33424 @@ -1851,7 +1851,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33425 {
33426 struct cpuidle_driver *cpuidle_drv;
33427 struct gpd_cpu_data *cpu_data;
33428 - struct cpuidle_state *idle_state;
33429 + cpuidle_state_no_const *idle_state;
33430 int ret = 0;
33431
33432 if (IS_ERR_OR_NULL(genpd) || state < 0)
33433 @@ -1919,7 +1919,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33434 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33435 {
33436 struct gpd_cpu_data *cpu_data;
33437 - struct cpuidle_state *idle_state;
33438 + cpuidle_state_no_const *idle_state;
33439 int ret = 0;
33440
33441 if (IS_ERR_OR_NULL(genpd))
33442 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33443 index e6ee5e8..98ad7fc 100644
33444 --- a/drivers/base/power/wakeup.c
33445 +++ b/drivers/base/power/wakeup.c
33446 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33447 * They need to be modified together atomically, so it's better to use one
33448 * atomic variable to hold them both.
33449 */
33450 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33451 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33452
33453 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33454 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33455
33456 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33457 {
33458 - unsigned int comb = atomic_read(&combined_event_count);
33459 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33460
33461 *cnt = (comb >> IN_PROGRESS_BITS);
33462 *inpr = comb & MAX_IN_PROGRESS;
33463 @@ -389,7 +389,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33464 ws->start_prevent_time = ws->last_time;
33465
33466 /* Increment the counter of events in progress. */
33467 - cec = atomic_inc_return(&combined_event_count);
33468 + cec = atomic_inc_return_unchecked(&combined_event_count);
33469
33470 trace_wakeup_source_activate(ws->name, cec);
33471 }
33472 @@ -515,7 +515,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33473 * Increment the counter of registered wakeup events and decrement the
33474 * couter of wakeup events in progress simultaneously.
33475 */
33476 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33477 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33478 trace_wakeup_source_deactivate(ws->name, cec);
33479
33480 split_counters(&cnt, &inpr);
33481 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33482 index e8d11b6..7b1b36f 100644
33483 --- a/drivers/base/syscore.c
33484 +++ b/drivers/base/syscore.c
33485 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33486 void register_syscore_ops(struct syscore_ops *ops)
33487 {
33488 mutex_lock(&syscore_ops_lock);
33489 - list_add_tail(&ops->node, &syscore_ops_list);
33490 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33491 mutex_unlock(&syscore_ops_lock);
33492 }
33493 EXPORT_SYMBOL_GPL(register_syscore_ops);
33494 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33495 void unregister_syscore_ops(struct syscore_ops *ops)
33496 {
33497 mutex_lock(&syscore_ops_lock);
33498 - list_del(&ops->node);
33499 + pax_list_del((struct list_head *)&ops->node);
33500 mutex_unlock(&syscore_ops_lock);
33501 }
33502 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33503 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33504 index ade58bc..867143d 100644
33505 --- a/drivers/block/cciss.c
33506 +++ b/drivers/block/cciss.c
33507 @@ -1196,6 +1196,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33508 int err;
33509 u32 cp;
33510
33511 + memset(&arg64, 0, sizeof(arg64));
33512 +
33513 err = 0;
33514 err |=
33515 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33516 @@ -3005,7 +3007,7 @@ static void start_io(ctlr_info_t *h)
33517 while (!list_empty(&h->reqQ)) {
33518 c = list_entry(h->reqQ.next, CommandList_struct, list);
33519 /* can't do anything if fifo is full */
33520 - if ((h->access.fifo_full(h))) {
33521 + if ((h->access->fifo_full(h))) {
33522 dev_warn(&h->pdev->dev, "fifo full\n");
33523 break;
33524 }
33525 @@ -3015,7 +3017,7 @@ static void start_io(ctlr_info_t *h)
33526 h->Qdepth--;
33527
33528 /* Tell the controller execute command */
33529 - h->access.submit_command(h, c);
33530 + h->access->submit_command(h, c);
33531
33532 /* Put job onto the completed Q */
33533 addQ(&h->cmpQ, c);
33534 @@ -3441,17 +3443,17 @@ startio:
33535
33536 static inline unsigned long get_next_completion(ctlr_info_t *h)
33537 {
33538 - return h->access.command_completed(h);
33539 + return h->access->command_completed(h);
33540 }
33541
33542 static inline int interrupt_pending(ctlr_info_t *h)
33543 {
33544 - return h->access.intr_pending(h);
33545 + return h->access->intr_pending(h);
33546 }
33547
33548 static inline long interrupt_not_for_us(ctlr_info_t *h)
33549 {
33550 - return ((h->access.intr_pending(h) == 0) ||
33551 + return ((h->access->intr_pending(h) == 0) ||
33552 (h->interrupts_enabled == 0));
33553 }
33554
33555 @@ -3484,7 +3486,7 @@ static inline u32 next_command(ctlr_info_t *h)
33556 u32 a;
33557
33558 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33559 - return h->access.command_completed(h);
33560 + return h->access->command_completed(h);
33561
33562 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33563 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33564 @@ -4041,7 +4043,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33565 trans_support & CFGTBL_Trans_use_short_tags);
33566
33567 /* Change the access methods to the performant access methods */
33568 - h->access = SA5_performant_access;
33569 + h->access = &SA5_performant_access;
33570 h->transMethod = CFGTBL_Trans_Performant;
33571
33572 return;
33573 @@ -4310,7 +4312,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33574 if (prod_index < 0)
33575 return -ENODEV;
33576 h->product_name = products[prod_index].product_name;
33577 - h->access = *(products[prod_index].access);
33578 + h->access = products[prod_index].access;
33579
33580 if (cciss_board_disabled(h)) {
33581 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33582 @@ -5032,7 +5034,7 @@ reinit_after_soft_reset:
33583 }
33584
33585 /* make sure the board interrupts are off */
33586 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33587 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33588 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33589 if (rc)
33590 goto clean2;
33591 @@ -5082,7 +5084,7 @@ reinit_after_soft_reset:
33592 * fake ones to scoop up any residual completions.
33593 */
33594 spin_lock_irqsave(&h->lock, flags);
33595 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33596 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33597 spin_unlock_irqrestore(&h->lock, flags);
33598 free_irq(h->intr[h->intr_mode], h);
33599 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33600 @@ -5102,9 +5104,9 @@ reinit_after_soft_reset:
33601 dev_info(&h->pdev->dev, "Board READY.\n");
33602 dev_info(&h->pdev->dev,
33603 "Waiting for stale completions to drain.\n");
33604 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33605 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33606 msleep(10000);
33607 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33608 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33609
33610 rc = controller_reset_failed(h->cfgtable);
33611 if (rc)
33612 @@ -5127,7 +5129,7 @@ reinit_after_soft_reset:
33613 cciss_scsi_setup(h);
33614
33615 /* Turn the interrupts on so we can service requests */
33616 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33617 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33618
33619 /* Get the firmware version */
33620 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33621 @@ -5199,7 +5201,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33622 kfree(flush_buf);
33623 if (return_code != IO_OK)
33624 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33625 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33626 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33627 free_irq(h->intr[h->intr_mode], h);
33628 }
33629
33630 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33631 index 7fda30e..eb5dfe0 100644
33632 --- a/drivers/block/cciss.h
33633 +++ b/drivers/block/cciss.h
33634 @@ -101,7 +101,7 @@ struct ctlr_info
33635 /* information about each logical volume */
33636 drive_info_struct *drv[CISS_MAX_LUN];
33637
33638 - struct access_method access;
33639 + struct access_method *access;
33640
33641 /* queue and queue Info */
33642 struct list_head reqQ;
33643 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33644 index 3f08713..56a586a 100644
33645 --- a/drivers/block/cpqarray.c
33646 +++ b/drivers/block/cpqarray.c
33647 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33648 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33649 goto Enomem4;
33650 }
33651 - hba[i]->access.set_intr_mask(hba[i], 0);
33652 + hba[i]->access->set_intr_mask(hba[i], 0);
33653 if (request_irq(hba[i]->intr, do_ida_intr,
33654 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33655 {
33656 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33657 add_timer(&hba[i]->timer);
33658
33659 /* Enable IRQ now that spinlock and rate limit timer are set up */
33660 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33661 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33662
33663 for(j=0; j<NWD; j++) {
33664 struct gendisk *disk = ida_gendisk[i][j];
33665 @@ -694,7 +694,7 @@ DBGINFO(
33666 for(i=0; i<NR_PRODUCTS; i++) {
33667 if (board_id == products[i].board_id) {
33668 c->product_name = products[i].product_name;
33669 - c->access = *(products[i].access);
33670 + c->access = products[i].access;
33671 break;
33672 }
33673 }
33674 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33675 hba[ctlr]->intr = intr;
33676 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33677 hba[ctlr]->product_name = products[j].product_name;
33678 - hba[ctlr]->access = *(products[j].access);
33679 + hba[ctlr]->access = products[j].access;
33680 hba[ctlr]->ctlr = ctlr;
33681 hba[ctlr]->board_id = board_id;
33682 hba[ctlr]->pci_dev = NULL; /* not PCI */
33683 @@ -980,7 +980,7 @@ static void start_io(ctlr_info_t *h)
33684
33685 while((c = h->reqQ) != NULL) {
33686 /* Can't do anything if we're busy */
33687 - if (h->access.fifo_full(h) == 0)
33688 + if (h->access->fifo_full(h) == 0)
33689 return;
33690
33691 /* Get the first entry from the request Q */
33692 @@ -988,7 +988,7 @@ static void start_io(ctlr_info_t *h)
33693 h->Qdepth--;
33694
33695 /* Tell the controller to do our bidding */
33696 - h->access.submit_command(h, c);
33697 + h->access->submit_command(h, c);
33698
33699 /* Get onto the completion Q */
33700 addQ(&h->cmpQ, c);
33701 @@ -1050,7 +1050,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33702 unsigned long flags;
33703 __u32 a,a1;
33704
33705 - istat = h->access.intr_pending(h);
33706 + istat = h->access->intr_pending(h);
33707 /* Is this interrupt for us? */
33708 if (istat == 0)
33709 return IRQ_NONE;
33710 @@ -1061,7 +1061,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33711 */
33712 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33713 if (istat & FIFO_NOT_EMPTY) {
33714 - while((a = h->access.command_completed(h))) {
33715 + while((a = h->access->command_completed(h))) {
33716 a1 = a; a &= ~3;
33717 if ((c = h->cmpQ) == NULL)
33718 {
33719 @@ -1449,11 +1449,11 @@ static int sendcmd(
33720 /*
33721 * Disable interrupt
33722 */
33723 - info_p->access.set_intr_mask(info_p, 0);
33724 + info_p->access->set_intr_mask(info_p, 0);
33725 /* Make sure there is room in the command FIFO */
33726 /* Actually it should be completely empty at this time. */
33727 for (i = 200000; i > 0; i--) {
33728 - temp = info_p->access.fifo_full(info_p);
33729 + temp = info_p->access->fifo_full(info_p);
33730 if (temp != 0) {
33731 break;
33732 }
33733 @@ -1466,7 +1466,7 @@ DBG(
33734 /*
33735 * Send the cmd
33736 */
33737 - info_p->access.submit_command(info_p, c);
33738 + info_p->access->submit_command(info_p, c);
33739 complete = pollcomplete(ctlr);
33740
33741 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33742 @@ -1549,9 +1549,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33743 * we check the new geometry. Then turn interrupts back on when
33744 * we're done.
33745 */
33746 - host->access.set_intr_mask(host, 0);
33747 + host->access->set_intr_mask(host, 0);
33748 getgeometry(ctlr);
33749 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33750 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33751
33752 for(i=0; i<NWD; i++) {
33753 struct gendisk *disk = ida_gendisk[ctlr][i];
33754 @@ -1591,7 +1591,7 @@ static int pollcomplete(int ctlr)
33755 /* Wait (up to 2 seconds) for a command to complete */
33756
33757 for (i = 200000; i > 0; i--) {
33758 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33759 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33760 if (done == 0) {
33761 udelay(10); /* a short fixed delay */
33762 } else
33763 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33764 index be73e9d..7fbf140 100644
33765 --- a/drivers/block/cpqarray.h
33766 +++ b/drivers/block/cpqarray.h
33767 @@ -99,7 +99,7 @@ struct ctlr_info {
33768 drv_info_t drv[NWD];
33769 struct proc_dir_entry *proc;
33770
33771 - struct access_method access;
33772 + struct access_method *access;
33773
33774 cmdlist_t *reqQ;
33775 cmdlist_t *cmpQ;
33776 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33777 index 6b51afa..17e1191 100644
33778 --- a/drivers/block/drbd/drbd_int.h
33779 +++ b/drivers/block/drbd/drbd_int.h
33780 @@ -582,7 +582,7 @@ struct drbd_epoch {
33781 struct drbd_tconn *tconn;
33782 struct list_head list;
33783 unsigned int barrier_nr;
33784 - atomic_t epoch_size; /* increased on every request added. */
33785 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33786 atomic_t active; /* increased on every req. added, and dec on every finished. */
33787 unsigned long flags;
33788 };
33789 @@ -1011,7 +1011,7 @@ struct drbd_conf {
33790 int al_tr_cycle;
33791 int al_tr_pos; /* position of the next transaction in the journal */
33792 wait_queue_head_t seq_wait;
33793 - atomic_t packet_seq;
33794 + atomic_unchecked_t packet_seq;
33795 unsigned int peer_seq;
33796 spinlock_t peer_seq_lock;
33797 unsigned int minor;
33798 @@ -1527,7 +1527,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33799 char __user *uoptval;
33800 int err;
33801
33802 - uoptval = (char __user __force *)optval;
33803 + uoptval = (char __force_user *)optval;
33804
33805 set_fs(KERNEL_DS);
33806 if (level == SOL_SOCKET)
33807 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33808 index 8c13eeb..217adee 100644
33809 --- a/drivers/block/drbd/drbd_main.c
33810 +++ b/drivers/block/drbd/drbd_main.c
33811 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33812 p->sector = sector;
33813 p->block_id = block_id;
33814 p->blksize = blksize;
33815 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33816 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33817 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33818 }
33819
33820 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33821 return -EIO;
33822 p->sector = cpu_to_be64(req->i.sector);
33823 p->block_id = (unsigned long)req;
33824 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33825 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33826 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33827 if (mdev->state.conn >= C_SYNC_SOURCE &&
33828 mdev->state.conn <= C_PAUSED_SYNC_T)
33829 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33830 {
33831 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33832
33833 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33834 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33835 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33836 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33837 kfree(tconn->current_epoch);
33838
33839 idr_destroy(&tconn->volumes);
33840 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33841 index a9eccfc..f5efe87 100644
33842 --- a/drivers/block/drbd/drbd_receiver.c
33843 +++ b/drivers/block/drbd/drbd_receiver.c
33844 @@ -833,7 +833,7 @@ int drbd_connected(struct drbd_conf *mdev)
33845 {
33846 int err;
33847
33848 - atomic_set(&mdev->packet_seq, 0);
33849 + atomic_set_unchecked(&mdev->packet_seq, 0);
33850 mdev->peer_seq = 0;
33851
33852 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33853 @@ -1191,7 +1191,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33854 do {
33855 next_epoch = NULL;
33856
33857 - epoch_size = atomic_read(&epoch->epoch_size);
33858 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33859
33860 switch (ev & ~EV_CLEANUP) {
33861 case EV_PUT:
33862 @@ -1231,7 +1231,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33863 rv = FE_DESTROYED;
33864 } else {
33865 epoch->flags = 0;
33866 - atomic_set(&epoch->epoch_size, 0);
33867 + atomic_set_unchecked(&epoch->epoch_size, 0);
33868 /* atomic_set(&epoch->active, 0); is already zero */
33869 if (rv == FE_STILL_LIVE)
33870 rv = FE_RECYCLED;
33871 @@ -1449,7 +1449,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33872 conn_wait_active_ee_empty(tconn);
33873 drbd_flush(tconn);
33874
33875 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33876 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33877 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33878 if (epoch)
33879 break;
33880 @@ -1462,11 +1462,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33881 }
33882
33883 epoch->flags = 0;
33884 - atomic_set(&epoch->epoch_size, 0);
33885 + atomic_set_unchecked(&epoch->epoch_size, 0);
33886 atomic_set(&epoch->active, 0);
33887
33888 spin_lock(&tconn->epoch_lock);
33889 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33890 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33891 list_add(&epoch->list, &tconn->current_epoch->list);
33892 tconn->current_epoch = epoch;
33893 tconn->epochs++;
33894 @@ -2170,7 +2170,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33895
33896 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33897 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33898 - atomic_inc(&tconn->current_epoch->epoch_size);
33899 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33900 err2 = drbd_drain_block(mdev, pi->size);
33901 if (!err)
33902 err = err2;
33903 @@ -2204,7 +2204,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33904
33905 spin_lock(&tconn->epoch_lock);
33906 peer_req->epoch = tconn->current_epoch;
33907 - atomic_inc(&peer_req->epoch->epoch_size);
33908 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33909 atomic_inc(&peer_req->epoch->active);
33910 spin_unlock(&tconn->epoch_lock);
33911
33912 @@ -4346,7 +4346,7 @@ struct data_cmd {
33913 int expect_payload;
33914 size_t pkt_size;
33915 int (*fn)(struct drbd_tconn *, struct packet_info *);
33916 -};
33917 +} __do_const;
33918
33919 static struct data_cmd drbd_cmd_handler[] = {
33920 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33921 @@ -4466,7 +4466,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33922 if (!list_empty(&tconn->current_epoch->list))
33923 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33924 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33925 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33926 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33927 tconn->send.seen_any_write_yet = false;
33928
33929 conn_info(tconn, "Connection closed\n");
33930 @@ -5222,7 +5222,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33931 struct asender_cmd {
33932 size_t pkt_size;
33933 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33934 -};
33935 +} __do_const;
33936
33937 static struct asender_cmd asender_tbl[] = {
33938 [P_PING] = { 0, got_Ping },
33939 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33940 index f74f2c0..bb668af 100644
33941 --- a/drivers/block/loop.c
33942 +++ b/drivers/block/loop.c
33943 @@ -226,7 +226,7 @@ static int __do_lo_send_write(struct file *file,
33944 mm_segment_t old_fs = get_fs();
33945
33946 set_fs(get_ds());
33947 - bw = file->f_op->write(file, buf, len, &pos);
33948 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33949 set_fs(old_fs);
33950 if (likely(bw == len))
33951 return 0;
33952 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33953 index d620b44..587561e 100644
33954 --- a/drivers/cdrom/cdrom.c
33955 +++ b/drivers/cdrom/cdrom.c
33956 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33957 ENSURE(reset, CDC_RESET);
33958 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33959 cdi->mc_flags = 0;
33960 - cdo->n_minors = 0;
33961 cdi->options = CDO_USE_FFLAGS;
33962
33963 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33964 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33965 else
33966 cdi->cdda_method = CDDA_OLD;
33967
33968 - if (!cdo->generic_packet)
33969 - cdo->generic_packet = cdrom_dummy_generic_packet;
33970 + if (!cdo->generic_packet) {
33971 + pax_open_kernel();
33972 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33973 + pax_close_kernel();
33974 + }
33975
33976 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33977 mutex_lock(&cdrom_mutex);
33978 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33979 if (cdi->exit)
33980 cdi->exit(cdi);
33981
33982 - cdi->ops->n_minors--;
33983 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33984 }
33985
33986 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33987 index d59cdcb..11afddf 100644
33988 --- a/drivers/cdrom/gdrom.c
33989 +++ b/drivers/cdrom/gdrom.c
33990 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33991 .audio_ioctl = gdrom_audio_ioctl,
33992 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33993 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33994 - .n_minors = 1,
33995 };
33996
33997 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33998 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33999 index 72bedad..8181ce1 100644
34000 --- a/drivers/char/Kconfig
34001 +++ b/drivers/char/Kconfig
34002 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
34003
34004 config DEVKMEM
34005 bool "/dev/kmem virtual device support"
34006 - default y
34007 + default n
34008 + depends on !GRKERNSEC_KMEM
34009 help
34010 Say Y here if you want to support the /dev/kmem device. The
34011 /dev/kmem device is rarely used, but can be used for certain
34012 @@ -581,6 +582,7 @@ config DEVPORT
34013 bool
34014 depends on !M68K
34015 depends on ISA || PCI
34016 + depends on !GRKERNSEC_KMEM
34017 default y
34018
34019 source "drivers/s390/char/Kconfig"
34020 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
34021 index 2e04433..22afc64 100644
34022 --- a/drivers/char/agp/frontend.c
34023 +++ b/drivers/char/agp/frontend.c
34024 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
34025 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
34026 return -EFAULT;
34027
34028 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
34029 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
34030 return -EFAULT;
34031
34032 client = agp_find_client_by_pid(reserve.pid);
34033 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
34034 index 21cb980..f15107c 100644
34035 --- a/drivers/char/genrtc.c
34036 +++ b/drivers/char/genrtc.c
34037 @@ -272,6 +272,7 @@ static int gen_rtc_ioctl(struct file *file,
34038 switch (cmd) {
34039
34040 case RTC_PLL_GET:
34041 + memset(&pll, 0, sizeof(pll));
34042 if (get_rtc_pll(&pll))
34043 return -EINVAL;
34044 else
34045 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
34046 index fe6d4be..89f32100 100644
34047 --- a/drivers/char/hpet.c
34048 +++ b/drivers/char/hpet.c
34049 @@ -571,7 +571,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
34050 }
34051
34052 static int
34053 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
34054 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
34055 struct hpet_info *info)
34056 {
34057 struct hpet_timer __iomem *timer;
34058 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
34059 index 053201b0..8335cce 100644
34060 --- a/drivers/char/ipmi/ipmi_msghandler.c
34061 +++ b/drivers/char/ipmi/ipmi_msghandler.c
34062 @@ -420,7 +420,7 @@ struct ipmi_smi {
34063 struct proc_dir_entry *proc_dir;
34064 char proc_dir_name[10];
34065
34066 - atomic_t stats[IPMI_NUM_STATS];
34067 + atomic_unchecked_t stats[IPMI_NUM_STATS];
34068
34069 /*
34070 * run_to_completion duplicate of smb_info, smi_info
34071 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
34072
34073
34074 #define ipmi_inc_stat(intf, stat) \
34075 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
34076 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
34077 #define ipmi_get_stat(intf, stat) \
34078 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
34079 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
34080
34081 static int is_lan_addr(struct ipmi_addr *addr)
34082 {
34083 @@ -2884,7 +2884,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
34084 INIT_LIST_HEAD(&intf->cmd_rcvrs);
34085 init_waitqueue_head(&intf->waitq);
34086 for (i = 0; i < IPMI_NUM_STATS; i++)
34087 - atomic_set(&intf->stats[i], 0);
34088 + atomic_set_unchecked(&intf->stats[i], 0);
34089
34090 intf->proc_dir = NULL;
34091
34092 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
34093 index 1c7fdcd..4899100 100644
34094 --- a/drivers/char/ipmi/ipmi_si_intf.c
34095 +++ b/drivers/char/ipmi/ipmi_si_intf.c
34096 @@ -275,7 +275,7 @@ struct smi_info {
34097 unsigned char slave_addr;
34098
34099 /* Counters and things for the proc filesystem. */
34100 - atomic_t stats[SI_NUM_STATS];
34101 + atomic_unchecked_t stats[SI_NUM_STATS];
34102
34103 struct task_struct *thread;
34104
34105 @@ -284,9 +284,9 @@ struct smi_info {
34106 };
34107
34108 #define smi_inc_stat(smi, stat) \
34109 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
34110 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
34111 #define smi_get_stat(smi, stat) \
34112 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
34113 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
34114
34115 #define SI_MAX_PARMS 4
34116
34117 @@ -3225,7 +3225,7 @@ static int try_smi_init(struct smi_info *new_smi)
34118 atomic_set(&new_smi->req_events, 0);
34119 new_smi->run_to_completion = 0;
34120 for (i = 0; i < SI_NUM_STATS; i++)
34121 - atomic_set(&new_smi->stats[i], 0);
34122 + atomic_set_unchecked(&new_smi->stats[i], 0);
34123
34124 new_smi->interrupt_disabled = 1;
34125 atomic_set(&new_smi->stop_operation, 0);
34126 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
34127 index c6fa3bc..4ca3e42 100644
34128 --- a/drivers/char/mem.c
34129 +++ b/drivers/char/mem.c
34130 @@ -18,6 +18,7 @@
34131 #include <linux/raw.h>
34132 #include <linux/tty.h>
34133 #include <linux/capability.h>
34134 +#include <linux/security.h>
34135 #include <linux/ptrace.h>
34136 #include <linux/device.h>
34137 #include <linux/highmem.h>
34138 @@ -37,6 +38,10 @@
34139
34140 #define DEVPORT_MINOR 4
34141
34142 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34143 +extern const struct file_operations grsec_fops;
34144 +#endif
34145 +
34146 static inline unsigned long size_inside_page(unsigned long start,
34147 unsigned long size)
34148 {
34149 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34150
34151 while (cursor < to) {
34152 if (!devmem_is_allowed(pfn)) {
34153 +#ifdef CONFIG_GRKERNSEC_KMEM
34154 + gr_handle_mem_readwrite(from, to);
34155 +#else
34156 printk(KERN_INFO
34157 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34158 current->comm, from, to);
34159 +#endif
34160 return 0;
34161 }
34162 cursor += PAGE_SIZE;
34163 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34164 }
34165 return 1;
34166 }
34167 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34168 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34169 +{
34170 + return 0;
34171 +}
34172 #else
34173 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34174 {
34175 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34176
34177 while (count > 0) {
34178 unsigned long remaining;
34179 + char *temp;
34180
34181 sz = size_inside_page(p, count);
34182
34183 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34184 if (!ptr)
34185 return -EFAULT;
34186
34187 - remaining = copy_to_user(buf, ptr, sz);
34188 +#ifdef CONFIG_PAX_USERCOPY
34189 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34190 + if (!temp) {
34191 + unxlate_dev_mem_ptr(p, ptr);
34192 + return -ENOMEM;
34193 + }
34194 + memcpy(temp, ptr, sz);
34195 +#else
34196 + temp = ptr;
34197 +#endif
34198 +
34199 + remaining = copy_to_user(buf, temp, sz);
34200 +
34201 +#ifdef CONFIG_PAX_USERCOPY
34202 + kfree(temp);
34203 +#endif
34204 +
34205 unxlate_dev_mem_ptr(p, ptr);
34206 if (remaining)
34207 return -EFAULT;
34208 @@ -398,9 +429,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34209 size_t count, loff_t *ppos)
34210 {
34211 unsigned long p = *ppos;
34212 - ssize_t low_count, read, sz;
34213 + ssize_t low_count, read, sz, err = 0;
34214 char * kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34215 - int err = 0;
34216
34217 read = 0;
34218 if (p < (unsigned long) high_memory) {
34219 @@ -422,6 +452,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34220 }
34221 #endif
34222 while (low_count > 0) {
34223 + char *temp;
34224 +
34225 sz = size_inside_page(p, low_count);
34226
34227 /*
34228 @@ -431,7 +463,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34229 */
34230 kbuf = xlate_dev_kmem_ptr((char *)p);
34231
34232 - if (copy_to_user(buf, kbuf, sz))
34233 +#ifdef CONFIG_PAX_USERCOPY
34234 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34235 + if (!temp)
34236 + return -ENOMEM;
34237 + memcpy(temp, kbuf, sz);
34238 +#else
34239 + temp = kbuf;
34240 +#endif
34241 +
34242 + err = copy_to_user(buf, temp, sz);
34243 +
34244 +#ifdef CONFIG_PAX_USERCOPY
34245 + kfree(temp);
34246 +#endif
34247 +
34248 + if (err)
34249 return -EFAULT;
34250 buf += sz;
34251 p += sz;
34252 @@ -833,6 +880,9 @@ static const struct memdev {
34253 #ifdef CONFIG_CRASH_DUMP
34254 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34255 #endif
34256 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34257 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34258 +#endif
34259 };
34260
34261 static int memory_open(struct inode *inode, struct file *filp)
34262 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34263 index 9df78e2..01ba9ae 100644
34264 --- a/drivers/char/nvram.c
34265 +++ b/drivers/char/nvram.c
34266 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34267
34268 spin_unlock_irq(&rtc_lock);
34269
34270 - if (copy_to_user(buf, contents, tmp - contents))
34271 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34272 return -EFAULT;
34273
34274 *ppos = i;
34275 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34276 index b66eaa0..2619d1b 100644
34277 --- a/drivers/char/pcmcia/synclink_cs.c
34278 +++ b/drivers/char/pcmcia/synclink_cs.c
34279 @@ -2348,9 +2348,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34280
34281 if (debug_level >= DEBUG_LEVEL_INFO)
34282 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34283 - __FILE__,__LINE__, info->device_name, port->count);
34284 + __FILE__,__LINE__, info->device_name, atomic_read(&port->count));
34285
34286 - WARN_ON(!port->count);
34287 + WARN_ON(!atomic_read(&port->count));
34288
34289 if (tty_port_close_start(port, tty, filp) == 0)
34290 goto cleanup;
34291 @@ -2368,7 +2368,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34292 cleanup:
34293 if (debug_level >= DEBUG_LEVEL_INFO)
34294 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__,
34295 - tty->driver->name, port->count);
34296 + tty->driver->name, atomic_read(&port->count));
34297 }
34298
34299 /* Wait until the transmitter is empty.
34300 @@ -2510,7 +2510,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34301
34302 if (debug_level >= DEBUG_LEVEL_INFO)
34303 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34304 - __FILE__,__LINE__,tty->driver->name, port->count);
34305 + __FILE__,__LINE__,tty->driver->name, atomic_read(&port->count));
34306
34307 /* If port is closing, signal caller to try again */
34308 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34309 @@ -2530,11 +2530,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34310 goto cleanup;
34311 }
34312 spin_lock(&port->lock);
34313 - port->count++;
34314 + atomic_inc(&port->count);
34315 spin_unlock(&port->lock);
34316 spin_unlock_irqrestore(&info->netlock, flags);
34317
34318 - if (port->count == 1) {
34319 + if (atomic_read(&port->count) == 1) {
34320 /* 1st open on this device, init hardware */
34321 retval = startup(info, tty);
34322 if (retval < 0)
34323 @@ -3889,7 +3889,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34324 unsigned short new_crctype;
34325
34326 /* return error if TTY interface open */
34327 - if (info->port.count)
34328 + if (atomic_read(&info->port.count))
34329 return -EBUSY;
34330
34331 switch (encoding)
34332 @@ -3992,7 +3992,7 @@ static int hdlcdev_open(struct net_device *dev)
34333
34334 /* arbitrate between network and tty opens */
34335 spin_lock_irqsave(&info->netlock, flags);
34336 - if (info->port.count != 0 || info->netcount != 0) {
34337 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34338 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34339 spin_unlock_irqrestore(&info->netlock, flags);
34340 return -EBUSY;
34341 @@ -4081,7 +4081,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34342 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
34343
34344 /* return error if TTY interface open */
34345 - if (info->port.count)
34346 + if (atomic_read(&info->port.count))
34347 return -EBUSY;
34348
34349 if (cmd != SIOCWANDEV)
34350 diff --git a/drivers/char/random.c b/drivers/char/random.c
34351 index 57d4b15..253207b 100644
34352 --- a/drivers/char/random.c
34353 +++ b/drivers/char/random.c
34354 @@ -272,8 +272,13 @@
34355 /*
34356 * Configuration information
34357 */
34358 +#ifdef CONFIG_GRKERNSEC_RANDNET
34359 +#define INPUT_POOL_WORDS 512
34360 +#define OUTPUT_POOL_WORDS 128
34361 +#else
34362 #define INPUT_POOL_WORDS 128
34363 #define OUTPUT_POOL_WORDS 32
34364 +#endif
34365 #define SEC_XFER_SIZE 512
34366 #define EXTRACT_SIZE 10
34367
34368 @@ -313,10 +318,17 @@ static struct poolinfo {
34369 int poolwords;
34370 int tap1, tap2, tap3, tap4, tap5;
34371 } poolinfo_table[] = {
34372 +#ifdef CONFIG_GRKERNSEC_RANDNET
34373 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34374 + { 512, 411, 308, 208, 104, 1 },
34375 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34376 + { 128, 103, 76, 51, 25, 1 },
34377 +#else
34378 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34379 { 128, 103, 76, 51, 25, 1 },
34380 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34381 { 32, 26, 20, 14, 7, 1 },
34382 +#endif
34383 #if 0
34384 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34385 { 2048, 1638, 1231, 819, 411, 1 },
34386 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34387 input_rotate += i ? 7 : 14;
34388 }
34389
34390 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34391 - ACCESS_ONCE(r->add_ptr) = i;
34392 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34393 + ACCESS_ONCE_RW(r->add_ptr) = i;
34394 smp_wmb();
34395
34396 if (out)
34397 @@ -1024,7 +1036,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34398
34399 extract_buf(r, tmp);
34400 i = min_t(int, nbytes, EXTRACT_SIZE);
34401 - if (copy_to_user(buf, tmp, i)) {
34402 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34403 ret = -EFAULT;
34404 break;
34405 }
34406 @@ -1360,7 +1372,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34407 #include <linux/sysctl.h>
34408
34409 static int min_read_thresh = 8, min_write_thresh;
34410 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34411 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34412 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34413 static char sysctl_bootid[16];
34414
34415 @@ -1376,7 +1388,7 @@ static char sysctl_bootid[16];
34416 static int proc_do_uuid(ctl_table *table, int write,
34417 void __user *buffer, size_t *lenp, loff_t *ppos)
34418 {
34419 - ctl_table fake_table;
34420 + ctl_table_no_const fake_table;
34421 unsigned char buf[64], tmp_uuid[16], *uuid;
34422
34423 uuid = table->data;
34424 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34425 index d780295..b29f3a8 100644
34426 --- a/drivers/char/sonypi.c
34427 +++ b/drivers/char/sonypi.c
34428 @@ -54,6 +54,7 @@
34429
34430 #include <asm/uaccess.h>
34431 #include <asm/io.h>
34432 +#include <asm/local.h>
34433
34434 #include <linux/sonypi.h>
34435
34436 @@ -490,7 +491,7 @@ static struct sonypi_device {
34437 spinlock_t fifo_lock;
34438 wait_queue_head_t fifo_proc_list;
34439 struct fasync_struct *fifo_async;
34440 - int open_count;
34441 + local_t open_count;
34442 int model;
34443 struct input_dev *input_jog_dev;
34444 struct input_dev *input_key_dev;
34445 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34446 static int sonypi_misc_release(struct inode *inode, struct file *file)
34447 {
34448 mutex_lock(&sonypi_device.lock);
34449 - sonypi_device.open_count--;
34450 + local_dec(&sonypi_device.open_count);
34451 mutex_unlock(&sonypi_device.lock);
34452 return 0;
34453 }
34454 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34455 {
34456 mutex_lock(&sonypi_device.lock);
34457 /* Flush input queue on first open */
34458 - if (!sonypi_device.open_count)
34459 + if (!local_read(&sonypi_device.open_count))
34460 kfifo_reset(&sonypi_device.fifo);
34461 - sonypi_device.open_count++;
34462 + local_inc(&sonypi_device.open_count);
34463 mutex_unlock(&sonypi_device.lock);
34464
34465 return 0;
34466 diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
34467 index 93211df..c7805f7 100644
34468 --- a/drivers/char/tpm/tpm.c
34469 +++ b/drivers/char/tpm/tpm.c
34470 @@ -410,7 +410,7 @@ static ssize_t tpm_transmit(struct tpm_chip *chip, const char *buf,
34471 chip->vendor.req_complete_val)
34472 goto out_recv;
34473
34474 - if ((status == chip->vendor.req_canceled)) {
34475 + if (status == chip->vendor.req_canceled) {
34476 dev_err(chip->dev, "Operation Canceled\n");
34477 rc = -ECANCELED;
34478 goto out;
34479 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34480 index 56051d0..11cf3b7 100644
34481 --- a/drivers/char/tpm/tpm_acpi.c
34482 +++ b/drivers/char/tpm/tpm_acpi.c
34483 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34484 virt = acpi_os_map_memory(start, len);
34485 if (!virt) {
34486 kfree(log->bios_event_log);
34487 + log->bios_event_log = NULL;
34488 printk("%s: ERROR - Unable to map memory\n", __func__);
34489 return -EIO;
34490 }
34491
34492 - memcpy_fromio(log->bios_event_log, virt, len);
34493 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34494
34495 acpi_os_unmap_memory(virt, len);
34496 return 0;
34497 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34498 index 84ddc55..1d32f1e 100644
34499 --- a/drivers/char/tpm/tpm_eventlog.c
34500 +++ b/drivers/char/tpm/tpm_eventlog.c
34501 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34502 event = addr;
34503
34504 if ((event->event_type == 0 && event->event_size == 0) ||
34505 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34506 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34507 return NULL;
34508
34509 return addr;
34510 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34511 return NULL;
34512
34513 if ((event->event_type == 0 && event->event_size == 0) ||
34514 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34515 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34516 return NULL;
34517
34518 (*pos)++;
34519 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34520 int i;
34521
34522 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34523 - seq_putc(m, data[i]);
34524 + if (!seq_putc(m, data[i]))
34525 + return -EFAULT;
34526
34527 return 0;
34528 }
34529 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34530 index a4b7aa0..2faa0bc 100644
34531 --- a/drivers/char/virtio_console.c
34532 +++ b/drivers/char/virtio_console.c
34533 @@ -685,7 +685,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34534 if (to_user) {
34535 ssize_t ret;
34536
34537 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34538 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34539 if (ret)
34540 return -EFAULT;
34541 } else {
34542 @@ -784,7 +784,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34543 if (!port_has_data(port) && !port->host_connected)
34544 return 0;
34545
34546 - return fill_readbuf(port, ubuf, count, true);
34547 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34548 }
34549
34550 static int wait_port_writable(struct port *port, bool nonblock)
34551 diff --git a/drivers/clocksource/arm_generic.c b/drivers/clocksource/arm_generic.c
34552 index 8ae1a61..9c00613 100644
34553 --- a/drivers/clocksource/arm_generic.c
34554 +++ b/drivers/clocksource/arm_generic.c
34555 @@ -181,7 +181,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34556 return NOTIFY_OK;
34557 }
34558
34559 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34560 +static struct notifier_block arch_timer_cpu_nb = {
34561 .notifier_call = arch_timer_cpu_notify,
34562 };
34563
34564 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34565 index 7b0d49d..134fac9 100644
34566 --- a/drivers/cpufreq/acpi-cpufreq.c
34567 +++ b/drivers/cpufreq/acpi-cpufreq.c
34568 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34569 return sprintf(buf, "%u\n", boost_enabled);
34570 }
34571
34572 -static struct global_attr global_boost = __ATTR(boost, 0644,
34573 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34574 show_global_boost,
34575 store_global_boost);
34576
34577 @@ -712,8 +712,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34578 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34579 per_cpu(acfreq_data, cpu) = data;
34580
34581 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34582 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34583 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34584 + pax_open_kernel();
34585 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34586 + pax_close_kernel();
34587 + }
34588
34589 result = acpi_processor_register_performance(data->acpi_data, cpu);
34590 if (result)
34591 @@ -835,7 +838,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34592 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34593 break;
34594 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34595 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34596 + pax_open_kernel();
34597 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34598 + pax_close_kernel();
34599 policy->cur = get_cur_freq_on_cpu(cpu);
34600 break;
34601 default:
34602 @@ -846,8 +851,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34603 acpi_processor_notify_smm(THIS_MODULE);
34604
34605 /* Check for APERF/MPERF support in hardware */
34606 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34607 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34608 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34609 + pax_open_kernel();
34610 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34611 + pax_close_kernel();
34612 + }
34613
34614 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34615 for (i = 0; i < perf->state_count; i++)
34616 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34617 index 1f93dbd..305cef1 100644
34618 --- a/drivers/cpufreq/cpufreq.c
34619 +++ b/drivers/cpufreq/cpufreq.c
34620 @@ -1843,7 +1843,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34621 return NOTIFY_OK;
34622 }
34623
34624 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34625 +static struct notifier_block cpufreq_cpu_notifier = {
34626 .notifier_call = cpufreq_cpu_callback,
34627 };
34628
34629 @@ -1875,8 +1875,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34630
34631 pr_debug("trying to register driver %s\n", driver_data->name);
34632
34633 - if (driver_data->setpolicy)
34634 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34635 + if (driver_data->setpolicy) {
34636 + pax_open_kernel();
34637 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34638 + pax_close_kernel();
34639 + }
34640
34641 spin_lock_irqsave(&cpufreq_driver_lock, flags);
34642 if (cpufreq_driver) {
34643 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34644 index 6c5f1d3..c7e2f35e 100644
34645 --- a/drivers/cpufreq/cpufreq_governor.c
34646 +++ b/drivers/cpufreq/cpufreq_governor.c
34647 @@ -243,7 +243,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34648 * governor, thus we are bound to jiffes/HZ
34649 */
34650 if (dbs_data->governor == GOV_CONSERVATIVE) {
34651 - struct cs_ops *ops = dbs_data->gov_ops;
34652 + const struct cs_ops *ops = dbs_data->gov_ops;
34653
34654 cpufreq_register_notifier(ops->notifier_block,
34655 CPUFREQ_TRANSITION_NOTIFIER);
34656 @@ -251,7 +251,7 @@ int cpufreq_governor_dbs(struct dbs_data *dbs_data,
34657 dbs_data->min_sampling_rate = MIN_SAMPLING_RATE_RATIO *
34658 jiffies_to_usecs(10);
34659 } else {
34660 - struct od_ops *ops = dbs_data->gov_ops;
34661 + const struct od_ops *ops = dbs_data->gov_ops;
34662
34663 od_tuners->io_is_busy = ops->io_busy();
34664 }
34665 @@ -268,7 +268,7 @@ second_time:
34666 cs_dbs_info->enable = 1;
34667 cs_dbs_info->requested_freq = policy->cur;
34668 } else {
34669 - struct od_ops *ops = dbs_data->gov_ops;
34670 + const struct od_ops *ops = dbs_data->gov_ops;
34671 od_dbs_info->rate_mult = 1;
34672 od_dbs_info->sample_type = OD_NORMAL_SAMPLE;
34673 ops->powersave_bias_init_cpu(cpu);
34674 @@ -289,7 +289,7 @@ second_time:
34675 mutex_destroy(&cpu_cdbs->timer_mutex);
34676 dbs_data->enable--;
34677 if (!dbs_data->enable) {
34678 - struct cs_ops *ops = dbs_data->gov_ops;
34679 + const struct cs_ops *ops = dbs_data->gov_ops;
34680
34681 sysfs_remove_group(cpufreq_global_kobject,
34682 dbs_data->attr_group);
34683 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34684 index f661654..6c8e638 100644
34685 --- a/drivers/cpufreq/cpufreq_governor.h
34686 +++ b/drivers/cpufreq/cpufreq_governor.h
34687 @@ -142,7 +142,7 @@ struct dbs_data {
34688 void (*gov_check_cpu)(int cpu, unsigned int load);
34689
34690 /* Governor specific ops, see below */
34691 - void *gov_ops;
34692 + const void *gov_ops;
34693 };
34694
34695 /* Governor specific ops, will be passed to dbs_data->gov_ops */
34696 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34697 index 9d7732b..0b1a793 100644
34698 --- a/drivers/cpufreq/cpufreq_stats.c
34699 +++ b/drivers/cpufreq/cpufreq_stats.c
34700 @@ -340,7 +340,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34701 }
34702
34703 /* priority=1 so this will get called before cpufreq_remove_dev */
34704 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34705 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34706 .notifier_call = cpufreq_stat_cpu_callback,
34707 .priority = 1,
34708 };
34709 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34710 index 827629c9..0bc6a03 100644
34711 --- a/drivers/cpufreq/p4-clockmod.c
34712 +++ b/drivers/cpufreq/p4-clockmod.c
34713 @@ -167,10 +167,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34714 case 0x0F: /* Core Duo */
34715 case 0x16: /* Celeron Core */
34716 case 0x1C: /* Atom */
34717 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34718 + pax_open_kernel();
34719 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34720 + pax_close_kernel();
34721 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34722 case 0x0D: /* Pentium M (Dothan) */
34723 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34724 + pax_open_kernel();
34725 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34726 + pax_close_kernel();
34727 /* fall through */
34728 case 0x09: /* Pentium M (Banias) */
34729 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34730 @@ -182,7 +186,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34731
34732 /* on P-4s, the TSC runs with constant frequency independent whether
34733 * throttling is active or not. */
34734 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34735 + pax_open_kernel();
34736 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34737 + pax_close_kernel();
34738
34739 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34740 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34741 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34742 index 3a953d5..f5993f6 100644
34743 --- a/drivers/cpufreq/speedstep-centrino.c
34744 +++ b/drivers/cpufreq/speedstep-centrino.c
34745 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34746 !cpu_has(cpu, X86_FEATURE_EST))
34747 return -ENODEV;
34748
34749 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34750 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34751 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34752 + pax_open_kernel();
34753 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34754 + pax_close_kernel();
34755 + }
34756
34757 if (policy->cpu != 0)
34758 return -ENODEV;
34759 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34760 index e1f6860..f8de20b 100644
34761 --- a/drivers/cpuidle/cpuidle.c
34762 +++ b/drivers/cpuidle/cpuidle.c
34763 @@ -279,7 +279,7 @@ static int poll_idle(struct cpuidle_device *dev,
34764
34765 static void poll_idle_init(struct cpuidle_driver *drv)
34766 {
34767 - struct cpuidle_state *state = &drv->states[0];
34768 + cpuidle_state_no_const *state = &drv->states[0];
34769
34770 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34771 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34772 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34773 index ea2f8e7..70ac501 100644
34774 --- a/drivers/cpuidle/governor.c
34775 +++ b/drivers/cpuidle/governor.c
34776 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34777 mutex_lock(&cpuidle_lock);
34778 if (__cpuidle_find_governor(gov->name) == NULL) {
34779 ret = 0;
34780 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34781 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34782 if (!cpuidle_curr_governor ||
34783 cpuidle_curr_governor->rating < gov->rating)
34784 cpuidle_switch_governor(gov);
34785 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34786 new_gov = cpuidle_replace_governor(gov->rating);
34787 cpuidle_switch_governor(new_gov);
34788 }
34789 - list_del(&gov->governor_list);
34790 + pax_list_del((struct list_head *)&gov->governor_list);
34791 mutex_unlock(&cpuidle_lock);
34792 }
34793
34794 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34795 index 428754a..8bdf9cc 100644
34796 --- a/drivers/cpuidle/sysfs.c
34797 +++ b/drivers/cpuidle/sysfs.c
34798 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34799 NULL
34800 };
34801
34802 -static struct attribute_group cpuidle_attr_group = {
34803 +static attribute_group_no_const cpuidle_attr_group = {
34804 .attrs = cpuidle_default_attrs,
34805 .name = "cpuidle",
34806 };
34807 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34808 index 3b36797..289c16a 100644
34809 --- a/drivers/devfreq/devfreq.c
34810 +++ b/drivers/devfreq/devfreq.c
34811 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34812 goto err_out;
34813 }
34814
34815 - list_add(&governor->node, &devfreq_governor_list);
34816 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34817
34818 list_for_each_entry(devfreq, &devfreq_list, node) {
34819 int ret = 0;
34820 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34821 }
34822 }
34823
34824 - list_del(&governor->node);
34825 + pax_list_del((struct list_head *)&governor->node);
34826 err_out:
34827 mutex_unlock(&devfreq_list_lock);
34828
34829 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34830 index b70709b..1d8d02a 100644
34831 --- a/drivers/dma/sh/shdma.c
34832 +++ b/drivers/dma/sh/shdma.c
34833 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34834 return ret;
34835 }
34836
34837 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34838 +static struct notifier_block sh_dmae_nmi_notifier = {
34839 .notifier_call = sh_dmae_nmi_handler,
34840
34841 /* Run before NMI debug handler and KGDB */
34842 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34843 index 0ca1ca7..6e6f454 100644
34844 --- a/drivers/edac/edac_mc_sysfs.c
34845 +++ b/drivers/edac/edac_mc_sysfs.c
34846 @@ -148,7 +148,7 @@ static const char *edac_caps[] = {
34847 struct dev_ch_attribute {
34848 struct device_attribute attr;
34849 int channel;
34850 -};
34851 +} __do_const;
34852
34853 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34854 struct dev_ch_attribute dev_attr_legacy_##_name = \
34855 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34856 index 0056c4d..23b54d9 100644
34857 --- a/drivers/edac/edac_pci_sysfs.c
34858 +++ b/drivers/edac/edac_pci_sysfs.c
34859 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34860 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34861 static int edac_pci_poll_msec = 1000; /* one second workq period */
34862
34863 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34864 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34865 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34866 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34867
34868 static struct kobject *edac_pci_top_main_kobj;
34869 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34870 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34871 void *value;
34872 ssize_t(*show) (void *, char *);
34873 ssize_t(*store) (void *, const char *, size_t);
34874 -};
34875 +} __do_const;
34876
34877 /* Set of show/store abstract level functions for PCI Parity object */
34878 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34879 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34880 edac_printk(KERN_CRIT, EDAC_PCI,
34881 "Signaled System Error on %s\n",
34882 pci_name(dev));
34883 - atomic_inc(&pci_nonparity_count);
34884 + atomic_inc_unchecked(&pci_nonparity_count);
34885 }
34886
34887 if (status & (PCI_STATUS_PARITY)) {
34888 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34889 "Master Data Parity Error on %s\n",
34890 pci_name(dev));
34891
34892 - atomic_inc(&pci_parity_count);
34893 + atomic_inc_unchecked(&pci_parity_count);
34894 }
34895
34896 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34897 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34898 "Detected Parity Error on %s\n",
34899 pci_name(dev));
34900
34901 - atomic_inc(&pci_parity_count);
34902 + atomic_inc_unchecked(&pci_parity_count);
34903 }
34904 }
34905
34906 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34907 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34908 "Signaled System Error on %s\n",
34909 pci_name(dev));
34910 - atomic_inc(&pci_nonparity_count);
34911 + atomic_inc_unchecked(&pci_nonparity_count);
34912 }
34913
34914 if (status & (PCI_STATUS_PARITY)) {
34915 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34916 "Master Data Parity Error on "
34917 "%s\n", pci_name(dev));
34918
34919 - atomic_inc(&pci_parity_count);
34920 + atomic_inc_unchecked(&pci_parity_count);
34921 }
34922
34923 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34924 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34925 "Detected Parity Error on %s\n",
34926 pci_name(dev));
34927
34928 - atomic_inc(&pci_parity_count);
34929 + atomic_inc_unchecked(&pci_parity_count);
34930 }
34931 }
34932 }
34933 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34934 if (!check_pci_errors)
34935 return;
34936
34937 - before_count = atomic_read(&pci_parity_count);
34938 + before_count = atomic_read_unchecked(&pci_parity_count);
34939
34940 /* scan all PCI devices looking for a Parity Error on devices and
34941 * bridges.
34942 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34943 /* Only if operator has selected panic on PCI Error */
34944 if (edac_pci_get_panic_on_pe()) {
34945 /* If the count is different 'after' from 'before' */
34946 - if (before_count != atomic_read(&pci_parity_count))
34947 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34948 panic("EDAC: PCI Parity Error");
34949 }
34950 }
34951 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34952 index 6796799..99e8377 100644
34953 --- a/drivers/edac/mce_amd.h
34954 +++ b/drivers/edac/mce_amd.h
34955 @@ -78,7 +78,7 @@ extern const char * const ii_msgs[];
34956 struct amd_decoder_ops {
34957 bool (*mc0_mce)(u16, u8);
34958 bool (*mc1_mce)(u16, u8);
34959 -};
34960 +} __no_const;
34961
34962 void amd_report_gart_errors(bool);
34963 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
34964 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
34965 index 57ea7f4..789e3c3 100644
34966 --- a/drivers/firewire/core-card.c
34967 +++ b/drivers/firewire/core-card.c
34968 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
34969
34970 void fw_core_remove_card(struct fw_card *card)
34971 {
34972 - struct fw_card_driver dummy_driver = dummy_driver_template;
34973 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
34974
34975 card->driver->update_phy_reg(card, 4,
34976 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
34977 diff --git a/drivers/firewire/core-cdev.c b/drivers/firewire/core-cdev.c
34978 index f8d2287..5aaf4db 100644
34979 --- a/drivers/firewire/core-cdev.c
34980 +++ b/drivers/firewire/core-cdev.c
34981 @@ -1365,8 +1365,7 @@ static int init_iso_resource(struct client *client,
34982 int ret;
34983
34984 if ((request->channels == 0 && request->bandwidth == 0) ||
34985 - request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL ||
34986 - request->bandwidth < 0)
34987 + request->bandwidth > BANDWIDTH_AVAILABLE_INITIAL)
34988 return -EINVAL;
34989
34990 r = kmalloc(sizeof(*r), GFP_KERNEL);
34991 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
34992 index af3e8aa..eb2f227 100644
34993 --- a/drivers/firewire/core-device.c
34994 +++ b/drivers/firewire/core-device.c
34995 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
34996 struct config_rom_attribute {
34997 struct device_attribute attr;
34998 u32 key;
34999 -};
35000 +} __do_const;
35001
35002 static ssize_t show_immediate(struct device *dev,
35003 struct device_attribute *dattr, char *buf)
35004 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35005 index 28a94c7..58da63a 100644
35006 --- a/drivers/firewire/core-transaction.c
35007 +++ b/drivers/firewire/core-transaction.c
35008 @@ -38,6 +38,7 @@
35009 #include <linux/timer.h>
35010 #include <linux/types.h>
35011 #include <linux/workqueue.h>
35012 +#include <linux/sched.h>
35013
35014 #include <asm/byteorder.h>
35015
35016 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35017 index 515a42c..5ecf3ba 100644
35018 --- a/drivers/firewire/core.h
35019 +++ b/drivers/firewire/core.h
35020 @@ -111,6 +111,7 @@ struct fw_card_driver {
35021
35022 int (*stop_iso)(struct fw_iso_context *ctx);
35023 };
35024 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35025
35026 void fw_card_initialize(struct fw_card *card,
35027 const struct fw_card_driver *driver, struct device *device);
35028 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35029 index 94a58a0..f5eba42 100644
35030 --- a/drivers/firmware/dmi-id.c
35031 +++ b/drivers/firmware/dmi-id.c
35032 @@ -16,7 +16,7 @@
35033 struct dmi_device_attribute{
35034 struct device_attribute dev_attr;
35035 int field;
35036 -};
35037 +} __do_const;
35038 #define to_dmi_dev_attr(_dev_attr) \
35039 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35040
35041 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35042 index 4cd392d..4b629e1 100644
35043 --- a/drivers/firmware/dmi_scan.c
35044 +++ b/drivers/firmware/dmi_scan.c
35045 @@ -490,11 +490,6 @@ void __init dmi_scan_machine(void)
35046 }
35047 }
35048 else {
35049 - /*
35050 - * no iounmap() for that ioremap(); it would be a no-op, but
35051 - * it's so early in setup that sucker gets confused into doing
35052 - * what it shouldn't if we actually call it.
35053 - */
35054 p = dmi_ioremap(0xF0000, 0x10000);
35055 if (p == NULL)
35056 goto error;
35057 @@ -769,7 +764,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35058 if (buf == NULL)
35059 return -1;
35060
35061 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35062 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35063
35064 iounmap(buf);
35065 return 0;
35066 diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
35067 index b07cb37..2a51037 100644
35068 --- a/drivers/firmware/efivars.c
35069 +++ b/drivers/firmware/efivars.c
35070 @@ -138,7 +138,7 @@ struct efivar_attribute {
35071 };
35072
35073 static struct efivars __efivars;
35074 -static struct efivar_operations ops;
35075 +static efivar_operations_no_const ops __read_only;
35076
35077 #define PSTORE_EFI_ATTRIBUTES \
35078 (EFI_VARIABLE_NON_VOLATILE | \
35079 @@ -1834,7 +1834,7 @@ efivar_create_sysfs_entry(struct efivars *efivars,
35080 static int
35081 create_efivars_bin_attributes(struct efivars *efivars)
35082 {
35083 - struct bin_attribute *attr;
35084 + bin_attribute_no_const *attr;
35085 int error;
35086
35087 /* new_var */
35088 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35089 index 2a90ba6..07f3733 100644
35090 --- a/drivers/firmware/google/memconsole.c
35091 +++ b/drivers/firmware/google/memconsole.c
35092 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35093 if (!found_memconsole())
35094 return -ENODEV;
35095
35096 - memconsole_bin_attr.size = memconsole_length;
35097 + pax_open_kernel();
35098 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35099 + pax_close_kernel();
35100
35101 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35102
35103 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35104 index 6f2306d..af9476a 100644
35105 --- a/drivers/gpio/gpio-ich.c
35106 +++ b/drivers/gpio/gpio-ich.c
35107 @@ -69,7 +69,7 @@ struct ichx_desc {
35108 /* Some chipsets have quirks, let these use their own request/get */
35109 int (*request)(struct gpio_chip *chip, unsigned offset);
35110 int (*get)(struct gpio_chip *chip, unsigned offset);
35111 -};
35112 +} __do_const;
35113
35114 static struct {
35115 spinlock_t lock;
35116 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35117 index 9902732..64b62dd 100644
35118 --- a/drivers/gpio/gpio-vr41xx.c
35119 +++ b/drivers/gpio/gpio-vr41xx.c
35120 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35121 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35122 maskl, pendl, maskh, pendh);
35123
35124 - atomic_inc(&irq_err_count);
35125 + atomic_inc_unchecked(&irq_err_count);
35126
35127 return -EINVAL;
35128 }
35129 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35130 index 7b2d378..cc947ea 100644
35131 --- a/drivers/gpu/drm/drm_crtc_helper.c
35132 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35133 @@ -319,7 +319,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35134 struct drm_crtc *tmp;
35135 int crtc_mask = 1;
35136
35137 - WARN(!crtc, "checking null crtc?\n");
35138 + BUG_ON(!crtc);
35139
35140 dev = crtc->dev;
35141
35142 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35143 index be174ca..7f38143 100644
35144 --- a/drivers/gpu/drm/drm_drv.c
35145 +++ b/drivers/gpu/drm/drm_drv.c
35146 @@ -307,7 +307,7 @@ module_exit(drm_core_exit);
35147 /**
35148 * Copy and IOCTL return string to user space
35149 */
35150 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35151 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35152 {
35153 int len;
35154
35155 @@ -377,7 +377,7 @@ long drm_ioctl(struct file *filp,
35156 struct drm_file *file_priv = filp->private_data;
35157 struct drm_device *dev;
35158 struct drm_ioctl_desc *ioctl;
35159 - drm_ioctl_t *func;
35160 + drm_ioctl_no_const_t func;
35161 unsigned int nr = DRM_IOCTL_NR(cmd);
35162 int retcode = -EINVAL;
35163 char stack_kdata[128];
35164 @@ -390,7 +390,7 @@ long drm_ioctl(struct file *filp,
35165 return -ENODEV;
35166
35167 atomic_inc(&dev->ioctl_count);
35168 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35169 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35170 ++file_priv->ioctl_count;
35171
35172 DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
35173 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35174 index 32d7775..c8be5e1 100644
35175 --- a/drivers/gpu/drm/drm_fops.c
35176 +++ b/drivers/gpu/drm/drm_fops.c
35177 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35178 }
35179
35180 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35181 - atomic_set(&dev->counts[i], 0);
35182 + atomic_set_unchecked(&dev->counts[i], 0);
35183
35184 dev->sigdata.lock = NULL;
35185
35186 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35187 if (drm_device_is_unplugged(dev))
35188 return -ENODEV;
35189
35190 - if (!dev->open_count++)
35191 + if (local_inc_return(&dev->open_count) == 1)
35192 need_setup = 1;
35193 mutex_lock(&dev->struct_mutex);
35194 old_imapping = inode->i_mapping;
35195 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35196 retcode = drm_open_helper(inode, filp, dev);
35197 if (retcode)
35198 goto err_undo;
35199 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35200 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35201 if (need_setup) {
35202 retcode = drm_setup(dev);
35203 if (retcode)
35204 @@ -166,7 +166,7 @@ err_undo:
35205 iput(container_of(dev->dev_mapping, struct inode, i_data));
35206 dev->dev_mapping = old_mapping;
35207 mutex_unlock(&dev->struct_mutex);
35208 - dev->open_count--;
35209 + local_dec(&dev->open_count);
35210 return retcode;
35211 }
35212 EXPORT_SYMBOL(drm_open);
35213 @@ -440,7 +440,7 @@ int drm_release(struct inode *inode, struct file *filp)
35214
35215 mutex_lock(&drm_global_mutex);
35216
35217 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35218 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35219
35220 if (dev->driver->preclose)
35221 dev->driver->preclose(dev, file_priv);
35222 @@ -449,10 +449,10 @@ int drm_release(struct inode *inode, struct file *filp)
35223 * Begin inline drm_release
35224 */
35225
35226 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35227 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35228 task_pid_nr(current),
35229 (long)old_encode_dev(file_priv->minor->device),
35230 - dev->open_count);
35231 + local_read(&dev->open_count));
35232
35233 /* Release any auth tokens that might point to this file_priv,
35234 (do that under the drm_global_mutex) */
35235 @@ -549,8 +549,8 @@ int drm_release(struct inode *inode, struct file *filp)
35236 * End inline drm_release
35237 */
35238
35239 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35240 - if (!--dev->open_count) {
35241 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35242 + if (local_dec_and_test(&dev->open_count)) {
35243 if (atomic_read(&dev->ioctl_count)) {
35244 DRM_ERROR("Device busy: %d\n",
35245 atomic_read(&dev->ioctl_count));
35246 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35247 index f731116..629842c 100644
35248 --- a/drivers/gpu/drm/drm_global.c
35249 +++ b/drivers/gpu/drm/drm_global.c
35250 @@ -36,7 +36,7 @@
35251 struct drm_global_item {
35252 struct mutex mutex;
35253 void *object;
35254 - int refcount;
35255 + atomic_t refcount;
35256 };
35257
35258 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35259 @@ -49,7 +49,7 @@ void drm_global_init(void)
35260 struct drm_global_item *item = &glob[i];
35261 mutex_init(&item->mutex);
35262 item->object = NULL;
35263 - item->refcount = 0;
35264 + atomic_set(&item->refcount, 0);
35265 }
35266 }
35267
35268 @@ -59,7 +59,7 @@ void drm_global_release(void)
35269 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35270 struct drm_global_item *item = &glob[i];
35271 BUG_ON(item->object != NULL);
35272 - BUG_ON(item->refcount != 0);
35273 + BUG_ON(atomic_read(&item->refcount) != 0);
35274 }
35275 }
35276
35277 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35278 void *object;
35279
35280 mutex_lock(&item->mutex);
35281 - if (item->refcount == 0) {
35282 + if (atomic_read(&item->refcount) == 0) {
35283 item->object = kzalloc(ref->size, GFP_KERNEL);
35284 if (unlikely(item->object == NULL)) {
35285 ret = -ENOMEM;
35286 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35287 goto out_err;
35288
35289 }
35290 - ++item->refcount;
35291 + atomic_inc(&item->refcount);
35292 ref->object = item->object;
35293 object = item->object;
35294 mutex_unlock(&item->mutex);
35295 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35296 struct drm_global_item *item = &glob[ref->global_type];
35297
35298 mutex_lock(&item->mutex);
35299 - BUG_ON(item->refcount == 0);
35300 + BUG_ON(atomic_read(&item->refcount) == 0);
35301 BUG_ON(ref->object != item->object);
35302 - if (--item->refcount == 0) {
35303 + if (atomic_dec_and_test(&item->refcount)) {
35304 ref->release(ref);
35305 item->object = NULL;
35306 }
35307 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35308 index d4b20ce..77a8d41 100644
35309 --- a/drivers/gpu/drm/drm_info.c
35310 +++ b/drivers/gpu/drm/drm_info.c
35311 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35312 struct drm_local_map *map;
35313 struct drm_map_list *r_list;
35314
35315 - /* Hardcoded from _DRM_FRAME_BUFFER,
35316 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35317 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35318 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35319 + static const char * const types[] = {
35320 + [_DRM_FRAME_BUFFER] = "FB",
35321 + [_DRM_REGISTERS] = "REG",
35322 + [_DRM_SHM] = "SHM",
35323 + [_DRM_AGP] = "AGP",
35324 + [_DRM_SCATTER_GATHER] = "SG",
35325 + [_DRM_CONSISTENT] = "PCI",
35326 + [_DRM_GEM] = "GEM" };
35327 const char *type;
35328 int i;
35329
35330 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35331 map = r_list->map;
35332 if (!map)
35333 continue;
35334 - if (map->type < 0 || map->type > 5)
35335 + if (map->type >= ARRAY_SIZE(types))
35336 type = "??";
35337 else
35338 type = types[map->type];
35339 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35340 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35341 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35342 vma->vm_flags & VM_IO ? 'i' : '-',
35343 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35344 + 0);
35345 +#else
35346 vma->vm_pgoff);
35347 +#endif
35348
35349 #if defined(__i386__)
35350 pgprot = pgprot_val(vma->vm_page_prot);
35351 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35352 index 2f4c434..dd12cd2 100644
35353 --- a/drivers/gpu/drm/drm_ioc32.c
35354 +++ b/drivers/gpu/drm/drm_ioc32.c
35355 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35356 request = compat_alloc_user_space(nbytes);
35357 if (!access_ok(VERIFY_WRITE, request, nbytes))
35358 return -EFAULT;
35359 - list = (struct drm_buf_desc *) (request + 1);
35360 + list = (struct drm_buf_desc __user *) (request + 1);
35361
35362 if (__put_user(count, &request->count)
35363 || __put_user(list, &request->list))
35364 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35365 request = compat_alloc_user_space(nbytes);
35366 if (!access_ok(VERIFY_WRITE, request, nbytes))
35367 return -EFAULT;
35368 - list = (struct drm_buf_pub *) (request + 1);
35369 + list = (struct drm_buf_pub __user *) (request + 1);
35370
35371 if (__put_user(count, &request->count)
35372 || __put_user(list, &request->list))
35373 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35374 return 0;
35375 }
35376
35377 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35378 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35379 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35380 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35381 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35382 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35383 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35384 {
35385 unsigned int nr = DRM_IOCTL_NR(cmd);
35386 - drm_ioctl_compat_t *fn;
35387 int ret;
35388
35389 /* Assume that ioctls without an explicit compat routine will just
35390 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35391 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35392 return drm_ioctl(filp, cmd, arg);
35393
35394 - fn = drm_compat_ioctls[nr];
35395 -
35396 - if (fn != NULL)
35397 - ret = (*fn) (filp, cmd, arg);
35398 + if (drm_compat_ioctls[nr] != NULL)
35399 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35400 else
35401 ret = drm_ioctl(filp, cmd, arg);
35402
35403 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35404 index e77bd8b..1571b85 100644
35405 --- a/drivers/gpu/drm/drm_ioctl.c
35406 +++ b/drivers/gpu/drm/drm_ioctl.c
35407 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35408 stats->data[i].value =
35409 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35410 else
35411 - stats->data[i].value = atomic_read(&dev->counts[i]);
35412 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35413 stats->data[i].type = dev->types[i];
35414 }
35415
35416 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35417 index d752c96..fe08455 100644
35418 --- a/drivers/gpu/drm/drm_lock.c
35419 +++ b/drivers/gpu/drm/drm_lock.c
35420 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35421 if (drm_lock_take(&master->lock, lock->context)) {
35422 master->lock.file_priv = file_priv;
35423 master->lock.lock_time = jiffies;
35424 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35425 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35426 break; /* Got lock */
35427 }
35428
35429 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35430 return -EINVAL;
35431 }
35432
35433 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35434 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35435
35436 if (drm_lock_free(&master->lock, lock->context)) {
35437 /* FIXME: Should really bail out here. */
35438 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35439 index 200e104..59facda 100644
35440 --- a/drivers/gpu/drm/drm_stub.c
35441 +++ b/drivers/gpu/drm/drm_stub.c
35442 @@ -516,7 +516,7 @@ void drm_unplug_dev(struct drm_device *dev)
35443
35444 drm_device_set_unplugged(dev);
35445
35446 - if (dev->open_count == 0) {
35447 + if (local_read(&dev->open_count) == 0) {
35448 drm_put_dev(dev);
35449 }
35450 mutex_unlock(&drm_global_mutex);
35451 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35452 index 004ecdf..db1f6e0 100644
35453 --- a/drivers/gpu/drm/i810/i810_dma.c
35454 +++ b/drivers/gpu/drm/i810/i810_dma.c
35455 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35456 dma->buflist[vertex->idx],
35457 vertex->discard, vertex->used);
35458
35459 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35460 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35461 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35462 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35463 sarea_priv->last_enqueue = dev_priv->counter - 1;
35464 sarea_priv->last_dispatch = (int)hw_status[5];
35465
35466 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35467 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35468 mc->last_render);
35469
35470 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35471 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35472 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35473 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35474 sarea_priv->last_enqueue = dev_priv->counter - 1;
35475 sarea_priv->last_dispatch = (int)hw_status[5];
35476
35477 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35478 index 6e0acad..93c8289 100644
35479 --- a/drivers/gpu/drm/i810/i810_drv.h
35480 +++ b/drivers/gpu/drm/i810/i810_drv.h
35481 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35482 int page_flipping;
35483
35484 wait_queue_head_t irq_queue;
35485 - atomic_t irq_received;
35486 - atomic_t irq_emitted;
35487 + atomic_unchecked_t irq_received;
35488 + atomic_unchecked_t irq_emitted;
35489
35490 int front_offset;
35491 } drm_i810_private_t;
35492 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35493 index 261efc8e..27af8a5 100644
35494 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35495 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35496 @@ -496,7 +496,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35497 I915_READ(GTIMR));
35498 }
35499 seq_printf(m, "Interrupts received: %d\n",
35500 - atomic_read(&dev_priv->irq_received));
35501 + atomic_read_unchecked(&dev_priv->irq_received));
35502 for_each_ring(ring, dev_priv, i) {
35503 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35504 seq_printf(m,
35505 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35506 index 99daa89..84ebd44 100644
35507 --- a/drivers/gpu/drm/i915/i915_dma.c
35508 +++ b/drivers/gpu/drm/i915/i915_dma.c
35509 @@ -1253,7 +1253,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35510 bool can_switch;
35511
35512 spin_lock(&dev->count_lock);
35513 - can_switch = (dev->open_count == 0);
35514 + can_switch = (local_read(&dev->open_count) == 0);
35515 spin_unlock(&dev->count_lock);
35516 return can_switch;
35517 }
35518 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35519 index 7339a4b..445aaba 100644
35520 --- a/drivers/gpu/drm/i915/i915_drv.h
35521 +++ b/drivers/gpu/drm/i915/i915_drv.h
35522 @@ -656,7 +656,7 @@ typedef struct drm_i915_private {
35523 drm_dma_handle_t *status_page_dmah;
35524 struct resource mch_res;
35525
35526 - atomic_t irq_received;
35527 + atomic_unchecked_t irq_received;
35528
35529 /* protects the irq masks */
35530 spinlock_t irq_lock;
35531 @@ -1102,7 +1102,7 @@ struct drm_i915_gem_object {
35532 * will be page flipped away on the next vblank. When it
35533 * reaches 0, dev_priv->pending_flip_queue will be woken up.
35534 */
35535 - atomic_t pending_flip;
35536 + atomic_unchecked_t pending_flip;
35537 };
35538 #define to_gem_object(obj) (&((struct drm_i915_gem_object *)(obj))->base)
35539
35540 @@ -1633,7 +1633,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35541 struct drm_i915_private *dev_priv, unsigned port);
35542 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35543 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35544 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35545 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35546 {
35547 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35548 }
35549 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35550 index ba8805a..39d5330 100644
35551 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35552 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35553 @@ -672,7 +672,7 @@ i915_gem_execbuffer_move_to_gpu(struct intel_ring_buffer *ring,
35554 i915_gem_clflush_object(obj);
35555
35556 if (obj->base.pending_write_domain)
35557 - flips |= atomic_read(&obj->pending_flip);
35558 + flips |= atomic_read_unchecked(&obj->pending_flip);
35559
35560 flush_domains |= obj->base.write_domain;
35561 }
35562 @@ -703,9 +703,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35563
35564 static int
35565 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35566 - int count)
35567 + unsigned int count)
35568 {
35569 - int i;
35570 + unsigned int i;
35571 int relocs_total = 0;
35572 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35573
35574 @@ -1202,7 +1202,7 @@ i915_gem_execbuffer2(struct drm_device *dev, void *data,
35575 return -ENOMEM;
35576 }
35577 ret = copy_from_user(exec2_list,
35578 - (struct drm_i915_relocation_entry __user *)
35579 + (struct drm_i915_gem_exec_object2 __user *)
35580 (uintptr_t) args->buffers_ptr,
35581 sizeof(*exec2_list) * args->buffer_count);
35582 if (ret != 0) {
35583 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35584 index 3c59584..500f2e9 100644
35585 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35586 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35587 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35588 (unsigned long)request);
35589 }
35590
35591 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35592 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35593 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35594 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35595 [DRM_I915_GETPARAM] = compat_i915_getparam,
35596 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35597 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35598 {
35599 unsigned int nr = DRM_IOCTL_NR(cmd);
35600 - drm_ioctl_compat_t *fn = NULL;
35601 int ret;
35602
35603 if (nr < DRM_COMMAND_BASE)
35604 return drm_compat_ioctl(filp, cmd, arg);
35605
35606 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35607 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35608 -
35609 - if (fn != NULL)
35610 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35611 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35612 ret = (*fn) (filp, cmd, arg);
35613 - else
35614 + } else
35615 ret = drm_ioctl(filp, cmd, arg);
35616
35617 return ret;
35618 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35619 index fe84338..a863190 100644
35620 --- a/drivers/gpu/drm/i915/i915_irq.c
35621 +++ b/drivers/gpu/drm/i915/i915_irq.c
35622 @@ -535,7 +535,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35623 u32 pipe_stats[I915_MAX_PIPES];
35624 bool blc_event;
35625
35626 - atomic_inc(&dev_priv->irq_received);
35627 + atomic_inc_unchecked(&dev_priv->irq_received);
35628
35629 while (true) {
35630 iir = I915_READ(VLV_IIR);
35631 @@ -688,7 +688,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35632 irqreturn_t ret = IRQ_NONE;
35633 int i;
35634
35635 - atomic_inc(&dev_priv->irq_received);
35636 + atomic_inc_unchecked(&dev_priv->irq_received);
35637
35638 /* disable master interrupt before clearing iir */
35639 de_ier = I915_READ(DEIER);
35640 @@ -760,7 +760,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35641 int ret = IRQ_NONE;
35642 u32 de_iir, gt_iir, de_ier, pch_iir, pm_iir;
35643
35644 - atomic_inc(&dev_priv->irq_received);
35645 + atomic_inc_unchecked(&dev_priv->irq_received);
35646
35647 /* disable master interrupt before clearing iir */
35648 de_ier = I915_READ(DEIER);
35649 @@ -1787,7 +1787,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35650 {
35651 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35652
35653 - atomic_set(&dev_priv->irq_received, 0);
35654 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35655
35656 I915_WRITE(HWSTAM, 0xeffe);
35657
35658 @@ -1813,7 +1813,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35659 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35660 int pipe;
35661
35662 - atomic_set(&dev_priv->irq_received, 0);
35663 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35664
35665 /* VLV magic */
35666 I915_WRITE(VLV_IMR, 0);
35667 @@ -2108,7 +2108,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35668 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35669 int pipe;
35670
35671 - atomic_set(&dev_priv->irq_received, 0);
35672 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35673
35674 for_each_pipe(pipe)
35675 I915_WRITE(PIPESTAT(pipe), 0);
35676 @@ -2159,7 +2159,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35677 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35678 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35679
35680 - atomic_inc(&dev_priv->irq_received);
35681 + atomic_inc_unchecked(&dev_priv->irq_received);
35682
35683 iir = I915_READ16(IIR);
35684 if (iir == 0)
35685 @@ -2244,7 +2244,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35686 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35687 int pipe;
35688
35689 - atomic_set(&dev_priv->irq_received, 0);
35690 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35691
35692 if (I915_HAS_HOTPLUG(dev)) {
35693 I915_WRITE(PORT_HOTPLUG_EN, 0);
35694 @@ -2339,7 +2339,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35695 };
35696 int pipe, ret = IRQ_NONE;
35697
35698 - atomic_inc(&dev_priv->irq_received);
35699 + atomic_inc_unchecked(&dev_priv->irq_received);
35700
35701 iir = I915_READ(IIR);
35702 do {
35703 @@ -2465,7 +2465,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35704 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35705 int pipe;
35706
35707 - atomic_set(&dev_priv->irq_received, 0);
35708 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35709
35710 I915_WRITE(PORT_HOTPLUG_EN, 0);
35711 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35712 @@ -2572,7 +2572,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35713 int irq_received;
35714 int ret = IRQ_NONE, pipe;
35715
35716 - atomic_inc(&dev_priv->irq_received);
35717 + atomic_inc_unchecked(&dev_priv->irq_received);
35718
35719 iir = I915_READ(IIR);
35720
35721 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35722 index d3f834a..0ad1b37 100644
35723 --- a/drivers/gpu/drm/i915/intel_display.c
35724 +++ b/drivers/gpu/drm/i915/intel_display.c
35725 @@ -2255,7 +2255,7 @@ intel_finish_fb(struct drm_framebuffer *old_fb)
35726
35727 wait_event(dev_priv->pending_flip_queue,
35728 atomic_read(&dev_priv->mm.wedged) ||
35729 - atomic_read(&obj->pending_flip) == 0);
35730 + atomic_read_unchecked(&obj->pending_flip) == 0);
35731
35732 /* Big Hammer, we also need to ensure that any pending
35733 * MI_WAIT_FOR_EVENT inside a user batch buffer on the
35734 @@ -7122,8 +7122,7 @@ static void do_intel_finish_page_flip(struct drm_device *dev,
35735
35736 obj = work->old_fb_obj;
35737
35738 - atomic_clear_mask(1 << intel_crtc->plane,
35739 - &obj->pending_flip.counter);
35740 + atomic_clear_mask_unchecked(1 << intel_crtc->plane, &obj->pending_flip);
35741 wake_up(&dev_priv->pending_flip_queue);
35742
35743 queue_work(dev_priv->wq, &work->work);
35744 @@ -7486,7 +7485,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35745 /* Block clients from rendering to the new back buffer until
35746 * the flip occurs and the object is no longer visible.
35747 */
35748 - atomic_add(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35749 + atomic_add_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35750 atomic_inc(&intel_crtc->unpin_work_count);
35751
35752 ret = dev_priv->display.queue_flip(dev, crtc, fb, obj);
35753 @@ -7504,7 +7503,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
35754 cleanup_pending:
35755 atomic_dec(&intel_crtc->unpin_work_count);
35756 crtc->fb = old_fb;
35757 - atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35758 + atomic_sub_unchecked(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
35759 drm_gem_object_unreference(&work->old_fb_obj->base);
35760 drm_gem_object_unreference(&obj->base);
35761 mutex_unlock(&dev->struct_mutex);
35762 @@ -8846,13 +8845,13 @@ struct intel_quirk {
35763 int subsystem_vendor;
35764 int subsystem_device;
35765 void (*hook)(struct drm_device *dev);
35766 -};
35767 +} __do_const;
35768
35769 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35770 struct intel_dmi_quirk {
35771 void (*hook)(struct drm_device *dev);
35772 const struct dmi_system_id (*dmi_id_list)[];
35773 -};
35774 +} __do_const;
35775
35776 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35777 {
35778 @@ -8860,18 +8859,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35779 return 1;
35780 }
35781
35782 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35783 + {
35784 + .callback = intel_dmi_reverse_brightness,
35785 + .ident = "NCR Corporation",
35786 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35787 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35788 + },
35789 + },
35790 + { } /* terminating entry */
35791 +};
35792 +
35793 static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35794 {
35795 - .dmi_id_list = &(const struct dmi_system_id[]) {
35796 - {
35797 - .callback = intel_dmi_reverse_brightness,
35798 - .ident = "NCR Corporation",
35799 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35800 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35801 - },
35802 - },
35803 - { } /* terminating entry */
35804 - },
35805 + .dmi_id_list = &intel_dmi_quirks_table,
35806 .hook = quirk_invert_brightness,
35807 },
35808 };
35809 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35810 index 54558a0..2d97005 100644
35811 --- a/drivers/gpu/drm/mga/mga_drv.h
35812 +++ b/drivers/gpu/drm/mga/mga_drv.h
35813 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35814 u32 clear_cmd;
35815 u32 maccess;
35816
35817 - atomic_t vbl_received; /**< Number of vblanks received. */
35818 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35819 wait_queue_head_t fence_queue;
35820 - atomic_t last_fence_retired;
35821 + atomic_unchecked_t last_fence_retired;
35822 u32 next_fence_to_post;
35823
35824 unsigned int fb_cpp;
35825 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35826 index 709e90d..89a1c0d 100644
35827 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35828 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35829 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35830 return 0;
35831 }
35832
35833 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35834 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35835 [DRM_MGA_INIT] = compat_mga_init,
35836 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35837 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35838 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35839 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35840 {
35841 unsigned int nr = DRM_IOCTL_NR(cmd);
35842 - drm_ioctl_compat_t *fn = NULL;
35843 int ret;
35844
35845 if (nr < DRM_COMMAND_BASE)
35846 return drm_compat_ioctl(filp, cmd, arg);
35847
35848 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35849 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35850 -
35851 - if (fn != NULL)
35852 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35853 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35854 ret = (*fn) (filp, cmd, arg);
35855 - else
35856 + } else
35857 ret = drm_ioctl(filp, cmd, arg);
35858
35859 return ret;
35860 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35861 index 598c281..60d590e 100644
35862 --- a/drivers/gpu/drm/mga/mga_irq.c
35863 +++ b/drivers/gpu/drm/mga/mga_irq.c
35864 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35865 if (crtc != 0)
35866 return 0;
35867
35868 - return atomic_read(&dev_priv->vbl_received);
35869 + return atomic_read_unchecked(&dev_priv->vbl_received);
35870 }
35871
35872
35873 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35874 /* VBLANK interrupt */
35875 if (status & MGA_VLINEPEN) {
35876 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35877 - atomic_inc(&dev_priv->vbl_received);
35878 + atomic_inc_unchecked(&dev_priv->vbl_received);
35879 drm_handle_vblank(dev, 0);
35880 handled = 1;
35881 }
35882 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35883 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35884 MGA_WRITE(MGA_PRIMEND, prim_end);
35885
35886 - atomic_inc(&dev_priv->last_fence_retired);
35887 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35888 DRM_WAKEUP(&dev_priv->fence_queue);
35889 handled = 1;
35890 }
35891 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35892 * using fences.
35893 */
35894 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35895 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35896 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35897 - *sequence) <= (1 << 23)));
35898
35899 *sequence = cur_fence;
35900 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35901 index 865eddf..62c4cc3 100644
35902 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35903 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35904 @@ -1015,7 +1015,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35905 struct bit_table {
35906 const char id;
35907 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35908 -};
35909 +} __no_const;
35910
35911 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35912
35913 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35914 index aa89eb9..d45d38b 100644
35915 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35916 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35917 @@ -80,7 +80,7 @@ struct nouveau_drm {
35918 struct drm_global_reference mem_global_ref;
35919 struct ttm_bo_global_ref bo_global_ref;
35920 struct ttm_bo_device bdev;
35921 - atomic_t validate_sequence;
35922 + atomic_unchecked_t validate_sequence;
35923 int (*move)(struct nouveau_channel *,
35924 struct ttm_buffer_object *,
35925 struct ttm_mem_reg *, struct ttm_mem_reg *);
35926 diff --git a/drivers/gpu/drm/nouveau/nouveau_fence.h b/drivers/gpu/drm/nouveau/nouveau_fence.h
35927 index cdb83ac..27f0a16 100644
35928 --- a/drivers/gpu/drm/nouveau/nouveau_fence.h
35929 +++ b/drivers/gpu/drm/nouveau/nouveau_fence.h
35930 @@ -43,7 +43,7 @@ struct nouveau_fence_priv {
35931 int (*sync)(struct nouveau_fence *, struct nouveau_channel *,
35932 struct nouveau_channel *);
35933 u32 (*read)(struct nouveau_channel *);
35934 -};
35935 +} __no_const;
35936
35937 #define nouveau_fence(drm) ((struct nouveau_fence_priv *)(drm)->fence)
35938
35939 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35940 index 8bf695c..9fbc90a 100644
35941 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35942 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35943 @@ -321,7 +321,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35944 int trycnt = 0;
35945 int ret, i;
35946
35947 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35948 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35949 retry:
35950 if (++trycnt > 100000) {
35951 NV_ERROR(drm, "%s failed and gave up.\n", __func__);
35952 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35953 index 08214bc..9208577 100644
35954 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35955 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35956 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35957 unsigned long arg)
35958 {
35959 unsigned int nr = DRM_IOCTL_NR(cmd);
35960 - drm_ioctl_compat_t *fn = NULL;
35961 + drm_ioctl_compat_t fn = NULL;
35962 int ret;
35963
35964 if (nr < DRM_COMMAND_BASE)
35965 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35966 index 25d3495..d81aaf6 100644
35967 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35968 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35969 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35970 bool can_switch;
35971
35972 spin_lock(&dev->count_lock);
35973 - can_switch = (dev->open_count == 0);
35974 + can_switch = (local_read(&dev->open_count) == 0);
35975 spin_unlock(&dev->count_lock);
35976 return can_switch;
35977 }
35978 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
35979 index d4660cf..70dbe65 100644
35980 --- a/drivers/gpu/drm/r128/r128_cce.c
35981 +++ b/drivers/gpu/drm/r128/r128_cce.c
35982 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
35983
35984 /* GH: Simple idle check.
35985 */
35986 - atomic_set(&dev_priv->idle_count, 0);
35987 + atomic_set_unchecked(&dev_priv->idle_count, 0);
35988
35989 /* We don't support anything other than bus-mastering ring mode,
35990 * but the ring can be in either AGP or PCI space for the ring
35991 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
35992 index 930c71b..499aded 100644
35993 --- a/drivers/gpu/drm/r128/r128_drv.h
35994 +++ b/drivers/gpu/drm/r128/r128_drv.h
35995 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
35996 int is_pci;
35997 unsigned long cce_buffers_offset;
35998
35999 - atomic_t idle_count;
36000 + atomic_unchecked_t idle_count;
36001
36002 int page_flipping;
36003 int current_page;
36004 u32 crtc_offset;
36005 u32 crtc_offset_cntl;
36006
36007 - atomic_t vbl_received;
36008 + atomic_unchecked_t vbl_received;
36009
36010 u32 color_fmt;
36011 unsigned int front_offset;
36012 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36013 index a954c54..9cc595c 100644
36014 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36015 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36016 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36017 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36018 }
36019
36020 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36021 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36022 [DRM_R128_INIT] = compat_r128_init,
36023 [DRM_R128_DEPTH] = compat_r128_depth,
36024 [DRM_R128_STIPPLE] = compat_r128_stipple,
36025 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36026 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36027 {
36028 unsigned int nr = DRM_IOCTL_NR(cmd);
36029 - drm_ioctl_compat_t *fn = NULL;
36030 int ret;
36031
36032 if (nr < DRM_COMMAND_BASE)
36033 return drm_compat_ioctl(filp, cmd, arg);
36034
36035 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36036 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36037 -
36038 - if (fn != NULL)
36039 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36040 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36041 ret = (*fn) (filp, cmd, arg);
36042 - else
36043 + } else
36044 ret = drm_ioctl(filp, cmd, arg);
36045
36046 return ret;
36047 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36048 index 2ea4f09..d391371 100644
36049 --- a/drivers/gpu/drm/r128/r128_irq.c
36050 +++ b/drivers/gpu/drm/r128/r128_irq.c
36051 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36052 if (crtc != 0)
36053 return 0;
36054
36055 - return atomic_read(&dev_priv->vbl_received);
36056 + return atomic_read_unchecked(&dev_priv->vbl_received);
36057 }
36058
36059 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36060 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36061 /* VBLANK interrupt */
36062 if (status & R128_CRTC_VBLANK_INT) {
36063 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36064 - atomic_inc(&dev_priv->vbl_received);
36065 + atomic_inc_unchecked(&dev_priv->vbl_received);
36066 drm_handle_vblank(dev, 0);
36067 return IRQ_HANDLED;
36068 }
36069 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36070 index 19bb7e6..de7e2a2 100644
36071 --- a/drivers/gpu/drm/r128/r128_state.c
36072 +++ b/drivers/gpu/drm/r128/r128_state.c
36073 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36074
36075 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36076 {
36077 - if (atomic_read(&dev_priv->idle_count) == 0)
36078 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36079 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36080 else
36081 - atomic_set(&dev_priv->idle_count, 0);
36082 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36083 }
36084
36085 #endif
36086 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36087 index 5a82b6b..9e69c73 100644
36088 --- a/drivers/gpu/drm/radeon/mkregtable.c
36089 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36090 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36091 regex_t mask_rex;
36092 regmatch_t match[4];
36093 char buf[1024];
36094 - size_t end;
36095 + long end;
36096 int len;
36097 int done = 0;
36098 int r;
36099 unsigned o;
36100 struct offset *offset;
36101 char last_reg_s[10];
36102 - int last_reg;
36103 + unsigned long last_reg;
36104
36105 if (regcomp
36106 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36107 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36108 index 0d6562b..a154330 100644
36109 --- a/drivers/gpu/drm/radeon/radeon_device.c
36110 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36111 @@ -969,7 +969,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36112 bool can_switch;
36113
36114 spin_lock(&dev->count_lock);
36115 - can_switch = (dev->open_count == 0);
36116 + can_switch = (local_read(&dev->open_count) == 0);
36117 spin_unlock(&dev->count_lock);
36118 return can_switch;
36119 }
36120 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36121 index e7fdf16..f4f6490 100644
36122 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36123 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36124 @@ -255,7 +255,7 @@ typedef struct drm_radeon_private {
36125
36126 /* SW interrupt */
36127 wait_queue_head_t swi_queue;
36128 - atomic_t swi_emitted;
36129 + atomic_unchecked_t swi_emitted;
36130 int vblank_crtc;
36131 uint32_t irq_enable_reg;
36132 uint32_t r500_disp_irq_reg;
36133 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36134 index c180df8..5fd8186 100644
36135 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36136 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36137 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36138 request = compat_alloc_user_space(sizeof(*request));
36139 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36140 || __put_user(req32.param, &request->param)
36141 - || __put_user((void __user *)(unsigned long)req32.value,
36142 + || __put_user((unsigned long)req32.value,
36143 &request->value))
36144 return -EFAULT;
36145
36146 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36147 #define compat_radeon_cp_setparam NULL
36148 #endif /* X86_64 || IA64 */
36149
36150 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36151 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36152 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36153 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36154 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36155 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36156 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36157 {
36158 unsigned int nr = DRM_IOCTL_NR(cmd);
36159 - drm_ioctl_compat_t *fn = NULL;
36160 int ret;
36161
36162 if (nr < DRM_COMMAND_BASE)
36163 return drm_compat_ioctl(filp, cmd, arg);
36164
36165 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36166 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36167 -
36168 - if (fn != NULL)
36169 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36170 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36171 ret = (*fn) (filp, cmd, arg);
36172 - else
36173 + } else
36174 ret = drm_ioctl(filp, cmd, arg);
36175
36176 return ret;
36177 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36178 index e771033..a0bc6b3 100644
36179 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36180 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36181 @@ -224,8 +224,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36182 unsigned int ret;
36183 RING_LOCALS;
36184
36185 - atomic_inc(&dev_priv->swi_emitted);
36186 - ret = atomic_read(&dev_priv->swi_emitted);
36187 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36188 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36189
36190 BEGIN_RING(4);
36191 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36192 @@ -351,7 +351,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36193 drm_radeon_private_t *dev_priv =
36194 (drm_radeon_private_t *) dev->dev_private;
36195
36196 - atomic_set(&dev_priv->swi_emitted, 0);
36197 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36198 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36199
36200 dev->max_vblank_count = 0x001fffff;
36201 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36202 index 8e9057b..af6dacb 100644
36203 --- a/drivers/gpu/drm/radeon/radeon_state.c
36204 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36205 @@ -2166,7 +2166,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36206 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36207 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36208
36209 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36210 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36211 sarea_priv->nbox * sizeof(depth_boxes[0])))
36212 return -EFAULT;
36213
36214 @@ -3029,7 +3029,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36215 {
36216 drm_radeon_private_t *dev_priv = dev->dev_private;
36217 drm_radeon_getparam_t *param = data;
36218 - int value;
36219 + int value = 0;
36220
36221 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36222
36223 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36224 index 93f760e..8088227 100644
36225 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36226 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36227 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36228 man->size = size >> PAGE_SHIFT;
36229 }
36230
36231 -static struct vm_operations_struct radeon_ttm_vm_ops;
36232 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36233 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36234
36235 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36236 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36237 }
36238 if (unlikely(ttm_vm_ops == NULL)) {
36239 ttm_vm_ops = vma->vm_ops;
36240 + pax_open_kernel();
36241 radeon_ttm_vm_ops = *ttm_vm_ops;
36242 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36243 + pax_close_kernel();
36244 }
36245 vma->vm_ops = &radeon_ttm_vm_ops;
36246 return 0;
36247 @@ -862,28 +864,33 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36248 sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36249 else
36250 sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36251 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36252 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36253 - radeon_mem_types_list[i].driver_features = 0;
36254 + pax_open_kernel();
36255 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36256 + *(void **)&radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36257 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36258 if (i == 0)
36259 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36260 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36261 else
36262 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36263 -
36264 + *(void **)&radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36265 + pax_close_kernel();
36266 }
36267 /* Add ttm page pool to debugfs */
36268 sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36269 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36270 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36271 - radeon_mem_types_list[i].driver_features = 0;
36272 - radeon_mem_types_list[i++].data = NULL;
36273 + pax_open_kernel();
36274 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36275 + *(void **)&radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36276 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36277 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36278 + pax_close_kernel();
36279 #ifdef CONFIG_SWIOTLB
36280 if (swiotlb_nr_tbl()) {
36281 sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36282 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36283 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36284 - radeon_mem_types_list[i].driver_features = 0;
36285 - radeon_mem_types_list[i++].data = NULL;
36286 + pax_open_kernel();
36287 + *(const char **)&radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36288 + *(void **)&radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36289 + *(u32 *)&radeon_mem_types_list[i].driver_features = 0;
36290 + *(void **)&radeon_mem_types_list[i++].data = NULL;
36291 + pax_close_kernel();
36292 }
36293 #endif
36294 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36295 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36296 index 5706d2a..17aedaa 100644
36297 --- a/drivers/gpu/drm/radeon/rs690.c
36298 +++ b/drivers/gpu/drm/radeon/rs690.c
36299 @@ -304,9 +304,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36300 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36301 rdev->pm.sideport_bandwidth.full)
36302 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36303 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36304 + read_delay_latency.full = dfixed_const(800 * 1000);
36305 read_delay_latency.full = dfixed_div(read_delay_latency,
36306 rdev->pm.igp_sideport_mclk);
36307 + a.full = dfixed_const(370);
36308 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36309 } else {
36310 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36311 rdev->pm.k8_bandwidth.full)
36312 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36313 index bd2a3b4..122d9ad 100644
36314 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36315 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36316 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36317 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36318 struct shrink_control *sc)
36319 {
36320 - static atomic_t start_pool = ATOMIC_INIT(0);
36321 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36322 unsigned i;
36323 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36324 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36325 struct ttm_page_pool *pool;
36326 int shrink_pages = sc->nr_to_scan;
36327
36328 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36329 index 1eb060c..188b1fc 100644
36330 --- a/drivers/gpu/drm/udl/udl_fb.c
36331 +++ b/drivers/gpu/drm/udl/udl_fb.c
36332 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36333 fb_deferred_io_cleanup(info);
36334 kfree(info->fbdefio);
36335 info->fbdefio = NULL;
36336 - info->fbops->fb_mmap = udl_fb_mmap;
36337 }
36338
36339 pr_warn("released /dev/fb%d user=%d count=%d\n",
36340 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36341 index 893a650..6190d3b 100644
36342 --- a/drivers/gpu/drm/via/via_drv.h
36343 +++ b/drivers/gpu/drm/via/via_drv.h
36344 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36345 typedef uint32_t maskarray_t[5];
36346
36347 typedef struct drm_via_irq {
36348 - atomic_t irq_received;
36349 + atomic_unchecked_t irq_received;
36350 uint32_t pending_mask;
36351 uint32_t enable_mask;
36352 wait_queue_head_t irq_queue;
36353 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36354 struct timeval last_vblank;
36355 int last_vblank_valid;
36356 unsigned usec_per_vblank;
36357 - atomic_t vbl_received;
36358 + atomic_unchecked_t vbl_received;
36359 drm_via_state_t hc_state;
36360 char pci_buf[VIA_PCI_BUF_SIZE];
36361 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36362 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36363 index ac98964..5dbf512 100644
36364 --- a/drivers/gpu/drm/via/via_irq.c
36365 +++ b/drivers/gpu/drm/via/via_irq.c
36366 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36367 if (crtc != 0)
36368 return 0;
36369
36370 - return atomic_read(&dev_priv->vbl_received);
36371 + return atomic_read_unchecked(&dev_priv->vbl_received);
36372 }
36373
36374 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36375 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36376
36377 status = VIA_READ(VIA_REG_INTERRUPT);
36378 if (status & VIA_IRQ_VBLANK_PENDING) {
36379 - atomic_inc(&dev_priv->vbl_received);
36380 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36381 + atomic_inc_unchecked(&dev_priv->vbl_received);
36382 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36383 do_gettimeofday(&cur_vblank);
36384 if (dev_priv->last_vblank_valid) {
36385 dev_priv->usec_per_vblank =
36386 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36387 dev_priv->last_vblank = cur_vblank;
36388 dev_priv->last_vblank_valid = 1;
36389 }
36390 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36391 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36392 DRM_DEBUG("US per vblank is: %u\n",
36393 dev_priv->usec_per_vblank);
36394 }
36395 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36396
36397 for (i = 0; i < dev_priv->num_irqs; ++i) {
36398 if (status & cur_irq->pending_mask) {
36399 - atomic_inc(&cur_irq->irq_received);
36400 + atomic_inc_unchecked(&cur_irq->irq_received);
36401 DRM_WAKEUP(&cur_irq->irq_queue);
36402 handled = 1;
36403 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36404 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36405 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36406 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36407 masks[irq][4]));
36408 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36409 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36410 } else {
36411 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36412 (((cur_irq_sequence =
36413 - atomic_read(&cur_irq->irq_received)) -
36414 + atomic_read_unchecked(&cur_irq->irq_received)) -
36415 *sequence) <= (1 << 23)));
36416 }
36417 *sequence = cur_irq_sequence;
36418 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36419 }
36420
36421 for (i = 0; i < dev_priv->num_irqs; ++i) {
36422 - atomic_set(&cur_irq->irq_received, 0);
36423 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36424 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36425 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36426 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36427 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36428 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36429 case VIA_IRQ_RELATIVE:
36430 irqwait->request.sequence +=
36431 - atomic_read(&cur_irq->irq_received);
36432 + atomic_read_unchecked(&cur_irq->irq_received);
36433 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36434 case VIA_IRQ_ABSOLUTE:
36435 break;
36436 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36437 index 13aeda7..4a952d1 100644
36438 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36439 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36440 @@ -290,7 +290,7 @@ struct vmw_private {
36441 * Fencing and IRQs.
36442 */
36443
36444 - atomic_t marker_seq;
36445 + atomic_unchecked_t marker_seq;
36446 wait_queue_head_t fence_queue;
36447 wait_queue_head_t fifo_queue;
36448 int fence_queue_waiters; /* Protected by hw_mutex */
36449 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36450 index 3eb1486..0a47ee9 100644
36451 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36452 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36453 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36454 (unsigned int) min,
36455 (unsigned int) fifo->capabilities);
36456
36457 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36458 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36459 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36460 vmw_marker_queue_init(&fifo->marker_queue);
36461 return vmw_fifo_send_fence(dev_priv, &dummy);
36462 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36463 if (reserveable)
36464 iowrite32(bytes, fifo_mem +
36465 SVGA_FIFO_RESERVED);
36466 - return fifo_mem + (next_cmd >> 2);
36467 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36468 } else {
36469 need_bounce = true;
36470 }
36471 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36472
36473 fm = vmw_fifo_reserve(dev_priv, bytes);
36474 if (unlikely(fm == NULL)) {
36475 - *seqno = atomic_read(&dev_priv->marker_seq);
36476 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36477 ret = -ENOMEM;
36478 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36479 false, 3*HZ);
36480 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36481 }
36482
36483 do {
36484 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36485 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36486 } while (*seqno == 0);
36487
36488 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36489 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36490 index 4640adb..e1384ed 100644
36491 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36492 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36493 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36494 * emitted. Then the fence is stale and signaled.
36495 */
36496
36497 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36498 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36499 > VMW_FENCE_WRAP);
36500
36501 return ret;
36502 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36503
36504 if (fifo_idle)
36505 down_read(&fifo_state->rwsem);
36506 - signal_seq = atomic_read(&dev_priv->marker_seq);
36507 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36508 ret = 0;
36509
36510 for (;;) {
36511 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36512 index 8a8725c..afed796 100644
36513 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36514 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36515 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36516 while (!vmw_lag_lt(queue, us)) {
36517 spin_lock(&queue->lock);
36518 if (list_empty(&queue->head))
36519 - seqno = atomic_read(&dev_priv->marker_seq);
36520 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36521 else {
36522 marker = list_first_entry(&queue->head,
36523 struct vmw_marker, head);
36524 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36525 index ceb3040..6160c5c 100644
36526 --- a/drivers/hid/hid-core.c
36527 +++ b/drivers/hid/hid-core.c
36528 @@ -2242,7 +2242,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36529
36530 int hid_add_device(struct hid_device *hdev)
36531 {
36532 - static atomic_t id = ATOMIC_INIT(0);
36533 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36534 int ret;
36535
36536 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36537 @@ -2276,7 +2276,7 @@ int hid_add_device(struct hid_device *hdev)
36538 /* XXX hack, any other cleaner solution after the driver core
36539 * is converted to allow more than 20 bytes as the device name? */
36540 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36541 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36542 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36543
36544 hid_debug_register(hdev, dev_name(&hdev->dev));
36545 ret = device_add(&hdev->dev);
36546 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36547 index eec3291..8ed706b 100644
36548 --- a/drivers/hid/hid-wiimote-debug.c
36549 +++ b/drivers/hid/hid-wiimote-debug.c
36550 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36551 else if (size == 0)
36552 return -EIO;
36553
36554 - if (copy_to_user(u, buf, size))
36555 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36556 return -EFAULT;
36557
36558 *off += size;
36559 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36560 index 773a2f2..7ce08bc 100644
36561 --- a/drivers/hv/channel.c
36562 +++ b/drivers/hv/channel.c
36563 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36564 int ret = 0;
36565 int t;
36566
36567 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36568 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36569 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36570 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36571
36572 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36573 if (ret)
36574 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36575 index 3648f8f..30ef30d 100644
36576 --- a/drivers/hv/hv.c
36577 +++ b/drivers/hv/hv.c
36578 @@ -111,7 +111,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36579 u64 output_address = (output) ? virt_to_phys(output) : 0;
36580 u32 output_address_hi = output_address >> 32;
36581 u32 output_address_lo = output_address & 0xFFFFFFFF;
36582 - void *hypercall_page = hv_context.hypercall_page;
36583 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36584
36585 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36586 "=a"(hv_status_lo) : "d" (control_hi),
36587 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36588 index d8d1fad..b91caf7 100644
36589 --- a/drivers/hv/hyperv_vmbus.h
36590 +++ b/drivers/hv/hyperv_vmbus.h
36591 @@ -594,7 +594,7 @@ enum vmbus_connect_state {
36592 struct vmbus_connection {
36593 enum vmbus_connect_state conn_state;
36594
36595 - atomic_t next_gpadl_handle;
36596 + atomic_unchecked_t next_gpadl_handle;
36597
36598 /*
36599 * Represents channel interrupts. Each bit position represents a
36600 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36601 index 8e1a9ec..4687821 100644
36602 --- a/drivers/hv/vmbus_drv.c
36603 +++ b/drivers/hv/vmbus_drv.c
36604 @@ -629,10 +629,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36605 {
36606 int ret = 0;
36607
36608 - static atomic_t device_num = ATOMIC_INIT(0);
36609 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36610
36611 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36612 - atomic_inc_return(&device_num));
36613 + atomic_inc_return_unchecked(&device_num));
36614
36615 child_device_obj->device.bus = &hv_bus;
36616 child_device_obj->device.parent = &hv_acpi_dev->dev;
36617 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36618 index 1672e2a..4a6297c 100644
36619 --- a/drivers/hwmon/acpi_power_meter.c
36620 +++ b/drivers/hwmon/acpi_power_meter.c
36621 @@ -117,7 +117,7 @@ struct sensor_template {
36622 struct device_attribute *devattr,
36623 const char *buf, size_t count);
36624 int index;
36625 -};
36626 +} __do_const;
36627
36628 /* Averaging interval */
36629 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36630 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36631 struct sensor_template *attrs)
36632 {
36633 struct device *dev = &resource->acpi_dev->dev;
36634 - struct sensor_device_attribute *sensors =
36635 + sensor_device_attribute_no_const *sensors =
36636 &resource->sensors[resource->num_sensors];
36637 int res = 0;
36638
36639 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36640 index b41baff..4953e4d 100644
36641 --- a/drivers/hwmon/applesmc.c
36642 +++ b/drivers/hwmon/applesmc.c
36643 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36644 {
36645 struct applesmc_node_group *grp;
36646 struct applesmc_dev_attr *node;
36647 - struct attribute *attr;
36648 + attribute_no_const *attr;
36649 int ret, i;
36650
36651 for (grp = groups; grp->format; grp++) {
36652 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36653 index 56dbcfb..9874bf1 100644
36654 --- a/drivers/hwmon/asus_atk0110.c
36655 +++ b/drivers/hwmon/asus_atk0110.c
36656 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36657 struct atk_sensor_data {
36658 struct list_head list;
36659 struct atk_data *data;
36660 - struct device_attribute label_attr;
36661 - struct device_attribute input_attr;
36662 - struct device_attribute limit1_attr;
36663 - struct device_attribute limit2_attr;
36664 + device_attribute_no_const label_attr;
36665 + device_attribute_no_const input_attr;
36666 + device_attribute_no_const limit1_attr;
36667 + device_attribute_no_const limit2_attr;
36668 char label_attr_name[ATTR_NAME_SIZE];
36669 char input_attr_name[ATTR_NAME_SIZE];
36670 char limit1_attr_name[ATTR_NAME_SIZE];
36671 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36672 static struct device_attribute atk_name_attr =
36673 __ATTR(name, 0444, atk_name_show, NULL);
36674
36675 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36676 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36677 sysfs_show_func show)
36678 {
36679 sysfs_attr_init(&attr->attr);
36680 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36681 index d64923d..72591e8 100644
36682 --- a/drivers/hwmon/coretemp.c
36683 +++ b/drivers/hwmon/coretemp.c
36684 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36685 return NOTIFY_OK;
36686 }
36687
36688 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36689 +static struct notifier_block coretemp_cpu_notifier = {
36690 .notifier_call = coretemp_cpu_callback,
36691 };
36692
36693 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36694 index a14f634..2916ee2 100644
36695 --- a/drivers/hwmon/ibmaem.c
36696 +++ b/drivers/hwmon/ibmaem.c
36697 @@ -925,7 +925,7 @@ static int aem_register_sensors(struct aem_data *data,
36698 struct aem_rw_sensor_template *rw)
36699 {
36700 struct device *dev = &data->pdev->dev;
36701 - struct sensor_device_attribute *sensors = data->sensors;
36702 + sensor_device_attribute_no_const *sensors = data->sensors;
36703 int err;
36704
36705 /* Set up read-only sensors */
36706 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36707 index 7d19b1b..8fdaaac 100644
36708 --- a/drivers/hwmon/pmbus/pmbus_core.c
36709 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36710 @@ -811,7 +811,7 @@ static ssize_t pmbus_show_label(struct device *dev,
36711
36712 #define PMBUS_ADD_ATTR(data, _name, _idx, _mode, _type, _show, _set) \
36713 do { \
36714 - struct sensor_device_attribute *a \
36715 + sensor_device_attribute_no_const *a \
36716 = &data->_type##s[data->num_##_type##s].attribute; \
36717 BUG_ON(data->num_attributes >= data->max_attributes); \
36718 sysfs_attr_init(&a->dev_attr.attr); \
36719 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36720 index 8047fed..1e956f0 100644
36721 --- a/drivers/hwmon/sht15.c
36722 +++ b/drivers/hwmon/sht15.c
36723 @@ -169,7 +169,7 @@ struct sht15_data {
36724 int supply_uV;
36725 bool supply_uV_valid;
36726 struct work_struct update_supply_work;
36727 - atomic_t interrupt_handled;
36728 + atomic_unchecked_t interrupt_handled;
36729 };
36730
36731 /**
36732 @@ -512,13 +512,13 @@ static int sht15_measurement(struct sht15_data *data,
36733 return ret;
36734
36735 gpio_direction_input(data->pdata->gpio_data);
36736 - atomic_set(&data->interrupt_handled, 0);
36737 + atomic_set_unchecked(&data->interrupt_handled, 0);
36738
36739 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36740 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36741 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36742 /* Only relevant if the interrupt hasn't occurred. */
36743 - if (!atomic_read(&data->interrupt_handled))
36744 + if (!atomic_read_unchecked(&data->interrupt_handled))
36745 schedule_work(&data->read_work);
36746 }
36747 ret = wait_event_timeout(data->wait_queue,
36748 @@ -785,7 +785,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36749
36750 /* First disable the interrupt */
36751 disable_irq_nosync(irq);
36752 - atomic_inc(&data->interrupt_handled);
36753 + atomic_inc_unchecked(&data->interrupt_handled);
36754 /* Then schedule a reading work struct */
36755 if (data->state != SHT15_READING_NOTHING)
36756 schedule_work(&data->read_work);
36757 @@ -807,11 +807,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36758 * If not, then start the interrupt again - care here as could
36759 * have gone low in meantime so verify it hasn't!
36760 */
36761 - atomic_set(&data->interrupt_handled, 0);
36762 + atomic_set_unchecked(&data->interrupt_handled, 0);
36763 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36764 /* If still not occurred or another handler was scheduled */
36765 if (gpio_get_value(data->pdata->gpio_data)
36766 - || atomic_read(&data->interrupt_handled))
36767 + || atomic_read_unchecked(&data->interrupt_handled))
36768 return;
36769 }
36770
36771 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36772 index 76f157b..9c0db1b 100644
36773 --- a/drivers/hwmon/via-cputemp.c
36774 +++ b/drivers/hwmon/via-cputemp.c
36775 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36776 return NOTIFY_OK;
36777 }
36778
36779 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36780 +static struct notifier_block via_cputemp_cpu_notifier = {
36781 .notifier_call = via_cputemp_cpu_callback,
36782 };
36783
36784 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36785 index 378fcb5..5e91fa8 100644
36786 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36787 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36788 @@ -43,7 +43,7 @@
36789 extern struct i2c_adapter amd756_smbus;
36790
36791 static struct i2c_adapter *s4882_adapter;
36792 -static struct i2c_algorithm *s4882_algo;
36793 +static i2c_algorithm_no_const *s4882_algo;
36794
36795 /* Wrapper access functions for multiplexed SMBus */
36796 static DEFINE_MUTEX(amd756_lock);
36797 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36798 index 29015eb..af2d8e9 100644
36799 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36800 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36801 @@ -41,7 +41,7 @@
36802 extern struct i2c_adapter *nforce2_smbus;
36803
36804 static struct i2c_adapter *s4985_adapter;
36805 -static struct i2c_algorithm *s4985_algo;
36806 +static i2c_algorithm_no_const *s4985_algo;
36807
36808 /* Wrapper access functions for multiplexed SMBus */
36809 static DEFINE_MUTEX(nforce2_lock);
36810 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36811 index 8126824..55a2798 100644
36812 --- a/drivers/ide/ide-cd.c
36813 +++ b/drivers/ide/ide-cd.c
36814 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36815 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36816 if ((unsigned long)buf & alignment
36817 || blk_rq_bytes(rq) & q->dma_pad_mask
36818 - || object_is_on_stack(buf))
36819 + || object_starts_on_stack(buf))
36820 drive->dma = 0;
36821 }
36822 }
36823 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
36824 index 8848f16..f8e6dd8 100644
36825 --- a/drivers/iio/industrialio-core.c
36826 +++ b/drivers/iio/industrialio-core.c
36827 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
36828 }
36829
36830 static
36831 -int __iio_device_attr_init(struct device_attribute *dev_attr,
36832 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
36833 const char *postfix,
36834 struct iio_chan_spec const *chan,
36835 ssize_t (*readfunc)(struct device *dev,
36836 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
36837 index 394fea2..c833880 100644
36838 --- a/drivers/infiniband/core/cm.c
36839 +++ b/drivers/infiniband/core/cm.c
36840 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
36841
36842 struct cm_counter_group {
36843 struct kobject obj;
36844 - atomic_long_t counter[CM_ATTR_COUNT];
36845 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
36846 };
36847
36848 struct cm_counter_attribute {
36849 @@ -1394,7 +1394,7 @@ static void cm_dup_req_handler(struct cm_work *work,
36850 struct ib_mad_send_buf *msg = NULL;
36851 int ret;
36852
36853 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36854 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36855 counter[CM_REQ_COUNTER]);
36856
36857 /* Quick state check to discard duplicate REQs. */
36858 @@ -1778,7 +1778,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
36859 if (!cm_id_priv)
36860 return;
36861
36862 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36863 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36864 counter[CM_REP_COUNTER]);
36865 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
36866 if (ret)
36867 @@ -1945,7 +1945,7 @@ static int cm_rtu_handler(struct cm_work *work)
36868 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
36869 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
36870 spin_unlock_irq(&cm_id_priv->lock);
36871 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36872 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36873 counter[CM_RTU_COUNTER]);
36874 goto out;
36875 }
36876 @@ -2128,7 +2128,7 @@ static int cm_dreq_handler(struct cm_work *work)
36877 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
36878 dreq_msg->local_comm_id);
36879 if (!cm_id_priv) {
36880 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36881 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36882 counter[CM_DREQ_COUNTER]);
36883 cm_issue_drep(work->port, work->mad_recv_wc);
36884 return -EINVAL;
36885 @@ -2153,7 +2153,7 @@ static int cm_dreq_handler(struct cm_work *work)
36886 case IB_CM_MRA_REP_RCVD:
36887 break;
36888 case IB_CM_TIMEWAIT:
36889 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36890 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36891 counter[CM_DREQ_COUNTER]);
36892 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36893 goto unlock;
36894 @@ -2167,7 +2167,7 @@ static int cm_dreq_handler(struct cm_work *work)
36895 cm_free_msg(msg);
36896 goto deref;
36897 case IB_CM_DREQ_RCVD:
36898 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36899 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36900 counter[CM_DREQ_COUNTER]);
36901 goto unlock;
36902 default:
36903 @@ -2534,7 +2534,7 @@ static int cm_mra_handler(struct cm_work *work)
36904 ib_modify_mad(cm_id_priv->av.port->mad_agent,
36905 cm_id_priv->msg, timeout)) {
36906 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
36907 - atomic_long_inc(&work->port->
36908 + atomic_long_inc_unchecked(&work->port->
36909 counter_group[CM_RECV_DUPLICATES].
36910 counter[CM_MRA_COUNTER]);
36911 goto out;
36912 @@ -2543,7 +2543,7 @@ static int cm_mra_handler(struct cm_work *work)
36913 break;
36914 case IB_CM_MRA_REQ_RCVD:
36915 case IB_CM_MRA_REP_RCVD:
36916 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36917 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36918 counter[CM_MRA_COUNTER]);
36919 /* fall through */
36920 default:
36921 @@ -2705,7 +2705,7 @@ static int cm_lap_handler(struct cm_work *work)
36922 case IB_CM_LAP_IDLE:
36923 break;
36924 case IB_CM_MRA_LAP_SENT:
36925 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36926 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36927 counter[CM_LAP_COUNTER]);
36928 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
36929 goto unlock;
36930 @@ -2721,7 +2721,7 @@ static int cm_lap_handler(struct cm_work *work)
36931 cm_free_msg(msg);
36932 goto deref;
36933 case IB_CM_LAP_RCVD:
36934 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36935 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36936 counter[CM_LAP_COUNTER]);
36937 goto unlock;
36938 default:
36939 @@ -3005,7 +3005,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
36940 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
36941 if (cur_cm_id_priv) {
36942 spin_unlock_irq(&cm.lock);
36943 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
36944 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
36945 counter[CM_SIDR_REQ_COUNTER]);
36946 goto out; /* Duplicate message. */
36947 }
36948 @@ -3217,10 +3217,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
36949 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
36950 msg->retries = 1;
36951
36952 - atomic_long_add(1 + msg->retries,
36953 + atomic_long_add_unchecked(1 + msg->retries,
36954 &port->counter_group[CM_XMIT].counter[attr_index]);
36955 if (msg->retries)
36956 - atomic_long_add(msg->retries,
36957 + atomic_long_add_unchecked(msg->retries,
36958 &port->counter_group[CM_XMIT_RETRIES].
36959 counter[attr_index]);
36960
36961 @@ -3430,7 +3430,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
36962 }
36963
36964 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
36965 - atomic_long_inc(&port->counter_group[CM_RECV].
36966 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
36967 counter[attr_id - CM_ATTR_ID_OFFSET]);
36968
36969 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
36970 @@ -3635,7 +3635,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
36971 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
36972
36973 return sprintf(buf, "%ld\n",
36974 - atomic_long_read(&group->counter[cm_attr->index]));
36975 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
36976 }
36977
36978 static const struct sysfs_ops cm_counter_ops = {
36979 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
36980 index 176c8f9..2627b62 100644
36981 --- a/drivers/infiniband/core/fmr_pool.c
36982 +++ b/drivers/infiniband/core/fmr_pool.c
36983 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
36984
36985 struct task_struct *thread;
36986
36987 - atomic_t req_ser;
36988 - atomic_t flush_ser;
36989 + atomic_unchecked_t req_ser;
36990 + atomic_unchecked_t flush_ser;
36991
36992 wait_queue_head_t force_wait;
36993 };
36994 @@ -180,10 +180,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
36995 struct ib_fmr_pool *pool = pool_ptr;
36996
36997 do {
36998 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
36999 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37000 ib_fmr_batch_release(pool);
37001
37002 - atomic_inc(&pool->flush_ser);
37003 + atomic_inc_unchecked(&pool->flush_ser);
37004 wake_up_interruptible(&pool->force_wait);
37005
37006 if (pool->flush_function)
37007 @@ -191,7 +191,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37008 }
37009
37010 set_current_state(TASK_INTERRUPTIBLE);
37011 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37012 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37013 !kthread_should_stop())
37014 schedule();
37015 __set_current_state(TASK_RUNNING);
37016 @@ -283,8 +283,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37017 pool->dirty_watermark = params->dirty_watermark;
37018 pool->dirty_len = 0;
37019 spin_lock_init(&pool->pool_lock);
37020 - atomic_set(&pool->req_ser, 0);
37021 - atomic_set(&pool->flush_ser, 0);
37022 + atomic_set_unchecked(&pool->req_ser, 0);
37023 + atomic_set_unchecked(&pool->flush_ser, 0);
37024 init_waitqueue_head(&pool->force_wait);
37025
37026 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37027 @@ -412,11 +412,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37028 }
37029 spin_unlock_irq(&pool->pool_lock);
37030
37031 - serial = atomic_inc_return(&pool->req_ser);
37032 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37033 wake_up_process(pool->thread);
37034
37035 if (wait_event_interruptible(pool->force_wait,
37036 - atomic_read(&pool->flush_ser) - serial >= 0))
37037 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37038 return -EINTR;
37039
37040 return 0;
37041 @@ -526,7 +526,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37042 } else {
37043 list_add_tail(&fmr->list, &pool->dirty_list);
37044 if (++pool->dirty_len >= pool->dirty_watermark) {
37045 - atomic_inc(&pool->req_ser);
37046 + atomic_inc_unchecked(&pool->req_ser);
37047 wake_up_process(pool->thread);
37048 }
37049 }
37050 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37051 index afd8179..598063f 100644
37052 --- a/drivers/infiniband/hw/cxgb4/mem.c
37053 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37054 @@ -122,7 +122,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37055 int err;
37056 struct fw_ri_tpte tpt;
37057 u32 stag_idx;
37058 - static atomic_t key;
37059 + static atomic_unchecked_t key;
37060
37061 if (c4iw_fatal_error(rdev))
37062 return -EIO;
37063 @@ -139,7 +139,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37064 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37065 rdev->stats.stag.max = rdev->stats.stag.cur;
37066 mutex_unlock(&rdev->stats.lock);
37067 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37068 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37069 }
37070 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37071 __func__, stag_state, type, pdid, stag_idx);
37072 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37073 index 79b3dbc..96e5fcc 100644
37074 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37075 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37076 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37077 struct ib_atomic_eth *ateth;
37078 struct ipath_ack_entry *e;
37079 u64 vaddr;
37080 - atomic64_t *maddr;
37081 + atomic64_unchecked_t *maddr;
37082 u64 sdata;
37083 u32 rkey;
37084 u8 next;
37085 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37086 IB_ACCESS_REMOTE_ATOMIC)))
37087 goto nack_acc_unlck;
37088 /* Perform atomic OP and save result. */
37089 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37090 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37091 sdata = be64_to_cpu(ateth->swap_data);
37092 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37093 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37094 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37095 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37096 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37097 be64_to_cpu(ateth->compare_data),
37098 sdata);
37099 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37100 index 1f95bba..9530f87 100644
37101 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37102 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37103 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37104 unsigned long flags;
37105 struct ib_wc wc;
37106 u64 sdata;
37107 - atomic64_t *maddr;
37108 + atomic64_unchecked_t *maddr;
37109 enum ib_wc_status send_status;
37110
37111 /*
37112 @@ -382,11 +382,11 @@ again:
37113 IB_ACCESS_REMOTE_ATOMIC)))
37114 goto acc_err;
37115 /* Perform atomic OP and save result. */
37116 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37117 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37118 sdata = wqe->wr.wr.atomic.compare_add;
37119 *(u64 *) sqp->s_sge.sge.vaddr =
37120 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37121 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37122 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37123 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37124 sdata, wqe->wr.wr.atomic.swap);
37125 goto send_comp;
37126 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37127 index 9d3e5c1..d9afe4a 100644
37128 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37129 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37130 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37131 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37132 }
37133
37134 -int mthca_QUERY_FW(struct mthca_dev *dev)
37135 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37136 {
37137 struct mthca_mailbox *mailbox;
37138 u32 *outbox;
37139 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37140 index ed9a989..e0c5871 100644
37141 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37142 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37143 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37144 return key;
37145 }
37146
37147 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37148 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37149 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37150 {
37151 struct mthca_mailbox *mailbox;
37152 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37153 index 5b152a3..c1f3e83 100644
37154 --- a/drivers/infiniband/hw/nes/nes.c
37155 +++ b/drivers/infiniband/hw/nes/nes.c
37156 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37157 LIST_HEAD(nes_adapter_list);
37158 static LIST_HEAD(nes_dev_list);
37159
37160 -atomic_t qps_destroyed;
37161 +atomic_unchecked_t qps_destroyed;
37162
37163 static unsigned int ee_flsh_adapter;
37164 static unsigned int sysfs_nonidx_addr;
37165 @@ -267,7 +267,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37166 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37167 struct nes_adapter *nesadapter = nesdev->nesadapter;
37168
37169 - atomic_inc(&qps_destroyed);
37170 + atomic_inc_unchecked(&qps_destroyed);
37171
37172 /* Free the control structures */
37173
37174 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37175 index 33cc589..3bd6538 100644
37176 --- a/drivers/infiniband/hw/nes/nes.h
37177 +++ b/drivers/infiniband/hw/nes/nes.h
37178 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37179 extern unsigned int wqm_quanta;
37180 extern struct list_head nes_adapter_list;
37181
37182 -extern atomic_t cm_connects;
37183 -extern atomic_t cm_accepts;
37184 -extern atomic_t cm_disconnects;
37185 -extern atomic_t cm_closes;
37186 -extern atomic_t cm_connecteds;
37187 -extern atomic_t cm_connect_reqs;
37188 -extern atomic_t cm_rejects;
37189 -extern atomic_t mod_qp_timouts;
37190 -extern atomic_t qps_created;
37191 -extern atomic_t qps_destroyed;
37192 -extern atomic_t sw_qps_destroyed;
37193 +extern atomic_unchecked_t cm_connects;
37194 +extern atomic_unchecked_t cm_accepts;
37195 +extern atomic_unchecked_t cm_disconnects;
37196 +extern atomic_unchecked_t cm_closes;
37197 +extern atomic_unchecked_t cm_connecteds;
37198 +extern atomic_unchecked_t cm_connect_reqs;
37199 +extern atomic_unchecked_t cm_rejects;
37200 +extern atomic_unchecked_t mod_qp_timouts;
37201 +extern atomic_unchecked_t qps_created;
37202 +extern atomic_unchecked_t qps_destroyed;
37203 +extern atomic_unchecked_t sw_qps_destroyed;
37204 extern u32 mh_detected;
37205 extern u32 mh_pauses_sent;
37206 extern u32 cm_packets_sent;
37207 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37208 extern u32 cm_packets_received;
37209 extern u32 cm_packets_dropped;
37210 extern u32 cm_packets_retrans;
37211 -extern atomic_t cm_listens_created;
37212 -extern atomic_t cm_listens_destroyed;
37213 +extern atomic_unchecked_t cm_listens_created;
37214 +extern atomic_unchecked_t cm_listens_destroyed;
37215 extern u32 cm_backlog_drops;
37216 -extern atomic_t cm_loopbacks;
37217 -extern atomic_t cm_nodes_created;
37218 -extern atomic_t cm_nodes_destroyed;
37219 -extern atomic_t cm_accel_dropped_pkts;
37220 -extern atomic_t cm_resets_recvd;
37221 -extern atomic_t pau_qps_created;
37222 -extern atomic_t pau_qps_destroyed;
37223 +extern atomic_unchecked_t cm_loopbacks;
37224 +extern atomic_unchecked_t cm_nodes_created;
37225 +extern atomic_unchecked_t cm_nodes_destroyed;
37226 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37227 +extern atomic_unchecked_t cm_resets_recvd;
37228 +extern atomic_unchecked_t pau_qps_created;
37229 +extern atomic_unchecked_t pau_qps_destroyed;
37230
37231 extern u32 int_mod_timer_init;
37232 extern u32 int_mod_cq_depth_256;
37233 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37234 index 22ea67e..dcbe3bc 100644
37235 --- a/drivers/infiniband/hw/nes/nes_cm.c
37236 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37237 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37238 u32 cm_packets_retrans;
37239 u32 cm_packets_created;
37240 u32 cm_packets_received;
37241 -atomic_t cm_listens_created;
37242 -atomic_t cm_listens_destroyed;
37243 +atomic_unchecked_t cm_listens_created;
37244 +atomic_unchecked_t cm_listens_destroyed;
37245 u32 cm_backlog_drops;
37246 -atomic_t cm_loopbacks;
37247 -atomic_t cm_nodes_created;
37248 -atomic_t cm_nodes_destroyed;
37249 -atomic_t cm_accel_dropped_pkts;
37250 -atomic_t cm_resets_recvd;
37251 +atomic_unchecked_t cm_loopbacks;
37252 +atomic_unchecked_t cm_nodes_created;
37253 +atomic_unchecked_t cm_nodes_destroyed;
37254 +atomic_unchecked_t cm_accel_dropped_pkts;
37255 +atomic_unchecked_t cm_resets_recvd;
37256
37257 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37258 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37259 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37260
37261 static struct nes_cm_core *g_cm_core;
37262
37263 -atomic_t cm_connects;
37264 -atomic_t cm_accepts;
37265 -atomic_t cm_disconnects;
37266 -atomic_t cm_closes;
37267 -atomic_t cm_connecteds;
37268 -atomic_t cm_connect_reqs;
37269 -atomic_t cm_rejects;
37270 +atomic_unchecked_t cm_connects;
37271 +atomic_unchecked_t cm_accepts;
37272 +atomic_unchecked_t cm_disconnects;
37273 +atomic_unchecked_t cm_closes;
37274 +atomic_unchecked_t cm_connecteds;
37275 +atomic_unchecked_t cm_connect_reqs;
37276 +atomic_unchecked_t cm_rejects;
37277
37278 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37279 {
37280 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37281 kfree(listener);
37282 listener = NULL;
37283 ret = 0;
37284 - atomic_inc(&cm_listens_destroyed);
37285 + atomic_inc_unchecked(&cm_listens_destroyed);
37286 } else {
37287 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37288 }
37289 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37290 cm_node->rem_mac);
37291
37292 add_hte_node(cm_core, cm_node);
37293 - atomic_inc(&cm_nodes_created);
37294 + atomic_inc_unchecked(&cm_nodes_created);
37295
37296 return cm_node;
37297 }
37298 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37299 }
37300
37301 atomic_dec(&cm_core->node_cnt);
37302 - atomic_inc(&cm_nodes_destroyed);
37303 + atomic_inc_unchecked(&cm_nodes_destroyed);
37304 nesqp = cm_node->nesqp;
37305 if (nesqp) {
37306 nesqp->cm_node = NULL;
37307 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37308
37309 static void drop_packet(struct sk_buff *skb)
37310 {
37311 - atomic_inc(&cm_accel_dropped_pkts);
37312 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37313 dev_kfree_skb_any(skb);
37314 }
37315
37316 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37317 {
37318
37319 int reset = 0; /* whether to send reset in case of err.. */
37320 - atomic_inc(&cm_resets_recvd);
37321 + atomic_inc_unchecked(&cm_resets_recvd);
37322 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37323 " refcnt=%d\n", cm_node, cm_node->state,
37324 atomic_read(&cm_node->ref_count));
37325 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37326 rem_ref_cm_node(cm_node->cm_core, cm_node);
37327 return NULL;
37328 }
37329 - atomic_inc(&cm_loopbacks);
37330 + atomic_inc_unchecked(&cm_loopbacks);
37331 loopbackremotenode->loopbackpartner = cm_node;
37332 loopbackremotenode->tcp_cntxt.rcv_wscale =
37333 NES_CM_DEFAULT_RCV_WND_SCALE;
37334 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37335 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37336 else {
37337 rem_ref_cm_node(cm_core, cm_node);
37338 - atomic_inc(&cm_accel_dropped_pkts);
37339 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37340 dev_kfree_skb_any(skb);
37341 }
37342 break;
37343 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37344
37345 if ((cm_id) && (cm_id->event_handler)) {
37346 if (issue_disconn) {
37347 - atomic_inc(&cm_disconnects);
37348 + atomic_inc_unchecked(&cm_disconnects);
37349 cm_event.event = IW_CM_EVENT_DISCONNECT;
37350 cm_event.status = disconn_status;
37351 cm_event.local_addr = cm_id->local_addr;
37352 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37353 }
37354
37355 if (issue_close) {
37356 - atomic_inc(&cm_closes);
37357 + atomic_inc_unchecked(&cm_closes);
37358 nes_disconnect(nesqp, 1);
37359
37360 cm_id->provider_data = nesqp;
37361 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37362
37363 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37364 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37365 - atomic_inc(&cm_accepts);
37366 + atomic_inc_unchecked(&cm_accepts);
37367
37368 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37369 netdev_refcnt_read(nesvnic->netdev));
37370 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37371 struct nes_cm_core *cm_core;
37372 u8 *start_buff;
37373
37374 - atomic_inc(&cm_rejects);
37375 + atomic_inc_unchecked(&cm_rejects);
37376 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37377 loopback = cm_node->loopbackpartner;
37378 cm_core = cm_node->cm_core;
37379 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37380 ntohl(cm_id->local_addr.sin_addr.s_addr),
37381 ntohs(cm_id->local_addr.sin_port));
37382
37383 - atomic_inc(&cm_connects);
37384 + atomic_inc_unchecked(&cm_connects);
37385 nesqp->active_conn = 1;
37386
37387 /* cache the cm_id in the qp */
37388 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37389 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37390 return err;
37391 }
37392 - atomic_inc(&cm_listens_created);
37393 + atomic_inc_unchecked(&cm_listens_created);
37394 }
37395
37396 cm_id->add_ref(cm_id);
37397 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37398
37399 if (nesqp->destroyed)
37400 return;
37401 - atomic_inc(&cm_connecteds);
37402 + atomic_inc_unchecked(&cm_connecteds);
37403 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37404 " local port 0x%04X. jiffies = %lu.\n",
37405 nesqp->hwqp.qp_id,
37406 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37407
37408 cm_id->add_ref(cm_id);
37409 ret = cm_id->event_handler(cm_id, &cm_event);
37410 - atomic_inc(&cm_closes);
37411 + atomic_inc_unchecked(&cm_closes);
37412 cm_event.event = IW_CM_EVENT_CLOSE;
37413 cm_event.status = 0;
37414 cm_event.provider_data = cm_id->provider_data;
37415 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37416 return;
37417 cm_id = cm_node->cm_id;
37418
37419 - atomic_inc(&cm_connect_reqs);
37420 + atomic_inc_unchecked(&cm_connect_reqs);
37421 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37422 cm_node, cm_id, jiffies);
37423
37424 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37425 return;
37426 cm_id = cm_node->cm_id;
37427
37428 - atomic_inc(&cm_connect_reqs);
37429 + atomic_inc_unchecked(&cm_connect_reqs);
37430 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37431 cm_node, cm_id, jiffies);
37432
37433 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37434 index 4166452..fc952c3 100644
37435 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37436 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37437 @@ -40,8 +40,8 @@
37438 #include "nes.h"
37439 #include "nes_mgt.h"
37440
37441 -atomic_t pau_qps_created;
37442 -atomic_t pau_qps_destroyed;
37443 +atomic_unchecked_t pau_qps_created;
37444 +atomic_unchecked_t pau_qps_destroyed;
37445
37446 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37447 {
37448 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37449 {
37450 struct sk_buff *skb;
37451 unsigned long flags;
37452 - atomic_inc(&pau_qps_destroyed);
37453 + atomic_inc_unchecked(&pau_qps_destroyed);
37454
37455 /* Free packets that have not yet been forwarded */
37456 /* Lock is acquired by skb_dequeue when removing the skb */
37457 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37458 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37459 skb_queue_head_init(&nesqp->pau_list);
37460 spin_lock_init(&nesqp->pau_lock);
37461 - atomic_inc(&pau_qps_created);
37462 + atomic_inc_unchecked(&pau_qps_created);
37463 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37464 }
37465
37466 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37467 index 9542e16..a008c40 100644
37468 --- a/drivers/infiniband/hw/nes/nes_nic.c
37469 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37470 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37471 target_stat_values[++index] = mh_detected;
37472 target_stat_values[++index] = mh_pauses_sent;
37473 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37474 - target_stat_values[++index] = atomic_read(&cm_connects);
37475 - target_stat_values[++index] = atomic_read(&cm_accepts);
37476 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37477 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37478 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37479 - target_stat_values[++index] = atomic_read(&cm_rejects);
37480 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37481 - target_stat_values[++index] = atomic_read(&qps_created);
37482 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37483 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37484 - target_stat_values[++index] = atomic_read(&cm_closes);
37485 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37486 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37487 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37488 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37489 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37490 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37491 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37492 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37493 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37494 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37495 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37496 target_stat_values[++index] = cm_packets_sent;
37497 target_stat_values[++index] = cm_packets_bounced;
37498 target_stat_values[++index] = cm_packets_created;
37499 target_stat_values[++index] = cm_packets_received;
37500 target_stat_values[++index] = cm_packets_dropped;
37501 target_stat_values[++index] = cm_packets_retrans;
37502 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37503 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37504 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37505 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37506 target_stat_values[++index] = cm_backlog_drops;
37507 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37508 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37509 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37510 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37511 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37512 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37513 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37514 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37515 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37516 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37517 target_stat_values[++index] = nesadapter->free_4kpbl;
37518 target_stat_values[++index] = nesadapter->free_256pbl;
37519 target_stat_values[++index] = int_mod_timer_init;
37520 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37521 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37522 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37523 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37524 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37525 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37526 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37527 }
37528
37529 /**
37530 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37531 index 07e4fba..685f041 100644
37532 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37533 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37534 @@ -46,9 +46,9 @@
37535
37536 #include <rdma/ib_umem.h>
37537
37538 -atomic_t mod_qp_timouts;
37539 -atomic_t qps_created;
37540 -atomic_t sw_qps_destroyed;
37541 +atomic_unchecked_t mod_qp_timouts;
37542 +atomic_unchecked_t qps_created;
37543 +atomic_unchecked_t sw_qps_destroyed;
37544
37545 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37546
37547 @@ -1131,7 +1131,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37548 if (init_attr->create_flags)
37549 return ERR_PTR(-EINVAL);
37550
37551 - atomic_inc(&qps_created);
37552 + atomic_inc_unchecked(&qps_created);
37553 switch (init_attr->qp_type) {
37554 case IB_QPT_RC:
37555 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37556 @@ -1462,7 +1462,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37557 struct iw_cm_event cm_event;
37558 int ret = 0;
37559
37560 - atomic_inc(&sw_qps_destroyed);
37561 + atomic_inc_unchecked(&sw_qps_destroyed);
37562 nesqp->destroyed = 1;
37563
37564 /* Blow away the connection if it exists. */
37565 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37566 index 4d11575..3e890e5 100644
37567 --- a/drivers/infiniband/hw/qib/qib.h
37568 +++ b/drivers/infiniband/hw/qib/qib.h
37569 @@ -51,6 +51,7 @@
37570 #include <linux/completion.h>
37571 #include <linux/kref.h>
37572 #include <linux/sched.h>
37573 +#include <linux/slab.h>
37574
37575 #include "qib_common.h"
37576 #include "qib_verbs.h"
37577 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37578 index da739d9..da1c7f4 100644
37579 --- a/drivers/input/gameport/gameport.c
37580 +++ b/drivers/input/gameport/gameport.c
37581 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37582 */
37583 static void gameport_init_port(struct gameport *gameport)
37584 {
37585 - static atomic_t gameport_no = ATOMIC_INIT(0);
37586 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37587
37588 __module_get(THIS_MODULE);
37589
37590 mutex_init(&gameport->drv_mutex);
37591 device_initialize(&gameport->dev);
37592 dev_set_name(&gameport->dev, "gameport%lu",
37593 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37594 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37595 gameport->dev.bus = &gameport_bus;
37596 gameport->dev.release = gameport_release_port;
37597 if (gameport->parent)
37598 diff --git a/drivers/input/input.c b/drivers/input/input.c
37599 index c044699..174d71a 100644
37600 --- a/drivers/input/input.c
37601 +++ b/drivers/input/input.c
37602 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37603 */
37604 int input_register_device(struct input_dev *dev)
37605 {
37606 - static atomic_t input_no = ATOMIC_INIT(0);
37607 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37608 struct input_devres *devres = NULL;
37609 struct input_handler *handler;
37610 unsigned int packet_size;
37611 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37612 dev->setkeycode = input_default_setkeycode;
37613
37614 dev_set_name(&dev->dev, "input%ld",
37615 - (unsigned long) atomic_inc_return(&input_no) - 1);
37616 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37617
37618 error = device_add(&dev->dev);
37619 if (error)
37620 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37621 index 04c69af..5f92d00 100644
37622 --- a/drivers/input/joystick/sidewinder.c
37623 +++ b/drivers/input/joystick/sidewinder.c
37624 @@ -30,6 +30,7 @@
37625 #include <linux/kernel.h>
37626 #include <linux/module.h>
37627 #include <linux/slab.h>
37628 +#include <linux/sched.h>
37629 #include <linux/init.h>
37630 #include <linux/input.h>
37631 #include <linux/gameport.h>
37632 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37633 index d6cbfe9..6225402 100644
37634 --- a/drivers/input/joystick/xpad.c
37635 +++ b/drivers/input/joystick/xpad.c
37636 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37637
37638 static int xpad_led_probe(struct usb_xpad *xpad)
37639 {
37640 - static atomic_t led_seq = ATOMIC_INIT(0);
37641 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37642 long led_no;
37643 struct xpad_led *led;
37644 struct led_classdev *led_cdev;
37645 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37646 if (!led)
37647 return -ENOMEM;
37648
37649 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37650 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37651
37652 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37653 led->xpad = xpad;
37654 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37655 index fe1df23..5b710f3 100644
37656 --- a/drivers/input/mouse/psmouse.h
37657 +++ b/drivers/input/mouse/psmouse.h
37658 @@ -115,7 +115,7 @@ struct psmouse_attribute {
37659 ssize_t (*set)(struct psmouse *psmouse, void *data,
37660 const char *buf, size_t count);
37661 bool protect;
37662 -};
37663 +} __do_const;
37664 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37665
37666 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37667 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37668 index 4c842c3..590b0bf 100644
37669 --- a/drivers/input/mousedev.c
37670 +++ b/drivers/input/mousedev.c
37671 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37672
37673 spin_unlock_irq(&client->packet_lock);
37674
37675 - if (copy_to_user(buffer, data, count))
37676 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37677 return -EFAULT;
37678
37679 return count;
37680 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37681 index 25fc597..558bf3b 100644
37682 --- a/drivers/input/serio/serio.c
37683 +++ b/drivers/input/serio/serio.c
37684 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37685 */
37686 static void serio_init_port(struct serio *serio)
37687 {
37688 - static atomic_t serio_no = ATOMIC_INIT(0);
37689 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37690
37691 __module_get(THIS_MODULE);
37692
37693 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37694 mutex_init(&serio->drv_mutex);
37695 device_initialize(&serio->dev);
37696 dev_set_name(&serio->dev, "serio%ld",
37697 - (long)atomic_inc_return(&serio_no) - 1);
37698 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37699 serio->dev.bus = &serio_bus;
37700 serio->dev.release = serio_release_port;
37701 serio->dev.groups = serio_device_attr_groups;
37702 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37703 index ddbdaca..be18a78 100644
37704 --- a/drivers/iommu/iommu.c
37705 +++ b/drivers/iommu/iommu.c
37706 @@ -554,7 +554,7 @@ static struct notifier_block iommu_bus_nb = {
37707 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37708 {
37709 bus_register_notifier(bus, &iommu_bus_nb);
37710 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37711 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37712 }
37713
37714 /**
37715 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37716 index 89562a8..218999b 100644
37717 --- a/drivers/isdn/capi/capi.c
37718 +++ b/drivers/isdn/capi/capi.c
37719 @@ -81,8 +81,8 @@ struct capiminor {
37720
37721 struct capi20_appl *ap;
37722 u32 ncci;
37723 - atomic_t datahandle;
37724 - atomic_t msgid;
37725 + atomic_unchecked_t datahandle;
37726 + atomic_unchecked_t msgid;
37727
37728 struct tty_port port;
37729 int ttyinstop;
37730 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37731 capimsg_setu16(s, 2, mp->ap->applid);
37732 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37733 capimsg_setu8 (s, 5, CAPI_RESP);
37734 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37735 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37736 capimsg_setu32(s, 8, mp->ncci);
37737 capimsg_setu16(s, 12, datahandle);
37738 }
37739 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37740 mp->outbytes -= len;
37741 spin_unlock_bh(&mp->outlock);
37742
37743 - datahandle = atomic_inc_return(&mp->datahandle);
37744 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37745 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37746 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37747 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37748 capimsg_setu16(skb->data, 2, mp->ap->applid);
37749 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37750 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37751 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37752 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37753 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37754 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37755 capimsg_setu16(skb->data, 16, len); /* Data length */
37756 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37757 index 67abf3f..076b3a6 100644
37758 --- a/drivers/isdn/gigaset/interface.c
37759 +++ b/drivers/isdn/gigaset/interface.c
37760 @@ -160,9 +160,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37761 }
37762 tty->driver_data = cs;
37763
37764 - ++cs->port.count;
37765 + atomic_inc(&cs->port.count);
37766
37767 - if (cs->port.count == 1) {
37768 + if (atomic_read(&cs->port.count) == 1) {
37769 tty_port_tty_set(&cs->port, tty);
37770 tty->low_latency = 1;
37771 }
37772 @@ -186,9 +186,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
37773
37774 if (!cs->connected)
37775 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
37776 - else if (!cs->port.count)
37777 + else if (!atomic_read(&cs->port.count))
37778 dev_warn(cs->dev, "%s: device not opened\n", __func__);
37779 - else if (!--cs->port.count)
37780 + else if (!atomic_dec_return(&cs->port.count))
37781 tty_port_tty_set(&cs->port, NULL);
37782
37783 mutex_unlock(&cs->mutex);
37784 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
37785 index 821f7ac..28d4030 100644
37786 --- a/drivers/isdn/hardware/avm/b1.c
37787 +++ b/drivers/isdn/hardware/avm/b1.c
37788 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
37789 }
37790 if (left) {
37791 if (t4file->user) {
37792 - if (copy_from_user(buf, dp, left))
37793 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37794 return -EFAULT;
37795 } else {
37796 memcpy(buf, dp, left);
37797 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
37798 }
37799 if (left) {
37800 if (config->user) {
37801 - if (copy_from_user(buf, dp, left))
37802 + if (left > sizeof buf || copy_from_user(buf, dp, left))
37803 return -EFAULT;
37804 } else {
37805 memcpy(buf, dp, left);
37806 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
37807 index e09dc8a..15e2efb 100644
37808 --- a/drivers/isdn/i4l/isdn_tty.c
37809 +++ b/drivers/isdn/i4l/isdn_tty.c
37810 @@ -1513,9 +1513,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
37811
37812 #ifdef ISDN_DEBUG_MODEM_OPEN
37813 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
37814 - port->count);
37815 + atomic_read(&port->count));
37816 #endif
37817 - port->count++;
37818 + atomic_inc(&port->count);
37819 port->tty = tty;
37820 /*
37821 * Start up serial port
37822 @@ -1559,7 +1559,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37823 #endif
37824 return;
37825 }
37826 - if ((tty->count == 1) && (port->count != 1)) {
37827 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
37828 /*
37829 * Uh, oh. tty->count is 1, which means that the tty
37830 * structure will be freed. Info->count should always
37831 @@ -1568,15 +1568,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
37832 * serial port won't be shutdown.
37833 */
37834 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
37835 - "info->count is %d\n", port->count);
37836 - port->count = 1;
37837 + "info->count is %d\n", atomic_read(&port->count));
37838 + atomic_set(&port->count, 1);
37839 }
37840 - if (--port->count < 0) {
37841 + if (atomic_dec_return(&port->count) < 0) {
37842 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
37843 - info->line, port->count);
37844 - port->count = 0;
37845 + info->line, atomic_read(&port->count));
37846 + atomic_set(&port->count, 0);
37847 }
37848 - if (port->count) {
37849 + if (atomic_read(&port->count)) {
37850 #ifdef ISDN_DEBUG_MODEM_OPEN
37851 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
37852 #endif
37853 @@ -1630,7 +1630,7 @@ isdn_tty_hangup(struct tty_struct *tty)
37854 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
37855 return;
37856 isdn_tty_shutdown(info);
37857 - port->count = 0;
37858 + atomic_set(&port->count, 0);
37859 port->flags &= ~ASYNC_NORMAL_ACTIVE;
37860 port->tty = NULL;
37861 wake_up_interruptible(&port->open_wait);
37862 @@ -1975,7 +1975,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
37863 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
37864 modem_info *info = &dev->mdm.info[i];
37865
37866 - if (info->port.count == 0)
37867 + if (atomic_read(&info->port.count) == 0)
37868 continue;
37869 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
37870 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
37871 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
37872 index e74df7c..03a03ba 100644
37873 --- a/drivers/isdn/icn/icn.c
37874 +++ b/drivers/isdn/icn/icn.c
37875 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
37876 if (count > len)
37877 count = len;
37878 if (user) {
37879 - if (copy_from_user(msg, buf, count))
37880 + if (count > sizeof msg || copy_from_user(msg, buf, count))
37881 return -EFAULT;
37882 } else
37883 memcpy(msg, buf, count);
37884 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
37885 index 6a8405d..0bd1c7e 100644
37886 --- a/drivers/leds/leds-clevo-mail.c
37887 +++ b/drivers/leds/leds-clevo-mail.c
37888 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
37889 * detected as working, but in reality it is not) as low as
37890 * possible.
37891 */
37892 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
37893 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
37894 {
37895 .callback = clevo_mail_led_dmi_callback,
37896 .ident = "Clevo D410J",
37897 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
37898 index ec9b287..65c9bf4 100644
37899 --- a/drivers/leds/leds-ss4200.c
37900 +++ b/drivers/leds/leds-ss4200.c
37901 @@ -92,7 +92,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
37902 * detected as working, but in reality it is not) as low as
37903 * possible.
37904 */
37905 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
37906 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
37907 {
37908 .callback = ss4200_led_dmi_callback,
37909 .ident = "Intel SS4200-E",
37910 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
37911 index a5ebc00..982886f 100644
37912 --- a/drivers/lguest/core.c
37913 +++ b/drivers/lguest/core.c
37914 @@ -92,9 +92,17 @@ static __init int map_switcher(void)
37915 * it's worked so far. The end address needs +1 because __get_vm_area
37916 * allocates an extra guard page, so we need space for that.
37917 */
37918 +
37919 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
37920 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37921 + VM_ALLOC | VM_KERNEXEC, SWITCHER_ADDR, SWITCHER_ADDR
37922 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37923 +#else
37924 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
37925 VM_ALLOC, SWITCHER_ADDR, SWITCHER_ADDR
37926 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
37927 +#endif
37928 +
37929 if (!switcher_vma) {
37930 err = -ENOMEM;
37931 printk("lguest: could not map switcher pages high\n");
37932 @@ -119,7 +127,7 @@ static __init int map_switcher(void)
37933 * Now the Switcher is mapped at the right address, we can't fail!
37934 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
37935 */
37936 - memcpy(switcher_vma->addr, start_switcher_text,
37937 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
37938 end_switcher_text - start_switcher_text);
37939
37940 printk(KERN_INFO "lguest: mapped switcher at %p\n",
37941 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
37942 index 3b62be16..e33134a 100644
37943 --- a/drivers/lguest/page_tables.c
37944 +++ b/drivers/lguest/page_tables.c
37945 @@ -532,7 +532,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
37946 /*:*/
37947
37948 #ifdef CONFIG_X86_PAE
37949 -static void release_pmd(pmd_t *spmd)
37950 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
37951 {
37952 /* If the entry's not present, there's nothing to release. */
37953 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
37954 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
37955 index 4af12e1..0e89afe 100644
37956 --- a/drivers/lguest/x86/core.c
37957 +++ b/drivers/lguest/x86/core.c
37958 @@ -59,7 +59,7 @@ static struct {
37959 /* Offset from where switcher.S was compiled to where we've copied it */
37960 static unsigned long switcher_offset(void)
37961 {
37962 - return SWITCHER_ADDR - (unsigned long)start_switcher_text;
37963 + return SWITCHER_ADDR - (unsigned long)ktla_ktva(start_switcher_text);
37964 }
37965
37966 /* This cpu's struct lguest_pages. */
37967 @@ -100,7 +100,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
37968 * These copies are pretty cheap, so we do them unconditionally: */
37969 /* Save the current Host top-level page directory.
37970 */
37971 +
37972 +#ifdef CONFIG_PAX_PER_CPU_PGD
37973 + pages->state.host_cr3 = read_cr3();
37974 +#else
37975 pages->state.host_cr3 = __pa(current->mm->pgd);
37976 +#endif
37977 +
37978 /*
37979 * Set up the Guest's page tables to see this CPU's pages (and no
37980 * other CPU's pages).
37981 @@ -476,7 +482,7 @@ void __init lguest_arch_host_init(void)
37982 * compiled-in switcher code and the high-mapped copy we just made.
37983 */
37984 for (i = 0; i < IDT_ENTRIES; i++)
37985 - default_idt_entries[i] += switcher_offset();
37986 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
37987
37988 /*
37989 * Set up the Switcher's per-cpu areas.
37990 @@ -559,7 +565,7 @@ void __init lguest_arch_host_init(void)
37991 * it will be undisturbed when we switch. To change %cs and jump we
37992 * need this structure to feed to Intel's "lcall" instruction.
37993 */
37994 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
37995 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
37996 lguest_entry.segment = LGUEST_CS;
37997
37998 /*
37999 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38000 index 40634b0..4f5855e 100644
38001 --- a/drivers/lguest/x86/switcher_32.S
38002 +++ b/drivers/lguest/x86/switcher_32.S
38003 @@ -87,6 +87,7 @@
38004 #include <asm/page.h>
38005 #include <asm/segment.h>
38006 #include <asm/lguest.h>
38007 +#include <asm/processor-flags.h>
38008
38009 // We mark the start of the code to copy
38010 // It's placed in .text tho it's never run here
38011 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38012 // Changes type when we load it: damn Intel!
38013 // For after we switch over our page tables
38014 // That entry will be read-only: we'd crash.
38015 +
38016 +#ifdef CONFIG_PAX_KERNEXEC
38017 + mov %cr0, %edx
38018 + xor $X86_CR0_WP, %edx
38019 + mov %edx, %cr0
38020 +#endif
38021 +
38022 movl $(GDT_ENTRY_TSS*8), %edx
38023 ltr %dx
38024
38025 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38026 // Let's clear it again for our return.
38027 // The GDT descriptor of the Host
38028 // Points to the table after two "size" bytes
38029 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38030 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38031 // Clear "used" from type field (byte 5, bit 2)
38032 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38033 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38034 +
38035 +#ifdef CONFIG_PAX_KERNEXEC
38036 + mov %cr0, %eax
38037 + xor $X86_CR0_WP, %eax
38038 + mov %eax, %cr0
38039 +#endif
38040
38041 // Once our page table's switched, the Guest is live!
38042 // The Host fades as we run this final step.
38043 @@ -295,13 +309,12 @@ deliver_to_host:
38044 // I consulted gcc, and it gave
38045 // These instructions, which I gladly credit:
38046 leal (%edx,%ebx,8), %eax
38047 - movzwl (%eax),%edx
38048 - movl 4(%eax), %eax
38049 - xorw %ax, %ax
38050 - orl %eax, %edx
38051 + movl 4(%eax), %edx
38052 + movw (%eax), %dx
38053 // Now the address of the handler's in %edx
38054 // We call it now: its "iret" drops us home.
38055 - jmp *%edx
38056 + ljmp $__KERNEL_CS, $1f
38057 +1: jmp *%edx
38058
38059 // Every interrupt can come to us here
38060 // But we must truly tell each apart.
38061 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38062 index 7155945..4bcc562 100644
38063 --- a/drivers/md/bitmap.c
38064 +++ b/drivers/md/bitmap.c
38065 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38066 chunk_kb ? "KB" : "B");
38067 if (bitmap->storage.file) {
38068 seq_printf(seq, ", file: ");
38069 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38070 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38071 }
38072
38073 seq_printf(seq, "\n");
38074 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38075 index eee353d..74504c4 100644
38076 --- a/drivers/md/dm-ioctl.c
38077 +++ b/drivers/md/dm-ioctl.c
38078 @@ -1632,7 +1632,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38079 cmd == DM_LIST_VERSIONS_CMD)
38080 return 0;
38081
38082 - if ((cmd == DM_DEV_CREATE_CMD)) {
38083 + if (cmd == DM_DEV_CREATE_CMD) {
38084 if (!*param->name) {
38085 DMWARN("name not supplied when creating device");
38086 return -EINVAL;
38087 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38088 index 7f24190..0e18099 100644
38089 --- a/drivers/md/dm-raid1.c
38090 +++ b/drivers/md/dm-raid1.c
38091 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38092
38093 struct mirror {
38094 struct mirror_set *ms;
38095 - atomic_t error_count;
38096 + atomic_unchecked_t error_count;
38097 unsigned long error_type;
38098 struct dm_dev *dev;
38099 sector_t offset;
38100 @@ -183,7 +183,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38101 struct mirror *m;
38102
38103 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38104 - if (!atomic_read(&m->error_count))
38105 + if (!atomic_read_unchecked(&m->error_count))
38106 return m;
38107
38108 return NULL;
38109 @@ -215,7 +215,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38110 * simple way to tell if a device has encountered
38111 * errors.
38112 */
38113 - atomic_inc(&m->error_count);
38114 + atomic_inc_unchecked(&m->error_count);
38115
38116 if (test_and_set_bit(error_type, &m->error_type))
38117 return;
38118 @@ -406,7 +406,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38119 struct mirror *m = get_default_mirror(ms);
38120
38121 do {
38122 - if (likely(!atomic_read(&m->error_count)))
38123 + if (likely(!atomic_read_unchecked(&m->error_count)))
38124 return m;
38125
38126 if (m-- == ms->mirror)
38127 @@ -420,7 +420,7 @@ static int default_ok(struct mirror *m)
38128 {
38129 struct mirror *default_mirror = get_default_mirror(m->ms);
38130
38131 - return !atomic_read(&default_mirror->error_count);
38132 + return !atomic_read_unchecked(&default_mirror->error_count);
38133 }
38134
38135 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38136 @@ -557,7 +557,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38137 */
38138 if (likely(region_in_sync(ms, region, 1)))
38139 m = choose_mirror(ms, bio->bi_sector);
38140 - else if (m && atomic_read(&m->error_count))
38141 + else if (m && atomic_read_unchecked(&m->error_count))
38142 m = NULL;
38143
38144 if (likely(m))
38145 @@ -924,7 +924,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38146 }
38147
38148 ms->mirror[mirror].ms = ms;
38149 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38150 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38151 ms->mirror[mirror].error_type = 0;
38152 ms->mirror[mirror].offset = offset;
38153
38154 @@ -1337,7 +1337,7 @@ static void mirror_resume(struct dm_target *ti)
38155 */
38156 static char device_status_char(struct mirror *m)
38157 {
38158 - if (!atomic_read(&(m->error_count)))
38159 + if (!atomic_read_unchecked(&(m->error_count)))
38160 return 'A';
38161
38162 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38163 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38164 index aaecefa..23b3026 100644
38165 --- a/drivers/md/dm-stripe.c
38166 +++ b/drivers/md/dm-stripe.c
38167 @@ -20,7 +20,7 @@ struct stripe {
38168 struct dm_dev *dev;
38169 sector_t physical_start;
38170
38171 - atomic_t error_count;
38172 + atomic_unchecked_t error_count;
38173 };
38174
38175 struct stripe_c {
38176 @@ -184,7 +184,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38177 kfree(sc);
38178 return r;
38179 }
38180 - atomic_set(&(sc->stripe[i].error_count), 0);
38181 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38182 }
38183
38184 ti->private = sc;
38185 @@ -325,7 +325,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38186 DMEMIT("%d ", sc->stripes);
38187 for (i = 0; i < sc->stripes; i++) {
38188 DMEMIT("%s ", sc->stripe[i].dev->name);
38189 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38190 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38191 'D' : 'A';
38192 }
38193 buffer[i] = '\0';
38194 @@ -370,8 +370,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38195 */
38196 for (i = 0; i < sc->stripes; i++)
38197 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38198 - atomic_inc(&(sc->stripe[i].error_count));
38199 - if (atomic_read(&(sc->stripe[i].error_count)) <
38200 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38201 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38202 DM_IO_ERROR_THRESHOLD)
38203 schedule_work(&sc->trigger_event);
38204 }
38205 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38206 index daf25d0..d74f49f 100644
38207 --- a/drivers/md/dm-table.c
38208 +++ b/drivers/md/dm-table.c
38209 @@ -390,7 +390,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38210 if (!dev_size)
38211 return 0;
38212
38213 - if ((start >= dev_size) || (start + len > dev_size)) {
38214 + if ((start >= dev_size) || (len > dev_size - start)) {
38215 DMWARN("%s: %s too small for target: "
38216 "start=%llu, len=%llu, dev_size=%llu",
38217 dm_device_name(ti->table->md), bdevname(bdev, b),
38218 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38219 index 4d6e853..a234157 100644
38220 --- a/drivers/md/dm-thin-metadata.c
38221 +++ b/drivers/md/dm-thin-metadata.c
38222 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38223 {
38224 pmd->info.tm = pmd->tm;
38225 pmd->info.levels = 2;
38226 - pmd->info.value_type.context = pmd->data_sm;
38227 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38228 pmd->info.value_type.size = sizeof(__le64);
38229 pmd->info.value_type.inc = data_block_inc;
38230 pmd->info.value_type.dec = data_block_dec;
38231 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38232
38233 pmd->bl_info.tm = pmd->tm;
38234 pmd->bl_info.levels = 1;
38235 - pmd->bl_info.value_type.context = pmd->data_sm;
38236 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38237 pmd->bl_info.value_type.size = sizeof(__le64);
38238 pmd->bl_info.value_type.inc = data_block_inc;
38239 pmd->bl_info.value_type.dec = data_block_dec;
38240 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38241 index 0d8f086..f5a91d5 100644
38242 --- a/drivers/md/dm.c
38243 +++ b/drivers/md/dm.c
38244 @@ -170,9 +170,9 @@ struct mapped_device {
38245 /*
38246 * Event handling.
38247 */
38248 - atomic_t event_nr;
38249 + atomic_unchecked_t event_nr;
38250 wait_queue_head_t eventq;
38251 - atomic_t uevent_seq;
38252 + atomic_unchecked_t uevent_seq;
38253 struct list_head uevent_list;
38254 spinlock_t uevent_lock; /* Protect access to uevent_list */
38255
38256 @@ -1872,8 +1872,8 @@ static struct mapped_device *alloc_dev(int minor)
38257 rwlock_init(&md->map_lock);
38258 atomic_set(&md->holders, 1);
38259 atomic_set(&md->open_count, 0);
38260 - atomic_set(&md->event_nr, 0);
38261 - atomic_set(&md->uevent_seq, 0);
38262 + atomic_set_unchecked(&md->event_nr, 0);
38263 + atomic_set_unchecked(&md->uevent_seq, 0);
38264 INIT_LIST_HEAD(&md->uevent_list);
38265 spin_lock_init(&md->uevent_lock);
38266
38267 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38268
38269 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38270
38271 - atomic_inc(&md->event_nr);
38272 + atomic_inc_unchecked(&md->event_nr);
38273 wake_up(&md->eventq);
38274 }
38275
38276 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38277
38278 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38279 {
38280 - return atomic_add_return(1, &md->uevent_seq);
38281 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38282 }
38283
38284 uint32_t dm_get_event_nr(struct mapped_device *md)
38285 {
38286 - return atomic_read(&md->event_nr);
38287 + return atomic_read_unchecked(&md->event_nr);
38288 }
38289
38290 int dm_wait_event(struct mapped_device *md, int event_nr)
38291 {
38292 return wait_event_interruptible(md->eventq,
38293 - (event_nr != atomic_read(&md->event_nr)));
38294 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38295 }
38296
38297 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38298 diff --git a/drivers/md/md.c b/drivers/md/md.c
38299 index f363135..9b38815 100644
38300 --- a/drivers/md/md.c
38301 +++ b/drivers/md/md.c
38302 @@ -240,10 +240,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38303 * start build, activate spare
38304 */
38305 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38306 -static atomic_t md_event_count;
38307 +static atomic_unchecked_t md_event_count;
38308 void md_new_event(struct mddev *mddev)
38309 {
38310 - atomic_inc(&md_event_count);
38311 + atomic_inc_unchecked(&md_event_count);
38312 wake_up(&md_event_waiters);
38313 }
38314 EXPORT_SYMBOL_GPL(md_new_event);
38315 @@ -253,7 +253,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38316 */
38317 static void md_new_event_inintr(struct mddev *mddev)
38318 {
38319 - atomic_inc(&md_event_count);
38320 + atomic_inc_unchecked(&md_event_count);
38321 wake_up(&md_event_waiters);
38322 }
38323
38324 @@ -1507,7 +1507,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38325 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38326 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38327 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38328 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38329 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38330
38331 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38332 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38333 @@ -1751,7 +1751,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38334 else
38335 sb->resync_offset = cpu_to_le64(0);
38336
38337 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38338 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38339
38340 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38341 sb->size = cpu_to_le64(mddev->dev_sectors);
38342 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38343 static ssize_t
38344 errors_show(struct md_rdev *rdev, char *page)
38345 {
38346 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38347 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38348 }
38349
38350 static ssize_t
38351 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38352 char *e;
38353 unsigned long n = simple_strtoul(buf, &e, 10);
38354 if (*buf && (*e == 0 || *e == '\n')) {
38355 - atomic_set(&rdev->corrected_errors, n);
38356 + atomic_set_unchecked(&rdev->corrected_errors, n);
38357 return len;
38358 }
38359 return -EINVAL;
38360 @@ -3210,8 +3210,8 @@ int md_rdev_init(struct md_rdev *rdev)
38361 rdev->sb_loaded = 0;
38362 rdev->bb_page = NULL;
38363 atomic_set(&rdev->nr_pending, 0);
38364 - atomic_set(&rdev->read_errors, 0);
38365 - atomic_set(&rdev->corrected_errors, 0);
38366 + atomic_set_unchecked(&rdev->read_errors, 0);
38367 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38368
38369 INIT_LIST_HEAD(&rdev->same_set);
38370 init_waitqueue_head(&rdev->blocked_wait);
38371 @@ -6987,7 +6987,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38372
38373 spin_unlock(&pers_lock);
38374 seq_printf(seq, "\n");
38375 - seq->poll_event = atomic_read(&md_event_count);
38376 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38377 return 0;
38378 }
38379 if (v == (void*)2) {
38380 @@ -7090,7 +7090,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38381 return error;
38382
38383 seq = file->private_data;
38384 - seq->poll_event = atomic_read(&md_event_count);
38385 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38386 return error;
38387 }
38388
38389 @@ -7104,7 +7104,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38390 /* always allow read */
38391 mask = POLLIN | POLLRDNORM;
38392
38393 - if (seq->poll_event != atomic_read(&md_event_count))
38394 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38395 mask |= POLLERR | POLLPRI;
38396 return mask;
38397 }
38398 @@ -7148,7 +7148,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38399 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38400 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38401 (int)part_stat_read(&disk->part0, sectors[1]) -
38402 - atomic_read(&disk->sync_io);
38403 + atomic_read_unchecked(&disk->sync_io);
38404 /* sync IO will cause sync_io to increase before the disk_stats
38405 * as sync_io is counted when a request starts, and
38406 * disk_stats is counted when it completes.
38407 diff --git a/drivers/md/md.h b/drivers/md/md.h
38408 index eca59c3..7c42285 100644
38409 --- a/drivers/md/md.h
38410 +++ b/drivers/md/md.h
38411 @@ -94,13 +94,13 @@ struct md_rdev {
38412 * only maintained for arrays that
38413 * support hot removal
38414 */
38415 - atomic_t read_errors; /* number of consecutive read errors that
38416 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38417 * we have tried to ignore.
38418 */
38419 struct timespec last_read_error; /* monotonic time since our
38420 * last read error
38421 */
38422 - atomic_t corrected_errors; /* number of corrected read errors,
38423 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38424 * for reporting to userspace and storing
38425 * in superblock.
38426 */
38427 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38428
38429 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38430 {
38431 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38432 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38433 }
38434
38435 struct md_personality
38436 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38437 index 1cbfc6b..56e1dbb 100644
38438 --- a/drivers/md/persistent-data/dm-space-map.h
38439 +++ b/drivers/md/persistent-data/dm-space-map.h
38440 @@ -60,6 +60,7 @@ struct dm_space_map {
38441 int (*root_size)(struct dm_space_map *sm, size_t *result);
38442 int (*copy_root)(struct dm_space_map *sm, void *copy_to_here_le, size_t len);
38443 };
38444 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38445
38446 /*----------------------------------------------------------------*/
38447
38448 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38449 index 75b1f89..00ba344 100644
38450 --- a/drivers/md/raid1.c
38451 +++ b/drivers/md/raid1.c
38452 @@ -1819,7 +1819,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38453 if (r1_sync_page_io(rdev, sect, s,
38454 bio->bi_io_vec[idx].bv_page,
38455 READ) != 0)
38456 - atomic_add(s, &rdev->corrected_errors);
38457 + atomic_add_unchecked(s, &rdev->corrected_errors);
38458 }
38459 sectors -= s;
38460 sect += s;
38461 @@ -2041,7 +2041,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38462 test_bit(In_sync, &rdev->flags)) {
38463 if (r1_sync_page_io(rdev, sect, s,
38464 conf->tmppage, READ)) {
38465 - atomic_add(s, &rdev->corrected_errors);
38466 + atomic_add_unchecked(s, &rdev->corrected_errors);
38467 printk(KERN_INFO
38468 "md/raid1:%s: read error corrected "
38469 "(%d sectors at %llu on %s)\n",
38470 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38471 index 8d925dc..11d674f 100644
38472 --- a/drivers/md/raid10.c
38473 +++ b/drivers/md/raid10.c
38474 @@ -1878,7 +1878,7 @@ static void end_sync_read(struct bio *bio, int error)
38475 /* The write handler will notice the lack of
38476 * R10BIO_Uptodate and record any errors etc
38477 */
38478 - atomic_add(r10_bio->sectors,
38479 + atomic_add_unchecked(r10_bio->sectors,
38480 &conf->mirrors[d].rdev->corrected_errors);
38481
38482 /* for reconstruct, we always reschedule after a read.
38483 @@ -2227,7 +2227,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38484 {
38485 struct timespec cur_time_mon;
38486 unsigned long hours_since_last;
38487 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38488 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38489
38490 ktime_get_ts(&cur_time_mon);
38491
38492 @@ -2249,9 +2249,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38493 * overflowing the shift of read_errors by hours_since_last.
38494 */
38495 if (hours_since_last >= 8 * sizeof(read_errors))
38496 - atomic_set(&rdev->read_errors, 0);
38497 + atomic_set_unchecked(&rdev->read_errors, 0);
38498 else
38499 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38500 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38501 }
38502
38503 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38504 @@ -2305,8 +2305,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38505 return;
38506
38507 check_decay_read_errors(mddev, rdev);
38508 - atomic_inc(&rdev->read_errors);
38509 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38510 + atomic_inc_unchecked(&rdev->read_errors);
38511 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38512 char b[BDEVNAME_SIZE];
38513 bdevname(rdev->bdev, b);
38514
38515 @@ -2314,7 +2314,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38516 "md/raid10:%s: %s: Raid device exceeded "
38517 "read_error threshold [cur %d:max %d]\n",
38518 mdname(mddev), b,
38519 - atomic_read(&rdev->read_errors), max_read_errors);
38520 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38521 printk(KERN_NOTICE
38522 "md/raid10:%s: %s: Failing raid device\n",
38523 mdname(mddev), b);
38524 @@ -2469,7 +2469,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38525 sect +
38526 choose_data_offset(r10_bio, rdev)),
38527 bdevname(rdev->bdev, b));
38528 - atomic_add(s, &rdev->corrected_errors);
38529 + atomic_add_unchecked(s, &rdev->corrected_errors);
38530 }
38531
38532 rdev_dec_pending(rdev, mddev);
38533 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38534 index 94ce78e..df99e24 100644
38535 --- a/drivers/md/raid5.c
38536 +++ b/drivers/md/raid5.c
38537 @@ -1800,21 +1800,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38538 mdname(conf->mddev), STRIPE_SECTORS,
38539 (unsigned long long)s,
38540 bdevname(rdev->bdev, b));
38541 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38542 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38543 clear_bit(R5_ReadError, &sh->dev[i].flags);
38544 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38545 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38546 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38547
38548 - if (atomic_read(&rdev->read_errors))
38549 - atomic_set(&rdev->read_errors, 0);
38550 + if (atomic_read_unchecked(&rdev->read_errors))
38551 + atomic_set_unchecked(&rdev->read_errors, 0);
38552 } else {
38553 const char *bdn = bdevname(rdev->bdev, b);
38554 int retry = 0;
38555 int set_bad = 0;
38556
38557 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38558 - atomic_inc(&rdev->read_errors);
38559 + atomic_inc_unchecked(&rdev->read_errors);
38560 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38561 printk_ratelimited(
38562 KERN_WARNING
38563 @@ -1842,7 +1842,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38564 mdname(conf->mddev),
38565 (unsigned long long)s,
38566 bdn);
38567 - } else if (atomic_read(&rdev->read_errors)
38568 + } else if (atomic_read_unchecked(&rdev->read_errors)
38569 > conf->max_nr_stripes)
38570 printk(KERN_WARNING
38571 "md/raid:%s: Too many read errors, failing device %s.\n",
38572 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38573 index d33101a..6b13069 100644
38574 --- a/drivers/media/dvb-core/dvbdev.c
38575 +++ b/drivers/media/dvb-core/dvbdev.c
38576 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38577 const struct dvb_device *template, void *priv, int type)
38578 {
38579 struct dvb_device *dvbdev;
38580 - struct file_operations *dvbdevfops;
38581 + file_operations_no_const *dvbdevfops;
38582 struct device *clsdev;
38583 int minor;
38584 int id;
38585 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38586 index 404f63a..4796533 100644
38587 --- a/drivers/media/dvb-frontends/dib3000.h
38588 +++ b/drivers/media/dvb-frontends/dib3000.h
38589 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38590 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38591 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38592 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38593 -};
38594 +} __no_const;
38595
38596 #if defined(CONFIG_DVB_DIB3000MB) || (defined(CONFIG_DVB_DIB3000MB_MODULE) && defined(MODULE))
38597 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38598 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38599 index bc78354..42c9459 100644
38600 --- a/drivers/media/pci/cx88/cx88-video.c
38601 +++ b/drivers/media/pci/cx88/cx88-video.c
38602 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38603
38604 /* ------------------------------------------------------------------ */
38605
38606 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38607 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38608 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38609 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38610 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38611 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38612
38613 module_param_array(video_nr, int, NULL, 0444);
38614 module_param_array(vbi_nr, int, NULL, 0444);
38615 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38616 index 8e9a668..78d6310 100644
38617 --- a/drivers/media/platform/omap/omap_vout.c
38618 +++ b/drivers/media/platform/omap/omap_vout.c
38619 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38620 OMAP_VIDEO2,
38621 };
38622
38623 -static struct videobuf_queue_ops video_vbq_ops;
38624 /* Variables configurable through module params*/
38625 static u32 video1_numbuffers = 3;
38626 static u32 video2_numbuffers = 3;
38627 @@ -1012,6 +1011,12 @@ static int omap_vout_open(struct file *file)
38628 {
38629 struct videobuf_queue *q;
38630 struct omap_vout_device *vout = NULL;
38631 + static struct videobuf_queue_ops video_vbq_ops = {
38632 + .buf_setup = omap_vout_buffer_setup,
38633 + .buf_prepare = omap_vout_buffer_prepare,
38634 + .buf_release = omap_vout_buffer_release,
38635 + .buf_queue = omap_vout_buffer_queue,
38636 + };
38637
38638 vout = video_drvdata(file);
38639 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38640 @@ -1029,10 +1034,6 @@ static int omap_vout_open(struct file *file)
38641 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38642
38643 q = &vout->vbq;
38644 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38645 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38646 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38647 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38648 spin_lock_init(&vout->vbq_lock);
38649
38650 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38651 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38652 index b671e20..34088b7 100644
38653 --- a/drivers/media/platform/s5p-tv/mixer.h
38654 +++ b/drivers/media/platform/s5p-tv/mixer.h
38655 @@ -155,7 +155,7 @@ struct mxr_layer {
38656 /** layer index (unique identifier) */
38657 int idx;
38658 /** callbacks for layer methods */
38659 - struct mxr_layer_ops ops;
38660 + struct mxr_layer_ops *ops;
38661 /** format array */
38662 const struct mxr_format **fmt_array;
38663 /** size of format array */
38664 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38665 index b93a21f..2535195 100644
38666 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38667 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38668 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38669 {
38670 struct mxr_layer *layer;
38671 int ret;
38672 - struct mxr_layer_ops ops = {
38673 + static struct mxr_layer_ops ops = {
38674 .release = mxr_graph_layer_release,
38675 .buffer_set = mxr_graph_buffer_set,
38676 .stream_set = mxr_graph_stream_set,
38677 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38678 index 3b1670a..595c939 100644
38679 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38680 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38681 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38682 layer->update_buf = next;
38683 }
38684
38685 - layer->ops.buffer_set(layer, layer->update_buf);
38686 + layer->ops->buffer_set(layer, layer->update_buf);
38687
38688 if (done && done != layer->shadow_buf)
38689 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38690 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38691 index 1f3b743..e839271 100644
38692 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38693 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38694 @@ -208,7 +208,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38695 layer->geo.src.height = layer->geo.src.full_height;
38696
38697 mxr_geometry_dump(mdev, &layer->geo);
38698 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38699 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38700 mxr_geometry_dump(mdev, &layer->geo);
38701 }
38702
38703 @@ -226,7 +226,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38704 layer->geo.dst.full_width = mbus_fmt.width;
38705 layer->geo.dst.full_height = mbus_fmt.height;
38706 layer->geo.dst.field = mbus_fmt.field;
38707 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38708 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38709
38710 mxr_geometry_dump(mdev, &layer->geo);
38711 }
38712 @@ -332,7 +332,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38713 /* set source size to highest accepted value */
38714 geo->src.full_width = max(geo->dst.full_width, pix->width);
38715 geo->src.full_height = max(geo->dst.full_height, pix->height);
38716 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38717 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38718 mxr_geometry_dump(mdev, &layer->geo);
38719 /* set cropping to total visible screen */
38720 geo->src.width = pix->width;
38721 @@ -340,12 +340,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38722 geo->src.x_offset = 0;
38723 geo->src.y_offset = 0;
38724 /* assure consistency of geometry */
38725 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38726 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38727 mxr_geometry_dump(mdev, &layer->geo);
38728 /* set full size to lowest possible value */
38729 geo->src.full_width = 0;
38730 geo->src.full_height = 0;
38731 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38732 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38733 mxr_geometry_dump(mdev, &layer->geo);
38734
38735 /* returning results */
38736 @@ -472,7 +472,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38737 target->width = s->r.width;
38738 target->height = s->r.height;
38739
38740 - layer->ops.fix_geometry(layer, stage, s->flags);
38741 + layer->ops->fix_geometry(layer, stage, s->flags);
38742
38743 /* retrieve update selection rectangle */
38744 res.left = target->x_offset;
38745 @@ -937,13 +937,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38746 mxr_output_get(mdev);
38747
38748 mxr_layer_update_output(layer);
38749 - layer->ops.format_set(layer);
38750 + layer->ops->format_set(layer);
38751 /* enabling layer in hardware */
38752 spin_lock_irqsave(&layer->enq_slock, flags);
38753 layer->state = MXR_LAYER_STREAMING;
38754 spin_unlock_irqrestore(&layer->enq_slock, flags);
38755
38756 - layer->ops.stream_set(layer, MXR_ENABLE);
38757 + layer->ops->stream_set(layer, MXR_ENABLE);
38758 mxr_streamer_get(mdev);
38759
38760 return 0;
38761 @@ -1013,7 +1013,7 @@ static int stop_streaming(struct vb2_queue *vq)
38762 spin_unlock_irqrestore(&layer->enq_slock, flags);
38763
38764 /* disabling layer in hardware */
38765 - layer->ops.stream_set(layer, MXR_DISABLE);
38766 + layer->ops->stream_set(layer, MXR_DISABLE);
38767 /* remove one streamer */
38768 mxr_streamer_put(mdev);
38769 /* allow changes in output configuration */
38770 @@ -1052,8 +1052,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
38771
38772 void mxr_layer_release(struct mxr_layer *layer)
38773 {
38774 - if (layer->ops.release)
38775 - layer->ops.release(layer);
38776 + if (layer->ops->release)
38777 + layer->ops->release(layer);
38778 }
38779
38780 void mxr_base_layer_release(struct mxr_layer *layer)
38781 @@ -1079,7 +1079,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
38782
38783 layer->mdev = mdev;
38784 layer->idx = idx;
38785 - layer->ops = *ops;
38786 + layer->ops = ops;
38787
38788 spin_lock_init(&layer->enq_slock);
38789 INIT_LIST_HEAD(&layer->enq_list);
38790 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38791 index 3d13a63..da31bf1 100644
38792 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38793 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
38794 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
38795 {
38796 struct mxr_layer *layer;
38797 int ret;
38798 - struct mxr_layer_ops ops = {
38799 + static struct mxr_layer_ops ops = {
38800 .release = mxr_vp_layer_release,
38801 .buffer_set = mxr_vp_buffer_set,
38802 .stream_set = mxr_vp_stream_set,
38803 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
38804 index 643d80a..56bb96b 100644
38805 --- a/drivers/media/radio/radio-cadet.c
38806 +++ b/drivers/media/radio/radio-cadet.c
38807 @@ -302,6 +302,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38808 unsigned char readbuf[RDS_BUFFER];
38809 int i = 0;
38810
38811 + if (count > RDS_BUFFER)
38812 + return -EFAULT;
38813 mutex_lock(&dev->lock);
38814 if (dev->rdsstat == 0)
38815 cadet_start_rds(dev);
38816 @@ -317,7 +319,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
38817 while (i < count && dev->rdsin != dev->rdsout)
38818 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
38819
38820 - if (i && copy_to_user(data, readbuf, i))
38821 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
38822 i = -EFAULT;
38823 unlock:
38824 mutex_unlock(&dev->lock);
38825 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
38826 index 3940bb0..fb3952a 100644
38827 --- a/drivers/media/usb/dvb-usb/cxusb.c
38828 +++ b/drivers/media/usb/dvb-usb/cxusb.c
38829 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
38830
38831 struct dib0700_adapter_state {
38832 int (*set_param_save) (struct dvb_frontend *);
38833 -};
38834 +} __no_const;
38835
38836 static int dib7070_set_param_override(struct dvb_frontend *fe)
38837 {
38838 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
38839 index 9382895..ac8093c 100644
38840 --- a/drivers/media/usb/dvb-usb/dw2102.c
38841 +++ b/drivers/media/usb/dvb-usb/dw2102.c
38842 @@ -95,7 +95,7 @@ struct su3000_state {
38843
38844 struct s6x0_state {
38845 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
38846 -};
38847 +} __no_const;
38848
38849 /* debug */
38850 static int dvb_usb_dw2102_debug;
38851 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
38852 index aa6e7c7..4cd8061 100644
38853 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
38854 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
38855 @@ -1923,7 +1923,8 @@ struct v4l2_ioctl_info {
38856 struct file *file, void *fh, void *p);
38857 } u;
38858 void (*debug)(const void *arg, bool write_only);
38859 -};
38860 +} __do_const;
38861 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
38862
38863 /* This control needs a priority check */
38864 #define INFO_FL_PRIO (1 << 0)
38865 @@ -2108,7 +2109,7 @@ static long __video_do_ioctl(struct file *file,
38866 struct video_device *vfd = video_devdata(file);
38867 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
38868 bool write_only = false;
38869 - struct v4l2_ioctl_info default_info;
38870 + v4l2_ioctl_info_no_const default_info;
38871 const struct v4l2_ioctl_info *info;
38872 void *fh = file->private_data;
38873 struct v4l2_fh *vfh = NULL;
38874 diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c
38875 index 29b2172..a7c5b31 100644
38876 --- a/drivers/memstick/host/r592.c
38877 +++ b/drivers/memstick/host/r592.c
38878 @@ -454,7 +454,7 @@ static int r592_transfer_fifo_pio(struct r592_device *dev)
38879 /* Executes one TPC (data is read/written from small or large fifo) */
38880 static void r592_execute_tpc(struct r592_device *dev)
38881 {
38882 - bool is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38883 + bool is_write;
38884 int len, error;
38885 u32 status, reg;
38886
38887 @@ -463,6 +463,7 @@ static void r592_execute_tpc(struct r592_device *dev)
38888 return;
38889 }
38890
38891 + is_write = dev->req->tpc >= MS_TPC_SET_RW_REG_ADRS;
38892 len = dev->req->long_data ?
38893 dev->req->sg.length : dev->req->data_len;
38894
38895 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
38896 index fb69baa..3aeea2e 100644
38897 --- a/drivers/message/fusion/mptbase.c
38898 +++ b/drivers/message/fusion/mptbase.c
38899 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38900 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
38901 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
38902
38903 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38904 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
38905 +#else
38906 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
38907 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
38908 +#endif
38909 +
38910 /*
38911 * Rounding UP to nearest 4-kB boundary here...
38912 */
38913 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
38914 ioc->facts.GlobalCredits);
38915
38916 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
38917 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38918 + NULL, NULL);
38919 +#else
38920 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
38921 +#endif
38922 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
38923 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
38924 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
38925 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
38926 index fa43c39..daeb158 100644
38927 --- a/drivers/message/fusion/mptsas.c
38928 +++ b/drivers/message/fusion/mptsas.c
38929 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
38930 return 0;
38931 }
38932
38933 +static inline void
38934 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38935 +{
38936 + if (phy_info->port_details) {
38937 + phy_info->port_details->rphy = rphy;
38938 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38939 + ioc->name, rphy));
38940 + }
38941 +
38942 + if (rphy) {
38943 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38944 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38945 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38946 + ioc->name, rphy, rphy->dev.release));
38947 + }
38948 +}
38949 +
38950 /* no mutex */
38951 static void
38952 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
38953 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
38954 return NULL;
38955 }
38956
38957 -static inline void
38958 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
38959 -{
38960 - if (phy_info->port_details) {
38961 - phy_info->port_details->rphy = rphy;
38962 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
38963 - ioc->name, rphy));
38964 - }
38965 -
38966 - if (rphy) {
38967 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
38968 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
38969 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
38970 - ioc->name, rphy, rphy->dev.release));
38971 - }
38972 -}
38973 -
38974 static inline struct sas_port *
38975 mptsas_get_port(struct mptsas_phyinfo *phy_info)
38976 {
38977 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
38978 index 164afa7..b6b2e74 100644
38979 --- a/drivers/message/fusion/mptscsih.c
38980 +++ b/drivers/message/fusion/mptscsih.c
38981 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
38982
38983 h = shost_priv(SChost);
38984
38985 - if (h) {
38986 - if (h->info_kbuf == NULL)
38987 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38988 - return h->info_kbuf;
38989 - h->info_kbuf[0] = '\0';
38990 + if (!h)
38991 + return NULL;
38992
38993 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
38994 - h->info_kbuf[size-1] = '\0';
38995 - }
38996 + if (h->info_kbuf == NULL)
38997 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
38998 + return h->info_kbuf;
38999 + h->info_kbuf[0] = '\0';
39000 +
39001 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39002 + h->info_kbuf[size-1] = '\0';
39003
39004 return h->info_kbuf;
39005 }
39006 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39007 index 8001aa6..b137580 100644
39008 --- a/drivers/message/i2o/i2o_proc.c
39009 +++ b/drivers/message/i2o/i2o_proc.c
39010 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39011 "Array Controller Device"
39012 };
39013
39014 -static char *chtostr(char *tmp, u8 *chars, int n)
39015 -{
39016 - tmp[0] = 0;
39017 - return strncat(tmp, (char *)chars, n);
39018 -}
39019 -
39020 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39021 char *group)
39022 {
39023 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39024 } *result;
39025
39026 i2o_exec_execute_ddm_table ddm_table;
39027 - char tmp[28 + 1];
39028
39029 result = kmalloc(sizeof(*result), GFP_KERNEL);
39030 if (!result)
39031 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39032
39033 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39034 seq_printf(seq, "%-#8x", ddm_table.module_id);
39035 - seq_printf(seq, "%-29s",
39036 - chtostr(tmp, ddm_table.module_name_version, 28));
39037 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39038 seq_printf(seq, "%9d ", ddm_table.data_size);
39039 seq_printf(seq, "%8d", ddm_table.code_size);
39040
39041 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39042
39043 i2o_driver_result_table *result;
39044 i2o_driver_store_table *dst;
39045 - char tmp[28 + 1];
39046
39047 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39048 if (result == NULL)
39049 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39050
39051 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39052 seq_printf(seq, "%-#8x", dst->module_id);
39053 - seq_printf(seq, "%-29s",
39054 - chtostr(tmp, dst->module_name_version, 28));
39055 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39056 + seq_printf(seq, "%-.28s", dst->module_name_version);
39057 + seq_printf(seq, "%-.8s", dst->date);
39058 seq_printf(seq, "%8d ", dst->module_size);
39059 seq_printf(seq, "%8d ", dst->mpb_size);
39060 seq_printf(seq, "0x%04x", dst->module_flags);
39061 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39062 // == (allow) 512d bytes (max)
39063 static u16 *work16 = (u16 *) work32;
39064 int token;
39065 - char tmp[16 + 1];
39066
39067 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39068
39069 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39070 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39071 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39072 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39073 - seq_printf(seq, "Vendor info : %s\n",
39074 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39075 - seq_printf(seq, "Product info : %s\n",
39076 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39077 - seq_printf(seq, "Description : %s\n",
39078 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39079 - seq_printf(seq, "Product rev. : %s\n",
39080 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39081 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39082 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39083 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39084 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39085
39086 seq_printf(seq, "Serial number : ");
39087 print_serial_number(seq, (u8 *) (work32 + 16),
39088 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39089 u8 pad[256]; // allow up to 256 byte (max) serial number
39090 } result;
39091
39092 - char tmp[24 + 1];
39093 -
39094 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39095
39096 if (token < 0) {
39097 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39098 }
39099
39100 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39101 - seq_printf(seq, "Module name : %s\n",
39102 - chtostr(tmp, result.module_name, 24));
39103 - seq_printf(seq, "Module revision : %s\n",
39104 - chtostr(tmp, result.module_rev, 8));
39105 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39106 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39107
39108 seq_printf(seq, "Serial number : ");
39109 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39110 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39111 u8 instance_number[4];
39112 } result;
39113
39114 - char tmp[64 + 1];
39115 -
39116 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39117
39118 if (token < 0) {
39119 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39120 return 0;
39121 }
39122
39123 - seq_printf(seq, "Device name : %s\n",
39124 - chtostr(tmp, result.device_name, 64));
39125 - seq_printf(seq, "Service name : %s\n",
39126 - chtostr(tmp, result.service_name, 64));
39127 - seq_printf(seq, "Physical name : %s\n",
39128 - chtostr(tmp, result.physical_location, 64));
39129 - seq_printf(seq, "Instance number : %s\n",
39130 - chtostr(tmp, result.instance_number, 4));
39131 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39132 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39133 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39134 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39135
39136 return 0;
39137 }
39138 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39139 index a8c08f3..155fe3d 100644
39140 --- a/drivers/message/i2o/iop.c
39141 +++ b/drivers/message/i2o/iop.c
39142 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39143
39144 spin_lock_irqsave(&c->context_list_lock, flags);
39145
39146 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39147 - atomic_inc(&c->context_list_counter);
39148 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39149 + atomic_inc_unchecked(&c->context_list_counter);
39150
39151 - entry->context = atomic_read(&c->context_list_counter);
39152 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39153
39154 list_add(&entry->list, &c->context_list);
39155
39156 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39157
39158 #if BITS_PER_LONG == 64
39159 spin_lock_init(&c->context_list_lock);
39160 - atomic_set(&c->context_list_counter, 0);
39161 + atomic_set_unchecked(&c->context_list_counter, 0);
39162 INIT_LIST_HEAD(&c->context_list);
39163 #endif
39164
39165 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39166 index 45ece11..8efa218 100644
39167 --- a/drivers/mfd/janz-cmodio.c
39168 +++ b/drivers/mfd/janz-cmodio.c
39169 @@ -13,6 +13,7 @@
39170
39171 #include <linux/kernel.h>
39172 #include <linux/module.h>
39173 +#include <linux/slab.h>
39174 #include <linux/init.h>
39175 #include <linux/pci.h>
39176 #include <linux/interrupt.h>
39177 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39178 index a5f9888..1c0ed56 100644
39179 --- a/drivers/mfd/twl4030-irq.c
39180 +++ b/drivers/mfd/twl4030-irq.c
39181 @@ -35,6 +35,7 @@
39182 #include <linux/of.h>
39183 #include <linux/irqdomain.h>
39184 #include <linux/i2c/twl.h>
39185 +#include <asm/pgtable.h>
39186
39187 #include "twl-core.h"
39188
39189 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39190 * Install an irq handler for each of the SIH modules;
39191 * clone dummy irq_chip since PIH can't *do* anything
39192 */
39193 - twl4030_irq_chip = dummy_irq_chip;
39194 - twl4030_irq_chip.name = "twl4030";
39195 + pax_open_kernel();
39196 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39197 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39198
39199 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39200 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39201 + pax_close_kernel();
39202
39203 for (i = irq_base; i < irq_end; i++) {
39204 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39205 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39206 index 277a8db..0e0b754 100644
39207 --- a/drivers/mfd/twl6030-irq.c
39208 +++ b/drivers/mfd/twl6030-irq.c
39209 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39210 * install an irq handler for each of the modules;
39211 * clone dummy irq_chip since PIH can't *do* anything
39212 */
39213 - twl6030_irq_chip = dummy_irq_chip;
39214 - twl6030_irq_chip.name = "twl6030";
39215 - twl6030_irq_chip.irq_set_type = NULL;
39216 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39217 + pax_open_kernel();
39218 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39219 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39220 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39221 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39222 + pax_close_kernel();
39223
39224 for (i = irq_base; i < irq_end; i++) {
39225 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39226 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39227 index f428d86..274c368 100644
39228 --- a/drivers/misc/c2port/core.c
39229 +++ b/drivers/misc/c2port/core.c
39230 @@ -924,7 +924,9 @@ struct c2port_device *c2port_device_register(char *name,
39231 mutex_init(&c2dev->mutex);
39232
39233 /* Create binary file */
39234 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39235 + pax_open_kernel();
39236 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39237 + pax_close_kernel();
39238 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39239 if (unlikely(ret))
39240 goto error_device_create_bin_file;
39241 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39242 index 3aa9a96..59cf685 100644
39243 --- a/drivers/misc/kgdbts.c
39244 +++ b/drivers/misc/kgdbts.c
39245 @@ -832,7 +832,7 @@ static void run_plant_and_detach_test(int is_early)
39246 char before[BREAK_INSTR_SIZE];
39247 char after[BREAK_INSTR_SIZE];
39248
39249 - probe_kernel_read(before, (char *)kgdbts_break_test,
39250 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39251 BREAK_INSTR_SIZE);
39252 init_simple_test();
39253 ts.tst = plant_and_detach_test;
39254 @@ -840,7 +840,7 @@ static void run_plant_and_detach_test(int is_early)
39255 /* Activate test with initial breakpoint */
39256 if (!is_early)
39257 kgdb_breakpoint();
39258 - probe_kernel_read(after, (char *)kgdbts_break_test,
39259 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39260 BREAK_INSTR_SIZE);
39261 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39262 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39263 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39264 index 4a87e5c..76bdf5c 100644
39265 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39266 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39267 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39268 * the lid is closed. This leads to interrupts as soon as a little move
39269 * is done.
39270 */
39271 - atomic_inc(&lis3->count);
39272 + atomic_inc_unchecked(&lis3->count);
39273
39274 wake_up_interruptible(&lis3->misc_wait);
39275 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39276 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39277 if (lis3->pm_dev)
39278 pm_runtime_get_sync(lis3->pm_dev);
39279
39280 - atomic_set(&lis3->count, 0);
39281 + atomic_set_unchecked(&lis3->count, 0);
39282 return 0;
39283 }
39284
39285 @@ -617,7 +617,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39286 add_wait_queue(&lis3->misc_wait, &wait);
39287 while (true) {
39288 set_current_state(TASK_INTERRUPTIBLE);
39289 - data = atomic_xchg(&lis3->count, 0);
39290 + data = atomic_xchg_unchecked(&lis3->count, 0);
39291 if (data)
39292 break;
39293
39294 @@ -658,7 +658,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39295 struct lis3lv02d, miscdev);
39296
39297 poll_wait(file, &lis3->misc_wait, wait);
39298 - if (atomic_read(&lis3->count))
39299 + if (atomic_read_unchecked(&lis3->count))
39300 return POLLIN | POLLRDNORM;
39301 return 0;
39302 }
39303 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39304 index c439c82..1f20f57 100644
39305 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39306 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39307 @@ -297,7 +297,7 @@ struct lis3lv02d {
39308 struct input_polled_dev *idev; /* input device */
39309 struct platform_device *pdev; /* platform device */
39310 struct regulator_bulk_data regulators[2];
39311 - atomic_t count; /* interrupt count after last read */
39312 + atomic_unchecked_t count; /* interrupt count after last read */
39313 union axis_conversion ac; /* hw -> logical axis */
39314 int mapped_btns[3];
39315
39316 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39317 index 2f30bad..c4c13d0 100644
39318 --- a/drivers/misc/sgi-gru/gruhandles.c
39319 +++ b/drivers/misc/sgi-gru/gruhandles.c
39320 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39321 unsigned long nsec;
39322
39323 nsec = CLKS2NSEC(clks);
39324 - atomic_long_inc(&mcs_op_statistics[op].count);
39325 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39326 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39327 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39328 if (mcs_op_statistics[op].max < nsec)
39329 mcs_op_statistics[op].max = nsec;
39330 }
39331 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39332 index 950dbe9..eeef0f8 100644
39333 --- a/drivers/misc/sgi-gru/gruprocfs.c
39334 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39335 @@ -32,9 +32,9 @@
39336
39337 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39338
39339 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39340 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39341 {
39342 - unsigned long val = atomic_long_read(v);
39343 + unsigned long val = atomic_long_read_unchecked(v);
39344
39345 seq_printf(s, "%16lu %s\n", val, id);
39346 }
39347 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39348
39349 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39350 for (op = 0; op < mcsop_last; op++) {
39351 - count = atomic_long_read(&mcs_op_statistics[op].count);
39352 - total = atomic_long_read(&mcs_op_statistics[op].total);
39353 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39354 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39355 max = mcs_op_statistics[op].max;
39356 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39357 count ? total / count : 0, max);
39358 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39359 index 5c3ce24..4915ccb 100644
39360 --- a/drivers/misc/sgi-gru/grutables.h
39361 +++ b/drivers/misc/sgi-gru/grutables.h
39362 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39363 * GRU statistics.
39364 */
39365 struct gru_stats_s {
39366 - atomic_long_t vdata_alloc;
39367 - atomic_long_t vdata_free;
39368 - atomic_long_t gts_alloc;
39369 - atomic_long_t gts_free;
39370 - atomic_long_t gms_alloc;
39371 - atomic_long_t gms_free;
39372 - atomic_long_t gts_double_allocate;
39373 - atomic_long_t assign_context;
39374 - atomic_long_t assign_context_failed;
39375 - atomic_long_t free_context;
39376 - atomic_long_t load_user_context;
39377 - atomic_long_t load_kernel_context;
39378 - atomic_long_t lock_kernel_context;
39379 - atomic_long_t unlock_kernel_context;
39380 - atomic_long_t steal_user_context;
39381 - atomic_long_t steal_kernel_context;
39382 - atomic_long_t steal_context_failed;
39383 - atomic_long_t nopfn;
39384 - atomic_long_t asid_new;
39385 - atomic_long_t asid_next;
39386 - atomic_long_t asid_wrap;
39387 - atomic_long_t asid_reuse;
39388 - atomic_long_t intr;
39389 - atomic_long_t intr_cbr;
39390 - atomic_long_t intr_tfh;
39391 - atomic_long_t intr_spurious;
39392 - atomic_long_t intr_mm_lock_failed;
39393 - atomic_long_t call_os;
39394 - atomic_long_t call_os_wait_queue;
39395 - atomic_long_t user_flush_tlb;
39396 - atomic_long_t user_unload_context;
39397 - atomic_long_t user_exception;
39398 - atomic_long_t set_context_option;
39399 - atomic_long_t check_context_retarget_intr;
39400 - atomic_long_t check_context_unload;
39401 - atomic_long_t tlb_dropin;
39402 - atomic_long_t tlb_preload_page;
39403 - atomic_long_t tlb_dropin_fail_no_asid;
39404 - atomic_long_t tlb_dropin_fail_upm;
39405 - atomic_long_t tlb_dropin_fail_invalid;
39406 - atomic_long_t tlb_dropin_fail_range_active;
39407 - atomic_long_t tlb_dropin_fail_idle;
39408 - atomic_long_t tlb_dropin_fail_fmm;
39409 - atomic_long_t tlb_dropin_fail_no_exception;
39410 - atomic_long_t tfh_stale_on_fault;
39411 - atomic_long_t mmu_invalidate_range;
39412 - atomic_long_t mmu_invalidate_page;
39413 - atomic_long_t flush_tlb;
39414 - atomic_long_t flush_tlb_gru;
39415 - atomic_long_t flush_tlb_gru_tgh;
39416 - atomic_long_t flush_tlb_gru_zero_asid;
39417 + atomic_long_unchecked_t vdata_alloc;
39418 + atomic_long_unchecked_t vdata_free;
39419 + atomic_long_unchecked_t gts_alloc;
39420 + atomic_long_unchecked_t gts_free;
39421 + atomic_long_unchecked_t gms_alloc;
39422 + atomic_long_unchecked_t gms_free;
39423 + atomic_long_unchecked_t gts_double_allocate;
39424 + atomic_long_unchecked_t assign_context;
39425 + atomic_long_unchecked_t assign_context_failed;
39426 + atomic_long_unchecked_t free_context;
39427 + atomic_long_unchecked_t load_user_context;
39428 + atomic_long_unchecked_t load_kernel_context;
39429 + atomic_long_unchecked_t lock_kernel_context;
39430 + atomic_long_unchecked_t unlock_kernel_context;
39431 + atomic_long_unchecked_t steal_user_context;
39432 + atomic_long_unchecked_t steal_kernel_context;
39433 + atomic_long_unchecked_t steal_context_failed;
39434 + atomic_long_unchecked_t nopfn;
39435 + atomic_long_unchecked_t asid_new;
39436 + atomic_long_unchecked_t asid_next;
39437 + atomic_long_unchecked_t asid_wrap;
39438 + atomic_long_unchecked_t asid_reuse;
39439 + atomic_long_unchecked_t intr;
39440 + atomic_long_unchecked_t intr_cbr;
39441 + atomic_long_unchecked_t intr_tfh;
39442 + atomic_long_unchecked_t intr_spurious;
39443 + atomic_long_unchecked_t intr_mm_lock_failed;
39444 + atomic_long_unchecked_t call_os;
39445 + atomic_long_unchecked_t call_os_wait_queue;
39446 + atomic_long_unchecked_t user_flush_tlb;
39447 + atomic_long_unchecked_t user_unload_context;
39448 + atomic_long_unchecked_t user_exception;
39449 + atomic_long_unchecked_t set_context_option;
39450 + atomic_long_unchecked_t check_context_retarget_intr;
39451 + atomic_long_unchecked_t check_context_unload;
39452 + atomic_long_unchecked_t tlb_dropin;
39453 + atomic_long_unchecked_t tlb_preload_page;
39454 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39455 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39456 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39457 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39458 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39459 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39460 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39461 + atomic_long_unchecked_t tfh_stale_on_fault;
39462 + atomic_long_unchecked_t mmu_invalidate_range;
39463 + atomic_long_unchecked_t mmu_invalidate_page;
39464 + atomic_long_unchecked_t flush_tlb;
39465 + atomic_long_unchecked_t flush_tlb_gru;
39466 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39467 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39468
39469 - atomic_long_t copy_gpa;
39470 - atomic_long_t read_gpa;
39471 + atomic_long_unchecked_t copy_gpa;
39472 + atomic_long_unchecked_t read_gpa;
39473
39474 - atomic_long_t mesq_receive;
39475 - atomic_long_t mesq_receive_none;
39476 - atomic_long_t mesq_send;
39477 - atomic_long_t mesq_send_failed;
39478 - atomic_long_t mesq_noop;
39479 - atomic_long_t mesq_send_unexpected_error;
39480 - atomic_long_t mesq_send_lb_overflow;
39481 - atomic_long_t mesq_send_qlimit_reached;
39482 - atomic_long_t mesq_send_amo_nacked;
39483 - atomic_long_t mesq_send_put_nacked;
39484 - atomic_long_t mesq_page_overflow;
39485 - atomic_long_t mesq_qf_locked;
39486 - atomic_long_t mesq_qf_noop_not_full;
39487 - atomic_long_t mesq_qf_switch_head_failed;
39488 - atomic_long_t mesq_qf_unexpected_error;
39489 - atomic_long_t mesq_noop_unexpected_error;
39490 - atomic_long_t mesq_noop_lb_overflow;
39491 - atomic_long_t mesq_noop_qlimit_reached;
39492 - atomic_long_t mesq_noop_amo_nacked;
39493 - atomic_long_t mesq_noop_put_nacked;
39494 - atomic_long_t mesq_noop_page_overflow;
39495 + atomic_long_unchecked_t mesq_receive;
39496 + atomic_long_unchecked_t mesq_receive_none;
39497 + atomic_long_unchecked_t mesq_send;
39498 + atomic_long_unchecked_t mesq_send_failed;
39499 + atomic_long_unchecked_t mesq_noop;
39500 + atomic_long_unchecked_t mesq_send_unexpected_error;
39501 + atomic_long_unchecked_t mesq_send_lb_overflow;
39502 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39503 + atomic_long_unchecked_t mesq_send_amo_nacked;
39504 + atomic_long_unchecked_t mesq_send_put_nacked;
39505 + atomic_long_unchecked_t mesq_page_overflow;
39506 + atomic_long_unchecked_t mesq_qf_locked;
39507 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39508 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39509 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39510 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39511 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39512 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39513 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39514 + atomic_long_unchecked_t mesq_noop_put_nacked;
39515 + atomic_long_unchecked_t mesq_noop_page_overflow;
39516
39517 };
39518
39519 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39520 tghop_invalidate, mcsop_last};
39521
39522 struct mcs_op_statistic {
39523 - atomic_long_t count;
39524 - atomic_long_t total;
39525 + atomic_long_unchecked_t count;
39526 + atomic_long_unchecked_t total;
39527 unsigned long max;
39528 };
39529
39530 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39531
39532 #define STAT(id) do { \
39533 if (gru_options & OPT_STATS) \
39534 - atomic_long_inc(&gru_stats.id); \
39535 + atomic_long_inc_unchecked(&gru_stats.id); \
39536 } while (0)
39537
39538 #ifdef CONFIG_SGI_GRU_DEBUG
39539 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39540 index c862cd4..0d176fe 100644
39541 --- a/drivers/misc/sgi-xp/xp.h
39542 +++ b/drivers/misc/sgi-xp/xp.h
39543 @@ -288,7 +288,7 @@ struct xpc_interface {
39544 xpc_notify_func, void *);
39545 void (*received) (short, int, void *);
39546 enum xp_retval (*partid_to_nasids) (short, void *);
39547 -};
39548 +} __no_const;
39549
39550 extern struct xpc_interface xpc_interface;
39551
39552 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39553 index b94d5f7..7f494c5 100644
39554 --- a/drivers/misc/sgi-xp/xpc.h
39555 +++ b/drivers/misc/sgi-xp/xpc.h
39556 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39557 void (*received_payload) (struct xpc_channel *, void *);
39558 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39559 };
39560 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39561
39562 /* struct xpc_partition act_state values (for XPC HB) */
39563
39564 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39565 /* found in xpc_main.c */
39566 extern struct device *xpc_part;
39567 extern struct device *xpc_chan;
39568 -extern struct xpc_arch_operations xpc_arch_ops;
39569 +extern xpc_arch_operations_no_const xpc_arch_ops;
39570 extern int xpc_disengage_timelimit;
39571 extern int xpc_disengage_timedout;
39572 extern int xpc_activate_IRQ_rcvd;
39573 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39574 index d971817..33bdca5 100644
39575 --- a/drivers/misc/sgi-xp/xpc_main.c
39576 +++ b/drivers/misc/sgi-xp/xpc_main.c
39577 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39578 .notifier_call = xpc_system_die,
39579 };
39580
39581 -struct xpc_arch_operations xpc_arch_ops;
39582 +xpc_arch_operations_no_const xpc_arch_ops;
39583
39584 /*
39585 * Timer function to enforce the timelimit on the partition disengage.
39586 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39587
39588 if (((die_args->trapnr == X86_TRAP_MF) ||
39589 (die_args->trapnr == X86_TRAP_XF)) &&
39590 - !user_mode_vm(die_args->regs))
39591 + !user_mode(die_args->regs))
39592 xpc_die_deactivate();
39593
39594 break;
39595 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39596 index 6d8f701..35b6369 100644
39597 --- a/drivers/mmc/core/mmc_ops.c
39598 +++ b/drivers/mmc/core/mmc_ops.c
39599 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39600 void *data_buf;
39601 int is_on_stack;
39602
39603 - is_on_stack = object_is_on_stack(buf);
39604 + is_on_stack = object_starts_on_stack(buf);
39605 if (is_on_stack) {
39606 /*
39607 * dma onto stack is unsafe/nonportable, but callers to this
39608 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39609 index 53b8fd9..615b462 100644
39610 --- a/drivers/mmc/host/dw_mmc.h
39611 +++ b/drivers/mmc/host/dw_mmc.h
39612 @@ -205,5 +205,5 @@ struct dw_mci_drv_data {
39613 int (*parse_dt)(struct dw_mci *host);
39614 int (*setup_bus)(struct dw_mci *host,
39615 struct device_node *slot_np, u8 bus_width);
39616 -};
39617 +} __do_const;
39618 #endif /* _DW_MMC_H_ */
39619 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39620 index 82a8de1..3c56ccb 100644
39621 --- a/drivers/mmc/host/sdhci-s3c.c
39622 +++ b/drivers/mmc/host/sdhci-s3c.c
39623 @@ -721,9 +721,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39624 * we can use overriding functions instead of default.
39625 */
39626 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39627 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39628 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39629 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39630 + pax_open_kernel();
39631 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39632 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39633 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39634 + pax_close_kernel();
39635 }
39636
39637 /* It supports additional host capabilities if needed */
39638 diff --git a/drivers/mtd/devices/doc2000.c b/drivers/mtd/devices/doc2000.c
39639 index a4eb8b5..8c0628f 100644
39640 --- a/drivers/mtd/devices/doc2000.c
39641 +++ b/drivers/mtd/devices/doc2000.c
39642 @@ -753,7 +753,7 @@ static int doc_write(struct mtd_info *mtd, loff_t to, size_t len,
39643
39644 /* The ECC will not be calculated correctly if less than 512 is written */
39645 /* DBB-
39646 - if (len != 0x200 && eccbuf)
39647 + if (len != 0x200)
39648 printk(KERN_WARNING
39649 "ECC needs a full sector write (adr: %lx size %lx)\n",
39650 (long) to, (long) len);
39651 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39652 index 0c8bb6b..6f35deb 100644
39653 --- a/drivers/mtd/nand/denali.c
39654 +++ b/drivers/mtd/nand/denali.c
39655 @@ -24,6 +24,7 @@
39656 #include <linux/slab.h>
39657 #include <linux/mtd/mtd.h>
39658 #include <linux/module.h>
39659 +#include <linux/slab.h>
39660
39661 #include "denali.h"
39662
39663 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39664 index 51b9d6a..52af9a7 100644
39665 --- a/drivers/mtd/nftlmount.c
39666 +++ b/drivers/mtd/nftlmount.c
39667 @@ -24,6 +24,7 @@
39668 #include <asm/errno.h>
39669 #include <linux/delay.h>
39670 #include <linux/slab.h>
39671 +#include <linux/sched.h>
39672 #include <linux/mtd/mtd.h>
39673 #include <linux/mtd/nand.h>
39674 #include <linux/mtd/nftl.h>
39675 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39676 index 8dd6ba5..419cc1d 100644
39677 --- a/drivers/mtd/sm_ftl.c
39678 +++ b/drivers/mtd/sm_ftl.c
39679 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39680 #define SM_CIS_VENDOR_OFFSET 0x59
39681 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39682 {
39683 - struct attribute_group *attr_group;
39684 + attribute_group_no_const *attr_group;
39685 struct attribute **attributes;
39686 struct sm_sysfs_attribute *vendor_attribute;
39687
39688 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39689 index 27cdf1f..8c37357 100644
39690 --- a/drivers/net/bonding/bond_main.c
39691 +++ b/drivers/net/bonding/bond_main.c
39692 @@ -4859,7 +4859,7 @@ static unsigned int bond_get_num_tx_queues(void)
39693 return tx_queues;
39694 }
39695
39696 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39697 +static struct rtnl_link_ops bond_link_ops = {
39698 .kind = "bond",
39699 .priv_size = sizeof(struct bonding),
39700 .setup = bond_setup,
39701 @@ -4975,8 +4975,8 @@ static void __exit bonding_exit(void)
39702
39703 bond_destroy_debugfs();
39704
39705 - rtnl_link_unregister(&bond_link_ops);
39706 unregister_pernet_subsys(&bond_net_ops);
39707 + rtnl_link_unregister(&bond_link_ops);
39708
39709 #ifdef CONFIG_NET_POLL_CONTROLLER
39710 /*
39711 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39712 index 70dba5d..11a0919 100644
39713 --- a/drivers/net/ethernet/8390/ax88796.c
39714 +++ b/drivers/net/ethernet/8390/ax88796.c
39715 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39716 if (ax->plat->reg_offsets)
39717 ei_local->reg_offset = ax->plat->reg_offsets;
39718 else {
39719 + resource_size_t _mem_size = mem_size;
39720 + do_div(_mem_size, 0x18);
39721 ei_local->reg_offset = ax->reg_offsets;
39722 for (ret = 0; ret < 0x18; ret++)
39723 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39724 + ax->reg_offsets[ret] = _mem_size * ret;
39725 }
39726
39727 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39728 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39729 index 0991534..8098e92 100644
39730 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39731 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39732 @@ -1094,7 +1094,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
39733 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
39734 {
39735 /* RX_MODE controlling object */
39736 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
39737 + bnx2x_init_rx_mode_obj(bp);
39738
39739 /* multicast configuration controlling object */
39740 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
39741 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39742 index 10bc093..a2fb42a 100644
39743 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39744 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c
39745 @@ -2136,12 +2136,12 @@ static u8 bnx2x_dcbnl_get_cap(struct net_device *netdev, int capid, u8 *cap)
39746 break;
39747 default:
39748 BNX2X_ERR("Non valid capability ID\n");
39749 - rval = -EINVAL;
39750 + rval = 1;
39751 break;
39752 }
39753 } else {
39754 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39755 - rval = -EINVAL;
39756 + rval = 1;
39757 }
39758
39759 DP(BNX2X_MSG_DCB, "capid %d:%x\n", capid, *cap);
39760 @@ -2167,12 +2167,12 @@ static int bnx2x_dcbnl_get_numtcs(struct net_device *netdev, int tcid, u8 *num)
39761 break;
39762 default:
39763 BNX2X_ERR("Non valid TC-ID\n");
39764 - rval = -EINVAL;
39765 + rval = 1;
39766 break;
39767 }
39768 } else {
39769 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39770 - rval = -EINVAL;
39771 + rval = 1;
39772 }
39773
39774 return rval;
39775 @@ -2185,7 +2185,7 @@ static int bnx2x_dcbnl_set_numtcs(struct net_device *netdev, int tcid, u8 num)
39776 return -EINVAL;
39777 }
39778
39779 -static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39780 +static u8 bnx2x_dcbnl_get_pfc_state(struct net_device *netdev)
39781 {
39782 struct bnx2x *bp = netdev_priv(netdev);
39783 DP(BNX2X_MSG_DCB, "state = %d\n", bp->dcbx_local_feat.pfc.enabled);
39784 @@ -2387,12 +2387,12 @@ static u8 bnx2x_dcbnl_get_featcfg(struct net_device *netdev, int featid,
39785 break;
39786 default:
39787 BNX2X_ERR("Non valid featrue-ID\n");
39788 - rval = -EINVAL;
39789 + rval = 1;
39790 break;
39791 }
39792 } else {
39793 DP(BNX2X_MSG_DCB, "DCB disabled\n");
39794 - rval = -EINVAL;
39795 + rval = 1;
39796 }
39797
39798 return rval;
39799 @@ -2428,12 +2428,12 @@ static u8 bnx2x_dcbnl_set_featcfg(struct net_device *netdev, int featid,
39800 break;
39801 default:
39802 BNX2X_ERR("Non valid featrue-ID\n");
39803 - rval = -EINVAL;
39804 + rval = 1;
39805 break;
39806 }
39807 } else {
39808 DP(BNX2X_MSG_DCB, "dcbnl call not valid\n");
39809 - rval = -EINVAL;
39810 + rval = 1;
39811 }
39812
39813 return rval;
39814 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39815 index 5523da3..4fcf274 100644
39816 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39817 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
39818 @@ -4767,7 +4767,7 @@ static void bnx2x_after_function_update(struct bnx2x *bp)
39819 q);
39820 }
39821
39822 - if (!NO_FCOE(bp)) {
39823 + if (!NO_FCOE(bp) && CNIC_ENABLED(bp)) {
39824 fp = &bp->fp[FCOE_IDX(bp)];
39825 queue_params.q_obj = &bnx2x_sp_obj(bp, fp).q_obj;
39826
39827 @@ -13047,6 +13047,7 @@ static int bnx2x_unregister_cnic(struct net_device *dev)
39828 RCU_INIT_POINTER(bp->cnic_ops, NULL);
39829 mutex_unlock(&bp->cnic_mutex);
39830 synchronize_rcu();
39831 + bp->cnic_enabled = false;
39832 kfree(bp->cnic_kwq);
39833 bp->cnic_kwq = NULL;
39834
39835 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39836 index 09b625e..15b16fe 100644
39837 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39838 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
39839 @@ -2375,15 +2375,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
39840 return rc;
39841 }
39842
39843 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39844 - struct bnx2x_rx_mode_obj *o)
39845 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
39846 {
39847 if (CHIP_IS_E1x(bp)) {
39848 - o->wait_comp = bnx2x_empty_rx_mode_wait;
39849 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
39850 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
39851 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
39852 } else {
39853 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
39854 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
39855 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
39856 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
39857 }
39858 }
39859
39860 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39861 index adbd91b..58ec94a 100644
39862 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39863 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
39864 @@ -1293,8 +1293,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
39865
39866 /********************* RX MODE ****************/
39867
39868 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
39869 - struct bnx2x_rx_mode_obj *o);
39870 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
39871
39872 /**
39873 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
39874 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
39875 index d330e81..ce1fb9a 100644
39876 --- a/drivers/net/ethernet/broadcom/tg3.h
39877 +++ b/drivers/net/ethernet/broadcom/tg3.h
39878 @@ -146,6 +146,7 @@
39879 #define CHIPREV_ID_5750_A0 0x4000
39880 #define CHIPREV_ID_5750_A1 0x4001
39881 #define CHIPREV_ID_5750_A3 0x4003
39882 +#define CHIPREV_ID_5750_C1 0x4201
39883 #define CHIPREV_ID_5750_C2 0x4202
39884 #define CHIPREV_ID_5752_A0_HW 0x5000
39885 #define CHIPREV_ID_5752_A0 0x6000
39886 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39887 index 8cffcdf..aadf043 100644
39888 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39889 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
39890 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
39891 */
39892 struct l2t_skb_cb {
39893 arp_failure_handler_func arp_failure_handler;
39894 -};
39895 +} __no_const;
39896
39897 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
39898
39899 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
39900 index 4c83003..2a2a5b9 100644
39901 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
39902 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
39903 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39904 for (i=0; i<ETH_ALEN; i++) {
39905 tmp.addr[i] = dev->dev_addr[i];
39906 }
39907 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39908 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
39909 break;
39910
39911 case DE4X5_SET_HWADDR: /* Set the hardware address */
39912 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
39913 spin_lock_irqsave(&lp->lock, flags);
39914 memcpy(&statbuf, &lp->pktStats, ioc->len);
39915 spin_unlock_irqrestore(&lp->lock, flags);
39916 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
39917 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
39918 return -EFAULT;
39919 break;
39920 }
39921 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
39922 index 4d6f3c5..6169e60 100644
39923 --- a/drivers/net/ethernet/emulex/benet/be_main.c
39924 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
39925 @@ -455,7 +455,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
39926
39927 if (wrapped)
39928 newacc += 65536;
39929 - ACCESS_ONCE(*acc) = newacc;
39930 + ACCESS_ONCE_RW(*acc) = newacc;
39931 }
39932
39933 void be_parse_stats(struct be_adapter *adapter)
39934 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
39935 index 74d749e..eefb1bd 100644
39936 --- a/drivers/net/ethernet/faraday/ftgmac100.c
39937 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
39938 @@ -31,6 +31,8 @@
39939 #include <linux/netdevice.h>
39940 #include <linux/phy.h>
39941 #include <linux/platform_device.h>
39942 +#include <linux/interrupt.h>
39943 +#include <linux/irqreturn.h>
39944 #include <net/ip.h>
39945
39946 #include "ftgmac100.h"
39947 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
39948 index b901a01..1ff32ee 100644
39949 --- a/drivers/net/ethernet/faraday/ftmac100.c
39950 +++ b/drivers/net/ethernet/faraday/ftmac100.c
39951 @@ -31,6 +31,8 @@
39952 #include <linux/module.h>
39953 #include <linux/netdevice.h>
39954 #include <linux/platform_device.h>
39955 +#include <linux/interrupt.h>
39956 +#include <linux/irqreturn.h>
39957
39958 #include "ftmac100.h"
39959
39960 diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
39961 index a59f077..7925d77 100644
39962 --- a/drivers/net/ethernet/intel/e100.c
39963 +++ b/drivers/net/ethernet/intel/e100.c
39964 @@ -870,7 +870,7 @@ err_unlock:
39965 }
39966
39967 static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39968 - void (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39969 + int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
39970 {
39971 struct cb *cb;
39972 unsigned long flags;
39973 @@ -888,10 +888,13 @@ static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
39974 nic->cbs_avail--;
39975 cb->skb = skb;
39976
39977 + err = cb_prepare(nic, cb, skb);
39978 + if (err)
39979 + goto err_unlock;
39980 +
39981 if (unlikely(!nic->cbs_avail))
39982 err = -ENOSPC;
39983
39984 - cb_prepare(nic, cb, skb);
39985
39986 /* Order is important otherwise we'll be in a race with h/w:
39987 * set S-bit in current first, then clear S-bit in previous. */
39988 @@ -1091,7 +1094,7 @@ static void e100_get_defaults(struct nic *nic)
39989 nic->mii.mdio_write = mdio_write;
39990 }
39991
39992 -static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39993 +static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39994 {
39995 struct config *config = &cb->u.config;
39996 u8 *c = (u8 *)config;
39997 @@ -1181,6 +1184,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
39998 netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
39999 "[16-23]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
40000 c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]);
40001 + return 0;
40002 }
40003
40004 /*************************************************************************
40005 @@ -1331,7 +1335,7 @@ static const struct firmware *e100_request_firmware(struct nic *nic)
40006 return fw;
40007 }
40008
40009 -static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40010 +static int e100_setup_ucode(struct nic *nic, struct cb *cb,
40011 struct sk_buff *skb)
40012 {
40013 const struct firmware *fw = (void *)skb;
40014 @@ -1358,6 +1362,7 @@ static void e100_setup_ucode(struct nic *nic, struct cb *cb,
40015 cb->u.ucode[min_size] |= cpu_to_le32((BUNDLESMALL) ? 0xFFFF : 0xFF80);
40016
40017 cb->command = cpu_to_le16(cb_ucode | cb_el);
40018 + return 0;
40019 }
40020
40021 static inline int e100_load_ucode_wait(struct nic *nic)
40022 @@ -1400,18 +1405,20 @@ static inline int e100_load_ucode_wait(struct nic *nic)
40023 return err;
40024 }
40025
40026 -static void e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40027 +static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
40028 struct sk_buff *skb)
40029 {
40030 cb->command = cpu_to_le16(cb_iaaddr);
40031 memcpy(cb->u.iaaddr, nic->netdev->dev_addr, ETH_ALEN);
40032 + return 0;
40033 }
40034
40035 -static void e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40036 +static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40037 {
40038 cb->command = cpu_to_le16(cb_dump);
40039 cb->u.dump_buffer_addr = cpu_to_le32(nic->dma_addr +
40040 offsetof(struct mem, dump_buf));
40041 + return 0;
40042 }
40043
40044 static int e100_phy_check_without_mii(struct nic *nic)
40045 @@ -1581,7 +1588,7 @@ static int e100_hw_init(struct nic *nic)
40046 return 0;
40047 }
40048
40049 -static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40050 +static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40051 {
40052 struct net_device *netdev = nic->netdev;
40053 struct netdev_hw_addr *ha;
40054 @@ -1596,6 +1603,7 @@ static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
40055 memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &ha->addr,
40056 ETH_ALEN);
40057 }
40058 + return 0;
40059 }
40060
40061 static void e100_set_multicast_list(struct net_device *netdev)
40062 @@ -1756,11 +1764,18 @@ static void e100_watchdog(unsigned long data)
40063 round_jiffies(jiffies + E100_WATCHDOG_PERIOD));
40064 }
40065
40066 -static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40067 +static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
40068 struct sk_buff *skb)
40069 {
40070 + dma_addr_t dma_addr;
40071 cb->command = nic->tx_command;
40072
40073 + dma_addr = pci_map_single(nic->pdev,
40074 + skb->data, skb->len, PCI_DMA_TODEVICE);
40075 + /* If we can't map the skb, have the upper layer try later */
40076 + if (pci_dma_mapping_error(nic->pdev, dma_addr))
40077 + return -ENOMEM;
40078 +
40079 /*
40080 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
40081 * testing, ie sending frames with bad CRC.
40082 @@ -1777,11 +1792,10 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
40083 cb->u.tcb.tcb_byte_count = 0;
40084 cb->u.tcb.threshold = nic->tx_threshold;
40085 cb->u.tcb.tbd_count = 1;
40086 - cb->u.tcb.tbd.buf_addr = cpu_to_le32(pci_map_single(nic->pdev,
40087 - skb->data, skb->len, PCI_DMA_TODEVICE));
40088 - /* check for mapping failure? */
40089 + cb->u.tcb.tbd.buf_addr = cpu_to_le32(dma_addr);
40090 cb->u.tcb.tbd.size = cpu_to_le16(skb->len);
40091 skb_tx_timestamp(skb);
40092 + return 0;
40093 }
40094
40095 static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
40096 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40097 index bb9256a..56d8752 100644
40098 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40099 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40100 @@ -806,7 +806,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40101 }
40102
40103 /* update the base incval used to calculate frequency adjustment */
40104 - ACCESS_ONCE(adapter->base_incval) = incval;
40105 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40106 smp_mb();
40107
40108 /* need lock to prevent incorrect read while modifying cyclecounter */
40109 diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
40110 index c124e67..db9b897 100644
40111 --- a/drivers/net/ethernet/lantiq_etop.c
40112 +++ b/drivers/net/ethernet/lantiq_etop.c
40113 @@ -769,7 +769,7 @@ ltq_etop_probe(struct platform_device *pdev)
40114 return 0;
40115
40116 err_free:
40117 - kfree(dev);
40118 + free_netdev(dev);
40119 err_out:
40120 return err;
40121 }
40122 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40123 index fbe5363..266b4e3 100644
40124 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40125 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40126 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40127 struct __vxge_hw_fifo *fifo;
40128 struct vxge_hw_fifo_config *config;
40129 u32 txdl_size, txdl_per_memblock;
40130 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40131 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40132 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40133 + };
40134 +
40135 struct __vxge_hw_virtualpath *vpath;
40136
40137 if ((vp == NULL) || (attr == NULL)) {
40138 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40139 goto exit;
40140 }
40141
40142 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40143 -
40144 fifo->mempool =
40145 __vxge_hw_mempool_create(vpath->hldev,
40146 fifo->config->memblock_size,
40147 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40148 index 2d849da..23bba3b 100644
40149 --- a/drivers/net/ethernet/realtek/r8169.c
40150 +++ b/drivers/net/ethernet/realtek/r8169.c
40151 @@ -741,22 +741,22 @@ struct rtl8169_private {
40152 struct mdio_ops {
40153 void (*write)(struct rtl8169_private *, int, int);
40154 int (*read)(struct rtl8169_private *, int);
40155 - } mdio_ops;
40156 + } __no_const mdio_ops;
40157
40158 struct pll_power_ops {
40159 void (*down)(struct rtl8169_private *);
40160 void (*up)(struct rtl8169_private *);
40161 - } pll_power_ops;
40162 + } __no_const pll_power_ops;
40163
40164 struct jumbo_ops {
40165 void (*enable)(struct rtl8169_private *);
40166 void (*disable)(struct rtl8169_private *);
40167 - } jumbo_ops;
40168 + } __no_const jumbo_ops;
40169
40170 struct csi_ops {
40171 void (*write)(struct rtl8169_private *, int, int);
40172 u32 (*read)(struct rtl8169_private *, int);
40173 - } csi_ops;
40174 + } __no_const csi_ops;
40175
40176 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40177 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40178 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40179 index 3f93624..cf01144 100644
40180 --- a/drivers/net/ethernet/sfc/ptp.c
40181 +++ b/drivers/net/ethernet/sfc/ptp.c
40182 @@ -553,7 +553,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40183 (u32)((u64)ptp->start.dma_addr >> 32));
40184
40185 /* Clear flag that signals MC ready */
40186 - ACCESS_ONCE(*start) = 0;
40187 + ACCESS_ONCE_RW(*start) = 0;
40188 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40189 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40190
40191 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40192 index 0c74a70..3bc6f68 100644
40193 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40194 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40195 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40196
40197 writel(value, ioaddr + MMC_CNTRL);
40198
40199 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40200 - MMC_CNTRL, value);
40201 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40202 +// MMC_CNTRL, value);
40203 }
40204
40205 /* To mask all all interrupts.*/
40206 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40207 index e6fe0d8..2b7d752 100644
40208 --- a/drivers/net/hyperv/hyperv_net.h
40209 +++ b/drivers/net/hyperv/hyperv_net.h
40210 @@ -101,7 +101,7 @@ struct rndis_device {
40211
40212 enum rndis_device_state state;
40213 bool link_state;
40214 - atomic_t new_req_id;
40215 + atomic_unchecked_t new_req_id;
40216
40217 spinlock_t request_lock;
40218 struct list_head req_list;
40219 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40220 index 2b657d4..9903bc0 100644
40221 --- a/drivers/net/hyperv/rndis_filter.c
40222 +++ b/drivers/net/hyperv/rndis_filter.c
40223 @@ -107,7 +107,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40224 * template
40225 */
40226 set = &rndis_msg->msg.set_req;
40227 - set->req_id = atomic_inc_return(&dev->new_req_id);
40228 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40229
40230 /* Add to the request list */
40231 spin_lock_irqsave(&dev->request_lock, flags);
40232 @@ -758,7 +758,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40233
40234 /* Setup the rndis set */
40235 halt = &request->request_msg.msg.halt_req;
40236 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40237 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40238
40239 /* Ignore return since this msg is optional. */
40240 rndis_filter_send_request(dev, request);
40241 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40242 index 1e9cb0b..7839125 100644
40243 --- a/drivers/net/ieee802154/fakehard.c
40244 +++ b/drivers/net/ieee802154/fakehard.c
40245 @@ -386,7 +386,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40246 phy->transmit_power = 0xbf;
40247
40248 dev->netdev_ops = &fake_ops;
40249 - dev->ml_priv = &fake_mlme;
40250 + dev->ml_priv = (void *)&fake_mlme;
40251
40252 priv = netdev_priv(dev);
40253 priv->phy = phy;
40254 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40255 index e5cb723..1fc0461 100644
40256 --- a/drivers/net/macvlan.c
40257 +++ b/drivers/net/macvlan.c
40258 @@ -852,13 +852,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40259 int macvlan_link_register(struct rtnl_link_ops *ops)
40260 {
40261 /* common fields */
40262 - ops->priv_size = sizeof(struct macvlan_dev);
40263 - ops->validate = macvlan_validate;
40264 - ops->maxtype = IFLA_MACVLAN_MAX;
40265 - ops->policy = macvlan_policy;
40266 - ops->changelink = macvlan_changelink;
40267 - ops->get_size = macvlan_get_size;
40268 - ops->fill_info = macvlan_fill_info;
40269 + pax_open_kernel();
40270 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40271 + *(void **)&ops->validate = macvlan_validate;
40272 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40273 + *(const void **)&ops->policy = macvlan_policy;
40274 + *(void **)&ops->changelink = macvlan_changelink;
40275 + *(void **)&ops->get_size = macvlan_get_size;
40276 + *(void **)&ops->fill_info = macvlan_fill_info;
40277 + pax_close_kernel();
40278
40279 return rtnl_link_register(ops);
40280 };
40281 @@ -914,7 +916,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40282 return NOTIFY_DONE;
40283 }
40284
40285 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40286 +static struct notifier_block macvlan_notifier_block = {
40287 .notifier_call = macvlan_device_event,
40288 };
40289
40290 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40291 index 0f0f9ce..0ca5819 100644
40292 --- a/drivers/net/macvtap.c
40293 +++ b/drivers/net/macvtap.c
40294 @@ -1100,7 +1100,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40295 return NOTIFY_DONE;
40296 }
40297
40298 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40299 +static struct notifier_block macvtap_notifier_block = {
40300 .notifier_call = macvtap_device_event,
40301 };
40302
40303 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40304 index daec9b0..6428fcb 100644
40305 --- a/drivers/net/phy/mdio-bitbang.c
40306 +++ b/drivers/net/phy/mdio-bitbang.c
40307 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40308 struct mdiobb_ctrl *ctrl = bus->priv;
40309
40310 module_put(ctrl->ops->owner);
40311 + mdiobus_unregister(bus);
40312 mdiobus_free(bus);
40313 }
40314 EXPORT_SYMBOL(free_mdio_bitbang);
40315 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40316 index 508570e..f706dc7 100644
40317 --- a/drivers/net/ppp/ppp_generic.c
40318 +++ b/drivers/net/ppp/ppp_generic.c
40319 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40320 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40321 struct ppp_stats stats;
40322 struct ppp_comp_stats cstats;
40323 - char *vers;
40324
40325 switch (cmd) {
40326 case SIOCGPPPSTATS:
40327 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40328 break;
40329
40330 case SIOCGPPPVER:
40331 - vers = PPP_VERSION;
40332 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40333 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40334 break;
40335 err = 0;
40336 break;
40337 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40338 index 8efe47a..a8075c5 100644
40339 --- a/drivers/net/team/team.c
40340 +++ b/drivers/net/team/team.c
40341 @@ -2603,7 +2603,7 @@ static int team_device_event(struct notifier_block *unused,
40342 return NOTIFY_DONE;
40343 }
40344
40345 -static struct notifier_block team_notifier_block __read_mostly = {
40346 +static struct notifier_block team_notifier_block = {
40347 .notifier_call = team_device_event,
40348 };
40349
40350 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40351 index cb95fe5..a5bdab5 100644
40352 --- a/drivers/net/tun.c
40353 +++ b/drivers/net/tun.c
40354 @@ -1838,7 +1838,7 @@ unlock:
40355 }
40356
40357 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40358 - unsigned long arg, int ifreq_len)
40359 + unsigned long arg, size_t ifreq_len)
40360 {
40361 struct tun_file *tfile = file->private_data;
40362 struct tun_struct *tun;
40363 @@ -1850,6 +1850,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40364 int vnet_hdr_sz;
40365 int ret;
40366
40367 + if (ifreq_len > sizeof ifr)
40368 + return -EFAULT;
40369 +
40370 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40371 if (copy_from_user(&ifr, argp, ifreq_len))
40372 return -EFAULT;
40373 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40374 index cd8ccb2..cff5144 100644
40375 --- a/drivers/net/usb/hso.c
40376 +++ b/drivers/net/usb/hso.c
40377 @@ -71,7 +71,7 @@
40378 #include <asm/byteorder.h>
40379 #include <linux/serial_core.h>
40380 #include <linux/serial.h>
40381 -
40382 +#include <asm/local.h>
40383
40384 #define MOD_AUTHOR "Option Wireless"
40385 #define MOD_DESCRIPTION "USB High Speed Option driver"
40386 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40387 struct urb *urb;
40388
40389 urb = serial->rx_urb[0];
40390 - if (serial->port.count > 0) {
40391 + if (atomic_read(&serial->port.count) > 0) {
40392 count = put_rxbuf_data(urb, serial);
40393 if (count == -1)
40394 return;
40395 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40396 DUMP1(urb->transfer_buffer, urb->actual_length);
40397
40398 /* Anyone listening? */
40399 - if (serial->port.count == 0)
40400 + if (atomic_read(&serial->port.count) == 0)
40401 return;
40402
40403 if (status == 0) {
40404 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40405 tty_port_tty_set(&serial->port, tty);
40406
40407 /* check for port already opened, if not set the termios */
40408 - serial->port.count++;
40409 - if (serial->port.count == 1) {
40410 + if (atomic_inc_return(&serial->port.count) == 1) {
40411 serial->rx_state = RX_IDLE;
40412 /* Force default termio settings */
40413 _hso_serial_set_termios(tty, NULL);
40414 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40415 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40416 if (result) {
40417 hso_stop_serial_device(serial->parent);
40418 - serial->port.count--;
40419 + atomic_dec(&serial->port.count);
40420 kref_put(&serial->parent->ref, hso_serial_ref_free);
40421 }
40422 } else {
40423 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40424
40425 /* reset the rts and dtr */
40426 /* do the actual close */
40427 - serial->port.count--;
40428 + atomic_dec(&serial->port.count);
40429
40430 - if (serial->port.count <= 0) {
40431 - serial->port.count = 0;
40432 + if (atomic_read(&serial->port.count) <= 0) {
40433 + atomic_set(&serial->port.count, 0);
40434 tty_port_tty_set(&serial->port, NULL);
40435 if (!usb_gone)
40436 hso_stop_serial_device(serial->parent);
40437 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40438
40439 /* the actual setup */
40440 spin_lock_irqsave(&serial->serial_lock, flags);
40441 - if (serial->port.count)
40442 + if (atomic_read(&serial->port.count))
40443 _hso_serial_set_termios(tty, old);
40444 else
40445 tty->termios = *old;
40446 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40447 D1("Pending read interrupt on port %d\n", i);
40448 spin_lock(&serial->serial_lock);
40449 if (serial->rx_state == RX_IDLE &&
40450 - serial->port.count > 0) {
40451 + atomic_read(&serial->port.count) > 0) {
40452 /* Setup and send a ctrl req read on
40453 * port i */
40454 if (!serial->rx_urb_filled[0]) {
40455 @@ -3079,7 +3078,7 @@ static int hso_resume(struct usb_interface *iface)
40456 /* Start all serial ports */
40457 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40458 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40459 - if (dev2ser(serial_table[i])->port.count) {
40460 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40461 result =
40462 hso_start_serial_device(serial_table[i], GFP_NOIO);
40463 hso_kick_transmit(dev2ser(serial_table[i]));
40464 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40465 index 6993bfa..9053a34 100644
40466 --- a/drivers/net/vxlan.c
40467 +++ b/drivers/net/vxlan.c
40468 @@ -1428,7 +1428,7 @@ nla_put_failure:
40469 return -EMSGSIZE;
40470 }
40471
40472 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40473 +static struct rtnl_link_ops vxlan_link_ops = {
40474 .kind = "vxlan",
40475 .maxtype = IFLA_VXLAN_MAX,
40476 .policy = vxlan_policy,
40477 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40478 index 77fa428..996b355 100644
40479 --- a/drivers/net/wireless/at76c50x-usb.c
40480 +++ b/drivers/net/wireless/at76c50x-usb.c
40481 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40482 }
40483
40484 /* Convert timeout from the DFU status to jiffies */
40485 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40486 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40487 {
40488 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40489 | (s->poll_timeout[1] << 8)
40490 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40491 index 8d78253..bebbb68 100644
40492 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40493 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40494 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40495 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40496 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40497
40498 - ACCESS_ONCE(ads->ds_link) = i->link;
40499 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40500 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40501 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40502
40503 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40504 ctl6 = SM(i->keytype, AR_EncrType);
40505 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40506
40507 if ((i->is_first || i->is_last) &&
40508 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40509 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40510 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40511 | set11nTries(i->rates, 1)
40512 | set11nTries(i->rates, 2)
40513 | set11nTries(i->rates, 3)
40514 | (i->dur_update ? AR_DurUpdateEna : 0)
40515 | SM(0, AR_BurstDur);
40516
40517 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40518 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40519 | set11nRate(i->rates, 1)
40520 | set11nRate(i->rates, 2)
40521 | set11nRate(i->rates, 3);
40522 } else {
40523 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40524 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40525 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40526 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40527 }
40528
40529 if (!i->is_first) {
40530 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40531 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40532 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40533 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40534 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40535 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40536 return;
40537 }
40538
40539 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40540 break;
40541 }
40542
40543 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40544 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40545 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40546 | SM(i->txpower, AR_XmitPower)
40547 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40548 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40549 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40550 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40551
40552 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40553 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40554 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40555 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40556
40557 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40558 return;
40559
40560 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40561 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40562 | set11nPktDurRTSCTS(i->rates, 1);
40563
40564 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40565 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40566 | set11nPktDurRTSCTS(i->rates, 3);
40567
40568 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40569 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40570 | set11nRateFlags(i->rates, 1)
40571 | set11nRateFlags(i->rates, 2)
40572 | set11nRateFlags(i->rates, 3)
40573 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40574 index 301bf72..3f5654f 100644
40575 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40576 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40577 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40578 (i->qcu << AR_TxQcuNum_S) | desc_len;
40579
40580 checksum += val;
40581 - ACCESS_ONCE(ads->info) = val;
40582 + ACCESS_ONCE_RW(ads->info) = val;
40583
40584 checksum += i->link;
40585 - ACCESS_ONCE(ads->link) = i->link;
40586 + ACCESS_ONCE_RW(ads->link) = i->link;
40587
40588 checksum += i->buf_addr[0];
40589 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40590 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40591 checksum += i->buf_addr[1];
40592 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40593 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40594 checksum += i->buf_addr[2];
40595 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40596 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40597 checksum += i->buf_addr[3];
40598 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40599 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40600
40601 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40602 - ACCESS_ONCE(ads->ctl3) = val;
40603 + ACCESS_ONCE_RW(ads->ctl3) = val;
40604 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40605 - ACCESS_ONCE(ads->ctl5) = val;
40606 + ACCESS_ONCE_RW(ads->ctl5) = val;
40607 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40608 - ACCESS_ONCE(ads->ctl7) = val;
40609 + ACCESS_ONCE_RW(ads->ctl7) = val;
40610 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40611 - ACCESS_ONCE(ads->ctl9) = val;
40612 + ACCESS_ONCE_RW(ads->ctl9) = val;
40613
40614 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40615 - ACCESS_ONCE(ads->ctl10) = checksum;
40616 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40617
40618 if (i->is_first || i->is_last) {
40619 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40620 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40621 | set11nTries(i->rates, 1)
40622 | set11nTries(i->rates, 2)
40623 | set11nTries(i->rates, 3)
40624 | (i->dur_update ? AR_DurUpdateEna : 0)
40625 | SM(0, AR_BurstDur);
40626
40627 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40628 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40629 | set11nRate(i->rates, 1)
40630 | set11nRate(i->rates, 2)
40631 | set11nRate(i->rates, 3);
40632 } else {
40633 - ACCESS_ONCE(ads->ctl13) = 0;
40634 - ACCESS_ONCE(ads->ctl14) = 0;
40635 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40636 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40637 }
40638
40639 ads->ctl20 = 0;
40640 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40641
40642 ctl17 = SM(i->keytype, AR_EncrType);
40643 if (!i->is_first) {
40644 - ACCESS_ONCE(ads->ctl11) = 0;
40645 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40646 - ACCESS_ONCE(ads->ctl15) = 0;
40647 - ACCESS_ONCE(ads->ctl16) = 0;
40648 - ACCESS_ONCE(ads->ctl17) = ctl17;
40649 - ACCESS_ONCE(ads->ctl18) = 0;
40650 - ACCESS_ONCE(ads->ctl19) = 0;
40651 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40652 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40653 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40654 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40655 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40656 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40657 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40658 return;
40659 }
40660
40661 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40662 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40663 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40664 | SM(i->txpower, AR_XmitPower)
40665 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40666 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40667 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40668 ctl12 |= SM(val, AR_PAPRDChainMask);
40669
40670 - ACCESS_ONCE(ads->ctl12) = ctl12;
40671 - ACCESS_ONCE(ads->ctl17) = ctl17;
40672 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40673 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40674
40675 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40676 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40677 | set11nPktDurRTSCTS(i->rates, 1);
40678
40679 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40680 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40681 | set11nPktDurRTSCTS(i->rates, 3);
40682
40683 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40684 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40685 | set11nRateFlags(i->rates, 1)
40686 | set11nRateFlags(i->rates, 2)
40687 | set11nRateFlags(i->rates, 3)
40688 | SM(i->rtscts_rate, AR_RTSCTSRate);
40689
40690 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40691 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40692 }
40693
40694 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40695 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40696 index 9d26fc5..60d9f14 100644
40697 --- a/drivers/net/wireless/ath/ath9k/hw.h
40698 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40699 @@ -658,7 +658,7 @@ struct ath_hw_private_ops {
40700
40701 /* ANI */
40702 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40703 -};
40704 +} __no_const;
40705
40706 /**
40707 * struct ath_hw_ops - callbacks used by hardware code and driver code
40708 @@ -688,7 +688,7 @@ struct ath_hw_ops {
40709 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
40710 struct ath_hw_antcomb_conf *antconf);
40711 void (*antctrl_shared_chain_lnadiv)(struct ath_hw *hw, bool enable);
40712 -};
40713 +} __no_const;
40714
40715 struct ath_nf_limits {
40716 s16 max;
40717 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40718 index 3726cd6..b655808 100644
40719 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40720 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40721 @@ -3615,7 +3615,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40722 */
40723 if (il3945_mod_params.disable_hw_scan) {
40724 D_INFO("Disabling hw_scan\n");
40725 - il3945_mac_ops.hw_scan = NULL;
40726 + pax_open_kernel();
40727 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40728 + pax_close_kernel();
40729 }
40730
40731 D_INFO("*** LOAD DRIVER ***\n");
40732 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40733 index 5b9533e..7733880 100644
40734 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40735 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40736 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40737 {
40738 struct iwl_priv *priv = file->private_data;
40739 char buf[64];
40740 - int buf_size;
40741 + size_t buf_size;
40742 u32 offset, len;
40743
40744 memset(buf, 0, sizeof(buf));
40745 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40746 struct iwl_priv *priv = file->private_data;
40747
40748 char buf[8];
40749 - int buf_size;
40750 + size_t buf_size;
40751 u32 reset_flag;
40752
40753 memset(buf, 0, sizeof(buf));
40754 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40755 {
40756 struct iwl_priv *priv = file->private_data;
40757 char buf[8];
40758 - int buf_size;
40759 + size_t buf_size;
40760 int ht40;
40761
40762 memset(buf, 0, sizeof(buf));
40763 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40764 {
40765 struct iwl_priv *priv = file->private_data;
40766 char buf[8];
40767 - int buf_size;
40768 + size_t buf_size;
40769 int value;
40770
40771 memset(buf, 0, sizeof(buf));
40772 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40773 {
40774 struct iwl_priv *priv = file->private_data;
40775 char buf[8];
40776 - int buf_size;
40777 + size_t buf_size;
40778 int clear;
40779
40780 memset(buf, 0, sizeof(buf));
40781 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40782 {
40783 struct iwl_priv *priv = file->private_data;
40784 char buf[8];
40785 - int buf_size;
40786 + size_t buf_size;
40787 int trace;
40788
40789 memset(buf, 0, sizeof(buf));
40790 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40791 {
40792 struct iwl_priv *priv = file->private_data;
40793 char buf[8];
40794 - int buf_size;
40795 + size_t buf_size;
40796 int missed;
40797
40798 memset(buf, 0, sizeof(buf));
40799 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40800
40801 struct iwl_priv *priv = file->private_data;
40802 char buf[8];
40803 - int buf_size;
40804 + size_t buf_size;
40805 int plcp;
40806
40807 memset(buf, 0, sizeof(buf));
40808 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40809
40810 struct iwl_priv *priv = file->private_data;
40811 char buf[8];
40812 - int buf_size;
40813 + size_t buf_size;
40814 int flush;
40815
40816 memset(buf, 0, sizeof(buf));
40817 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40818
40819 struct iwl_priv *priv = file->private_data;
40820 char buf[8];
40821 - int buf_size;
40822 + size_t buf_size;
40823 int rts;
40824
40825 if (!priv->cfg->ht_params)
40826 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40827 {
40828 struct iwl_priv *priv = file->private_data;
40829 char buf[8];
40830 - int buf_size;
40831 + size_t buf_size;
40832
40833 memset(buf, 0, sizeof(buf));
40834 buf_size = min(count, sizeof(buf) - 1);
40835 @@ -2256,7 +2256,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40836 struct iwl_priv *priv = file->private_data;
40837 u32 event_log_flag;
40838 char buf[8];
40839 - int buf_size;
40840 + size_t buf_size;
40841
40842 /* check that the interface is up */
40843 if (!iwl_is_ready(priv))
40844 @@ -2310,7 +2310,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40845 struct iwl_priv *priv = file->private_data;
40846 char buf[8];
40847 u32 calib_disabled;
40848 - int buf_size;
40849 + size_t buf_size;
40850
40851 memset(buf, 0, sizeof(buf));
40852 buf_size = min(count, sizeof(buf) - 1);
40853 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40854 index 35708b9..31f7754 100644
40855 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40856 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40857 @@ -1100,7 +1100,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40858 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40859
40860 char buf[8];
40861 - int buf_size;
40862 + size_t buf_size;
40863 u32 reset_flag;
40864
40865 memset(buf, 0, sizeof(buf));
40866 @@ -1121,7 +1121,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40867 {
40868 struct iwl_trans *trans = file->private_data;
40869 char buf[8];
40870 - int buf_size;
40871 + size_t buf_size;
40872 int csr;
40873
40874 memset(buf, 0, sizeof(buf));
40875 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40876 index ff90855..e46d223 100644
40877 --- a/drivers/net/wireless/mac80211_hwsim.c
40878 +++ b/drivers/net/wireless/mac80211_hwsim.c
40879 @@ -2062,25 +2062,19 @@ static int __init init_mac80211_hwsim(void)
40880
40881 if (channels > 1) {
40882 hwsim_if_comb.num_different_channels = channels;
40883 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40884 - mac80211_hwsim_ops.cancel_hw_scan =
40885 - mac80211_hwsim_cancel_hw_scan;
40886 - mac80211_hwsim_ops.sw_scan_start = NULL;
40887 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40888 - mac80211_hwsim_ops.remain_on_channel =
40889 - mac80211_hwsim_roc;
40890 - mac80211_hwsim_ops.cancel_remain_on_channel =
40891 - mac80211_hwsim_croc;
40892 - mac80211_hwsim_ops.add_chanctx =
40893 - mac80211_hwsim_add_chanctx;
40894 - mac80211_hwsim_ops.remove_chanctx =
40895 - mac80211_hwsim_remove_chanctx;
40896 - mac80211_hwsim_ops.change_chanctx =
40897 - mac80211_hwsim_change_chanctx;
40898 - mac80211_hwsim_ops.assign_vif_chanctx =
40899 - mac80211_hwsim_assign_vif_chanctx;
40900 - mac80211_hwsim_ops.unassign_vif_chanctx =
40901 - mac80211_hwsim_unassign_vif_chanctx;
40902 + pax_open_kernel();
40903 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40904 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40905 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40906 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40907 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40908 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40909 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40910 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40911 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40912 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40913 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40914 + pax_close_kernel();
40915 }
40916
40917 spin_lock_init(&hwsim_radio_lock);
40918 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
40919 index abe1d03..fb02c22 100644
40920 --- a/drivers/net/wireless/rndis_wlan.c
40921 +++ b/drivers/net/wireless/rndis_wlan.c
40922 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
40923
40924 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
40925
40926 - if (rts_threshold < 0 || rts_threshold > 2347)
40927 + if (rts_threshold > 2347)
40928 rts_threshold = 2347;
40929
40930 tmp = cpu_to_le32(rts_threshold);
40931 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
40932 index 0751b35..246ba3e 100644
40933 --- a/drivers/net/wireless/rt2x00/rt2x00.h
40934 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
40935 @@ -398,7 +398,7 @@ struct rt2x00_intf {
40936 * for hardware which doesn't support hardware
40937 * sequence counting.
40938 */
40939 - atomic_t seqno;
40940 + atomic_unchecked_t seqno;
40941 };
40942
40943 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
40944 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
40945 index e488b94..14b6a0c 100644
40946 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
40947 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
40948 @@ -240,9 +240,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
40949 * sequence counter given by mac80211.
40950 */
40951 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
40952 - seqno = atomic_add_return(0x10, &intf->seqno);
40953 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
40954 else
40955 - seqno = atomic_read(&intf->seqno);
40956 + seqno = atomic_read_unchecked(&intf->seqno);
40957
40958 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
40959 hdr->seq_ctrl |= cpu_to_le16(seqno);
40960 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
40961 index e57ee48..541cf6c 100644
40962 --- a/drivers/net/wireless/ti/wl1251/sdio.c
40963 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
40964 @@ -269,13 +269,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
40965
40966 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
40967
40968 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40969 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40970 + pax_open_kernel();
40971 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
40972 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
40973 + pax_close_kernel();
40974
40975 wl1251_info("using dedicated interrupt line");
40976 } else {
40977 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40978 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40979 + pax_open_kernel();
40980 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
40981 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
40982 + pax_close_kernel();
40983
40984 wl1251_info("using SDIO interrupt");
40985 }
40986 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
40987 index e5f5f8f..fdf15b7 100644
40988 --- a/drivers/net/wireless/ti/wl12xx/main.c
40989 +++ b/drivers/net/wireless/ti/wl12xx/main.c
40990 @@ -644,7 +644,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
40991 sizeof(wl->conf.mem));
40992
40993 /* read data preparation is only needed by wl127x */
40994 - wl->ops->prepare_read = wl127x_prepare_read;
40995 + pax_open_kernel();
40996 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
40997 + pax_close_kernel();
40998
40999 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41000 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41001 @@ -665,7 +667,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41002 sizeof(wl->conf.mem));
41003
41004 /* read data preparation is only needed by wl127x */
41005 - wl->ops->prepare_read = wl127x_prepare_read;
41006 + pax_open_kernel();
41007 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41008 + pax_close_kernel();
41009
41010 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, WL127X_IFTYPE_VER,
41011 WL127X_MAJOR_VER, WL127X_SUBTYPE_VER,
41012 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41013 index 8d8c1f8..e754844 100644
41014 --- a/drivers/net/wireless/ti/wl18xx/main.c
41015 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41016 @@ -1489,8 +1489,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41017 }
41018
41019 if (!checksum_param) {
41020 - wl18xx_ops.set_rx_csum = NULL;
41021 - wl18xx_ops.init_vif = NULL;
41022 + pax_open_kernel();
41023 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41024 + *(void **)&wl18xx_ops.init_vif = NULL;
41025 + pax_close_kernel();
41026 }
41027
41028 /* Enable 11a Band only if we have 5G antennas */
41029 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41030 index ef2b171..bb513a6 100644
41031 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41032 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41033 @@ -387,7 +387,7 @@ static inline void handle_regs_int(struct urb *urb)
41034 {
41035 struct zd_usb *usb = urb->context;
41036 struct zd_usb_interrupt *intr = &usb->intr;
41037 - int len;
41038 + unsigned int len;
41039 u16 int_num;
41040
41041 ZD_ASSERT(in_interrupt());
41042 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41043 index d93b2b6..ae50401 100644
41044 --- a/drivers/oprofile/buffer_sync.c
41045 +++ b/drivers/oprofile/buffer_sync.c
41046 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41047 if (cookie == NO_COOKIE)
41048 offset = pc;
41049 if (cookie == INVALID_COOKIE) {
41050 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41051 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41052 offset = pc;
41053 }
41054 if (cookie != last_cookie) {
41055 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41056 /* add userspace sample */
41057
41058 if (!mm) {
41059 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41060 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41061 return 0;
41062 }
41063
41064 cookie = lookup_dcookie(mm, s->eip, &offset);
41065
41066 if (cookie == INVALID_COOKIE) {
41067 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41068 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41069 return 0;
41070 }
41071
41072 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41073 /* ignore backtraces if failed to add a sample */
41074 if (state == sb_bt_start) {
41075 state = sb_bt_ignore;
41076 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41077 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41078 }
41079 }
41080 release_mm(mm);
41081 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41082 index c0cc4e7..44d4e54 100644
41083 --- a/drivers/oprofile/event_buffer.c
41084 +++ b/drivers/oprofile/event_buffer.c
41085 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41086 }
41087
41088 if (buffer_pos == buffer_size) {
41089 - atomic_inc(&oprofile_stats.event_lost_overflow);
41090 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41091 return;
41092 }
41093
41094 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41095 index ed2c3ec..deda85a 100644
41096 --- a/drivers/oprofile/oprof.c
41097 +++ b/drivers/oprofile/oprof.c
41098 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41099 if (oprofile_ops.switch_events())
41100 return;
41101
41102 - atomic_inc(&oprofile_stats.multiplex_counter);
41103 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41104 start_switch_worker();
41105 }
41106
41107 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41108 index 84a208d..d61b0a1 100644
41109 --- a/drivers/oprofile/oprofile_files.c
41110 +++ b/drivers/oprofile/oprofile_files.c
41111 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41112
41113 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41114
41115 -static ssize_t timeout_read(struct file *file, char __user *buf,
41116 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41117 size_t count, loff_t *offset)
41118 {
41119 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41120 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41121 index 917d28e..d62d981 100644
41122 --- a/drivers/oprofile/oprofile_stats.c
41123 +++ b/drivers/oprofile/oprofile_stats.c
41124 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41125 cpu_buf->sample_invalid_eip = 0;
41126 }
41127
41128 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41129 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41130 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41131 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41132 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41133 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41134 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41135 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41136 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41137 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41138 }
41139
41140
41141 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41142 index 38b6fc0..b5cbfce 100644
41143 --- a/drivers/oprofile/oprofile_stats.h
41144 +++ b/drivers/oprofile/oprofile_stats.h
41145 @@ -13,11 +13,11 @@
41146 #include <linux/atomic.h>
41147
41148 struct oprofile_stat_struct {
41149 - atomic_t sample_lost_no_mm;
41150 - atomic_t sample_lost_no_mapping;
41151 - atomic_t bt_lost_no_mapping;
41152 - atomic_t event_lost_overflow;
41153 - atomic_t multiplex_counter;
41154 + atomic_unchecked_t sample_lost_no_mm;
41155 + atomic_unchecked_t sample_lost_no_mapping;
41156 + atomic_unchecked_t bt_lost_no_mapping;
41157 + atomic_unchecked_t event_lost_overflow;
41158 + atomic_unchecked_t multiplex_counter;
41159 };
41160
41161 extern struct oprofile_stat_struct oprofile_stats;
41162 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41163 index 849357c..b83c1e0 100644
41164 --- a/drivers/oprofile/oprofilefs.c
41165 +++ b/drivers/oprofile/oprofilefs.c
41166 @@ -185,7 +185,7 @@ static const struct file_operations atomic_ro_fops = {
41167
41168
41169 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41170 - char const *name, atomic_t *val)
41171 + char const *name, atomic_unchecked_t *val)
41172 {
41173 return __oprofilefs_create_file(sb, root, name,
41174 &atomic_ro_fops, 0444, val);
41175 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41176 index 93404f7..4a313d8 100644
41177 --- a/drivers/oprofile/timer_int.c
41178 +++ b/drivers/oprofile/timer_int.c
41179 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41180 return NOTIFY_OK;
41181 }
41182
41183 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41184 +static struct notifier_block oprofile_cpu_notifier = {
41185 .notifier_call = oprofile_cpu_notify,
41186 };
41187
41188 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41189 index 3f56bc0..707d642 100644
41190 --- a/drivers/parport/procfs.c
41191 +++ b/drivers/parport/procfs.c
41192 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41193
41194 *ppos += len;
41195
41196 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41197 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41198 }
41199
41200 #ifdef CONFIG_PARPORT_1284
41201 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41202
41203 *ppos += len;
41204
41205 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41206 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41207 }
41208 #endif /* IEEE1284.3 support. */
41209
41210 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41211 index c35e8ad..fc33beb 100644
41212 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41213 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41214 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41215 goto init_cleanup;
41216 }
41217
41218 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41219 + pax_open_kernel();
41220 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41221 + pax_close_kernel();
41222 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41223
41224 return retval;
41225 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41226 index a6a71c4..c91097b 100644
41227 --- a/drivers/pci/hotplug/cpcihp_generic.c
41228 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41229 @@ -73,7 +73,6 @@ static u16 port;
41230 static unsigned int enum_bit;
41231 static u8 enum_mask;
41232
41233 -static struct cpci_hp_controller_ops generic_hpc_ops;
41234 static struct cpci_hp_controller generic_hpc;
41235
41236 static int __init validate_parameters(void)
41237 @@ -139,6 +138,10 @@ static int query_enum(void)
41238 return ((value & enum_mask) == enum_mask);
41239 }
41240
41241 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41242 + .query_enum = query_enum,
41243 +};
41244 +
41245 static int __init cpcihp_generic_init(void)
41246 {
41247 int status;
41248 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41249 pci_dev_put(dev);
41250
41251 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41252 - generic_hpc_ops.query_enum = query_enum;
41253 generic_hpc.ops = &generic_hpc_ops;
41254
41255 status = cpci_hp_register_controller(&generic_hpc);
41256 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41257 index 449b4bb..257e2e8 100644
41258 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41259 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41260 @@ -59,7 +59,6 @@
41261 /* local variables */
41262 static bool debug;
41263 static bool poll;
41264 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41265 static struct cpci_hp_controller zt5550_hpc;
41266
41267 /* Primary cPCI bus bridge device */
41268 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41269 return 0;
41270 }
41271
41272 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41273 + .query_enum = zt5550_hc_query_enum,
41274 +};
41275 +
41276 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41277 {
41278 int status;
41279 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41280 dbg("returned from zt5550_hc_config");
41281
41282 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41283 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41284 zt5550_hpc.ops = &zt5550_hpc_ops;
41285 if(!poll) {
41286 zt5550_hpc.irq = hc_dev->irq;
41287 zt5550_hpc.irq_flags = IRQF_SHARED;
41288 zt5550_hpc.dev_id = hc_dev;
41289
41290 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41291 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41292 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41293 + pax_open_kernel();
41294 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41295 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41296 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41297 + pax_open_kernel();
41298 } else {
41299 info("using ENUM# polling mode");
41300 }
41301 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41302 index 76ba8a1..20ca857 100644
41303 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41304 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41305 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41306
41307 void compaq_nvram_init (void __iomem *rom_start)
41308 {
41309 +
41310 +#ifndef CONFIG_PAX_KERNEXEC
41311 if (rom_start) {
41312 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41313 }
41314 +#endif
41315 +
41316 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41317
41318 /* initialize our int15 lock */
41319 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41320 index 202f4a9..8ee47d0 100644
41321 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41322 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41323 @@ -448,8 +448,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41324 return -EINVAL;
41325 }
41326
41327 - slot->ops->owner = owner;
41328 - slot->ops->mod_name = mod_name;
41329 + pax_open_kernel();
41330 + *(struct module **)&slot->ops->owner = owner;
41331 + *(const char **)&slot->ops->mod_name = mod_name;
41332 + pax_close_kernel();
41333
41334 mutex_lock(&pci_hp_mutex);
41335 /*
41336 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41337 index 939bd1d..a1459c9 100644
41338 --- a/drivers/pci/hotplug/pciehp_core.c
41339 +++ b/drivers/pci/hotplug/pciehp_core.c
41340 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41341 struct slot *slot = ctrl->slot;
41342 struct hotplug_slot *hotplug = NULL;
41343 struct hotplug_slot_info *info = NULL;
41344 - struct hotplug_slot_ops *ops = NULL;
41345 + hotplug_slot_ops_no_const *ops = NULL;
41346 char name[SLOT_NAME_SIZE];
41347 int retval = -ENOMEM;
41348
41349 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41350 index 9c6e9bb..2916736 100644
41351 --- a/drivers/pci/pci-sysfs.c
41352 +++ b/drivers/pci/pci-sysfs.c
41353 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41354 {
41355 /* allocate attribute structure, piggyback attribute name */
41356 int name_len = write_combine ? 13 : 10;
41357 - struct bin_attribute *res_attr;
41358 + bin_attribute_no_const *res_attr;
41359 int retval;
41360
41361 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41362 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41363 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41364 {
41365 int retval;
41366 - struct bin_attribute *attr;
41367 + bin_attribute_no_const *attr;
41368
41369 /* If the device has VPD, try to expose it in sysfs. */
41370 if (dev->vpd) {
41371 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41372 {
41373 int retval;
41374 int rom_size = 0;
41375 - struct bin_attribute *attr;
41376 + bin_attribute_no_const *attr;
41377
41378 if (!sysfs_initialized)
41379 return -EACCES;
41380 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41381 index e851829..a1a7196 100644
41382 --- a/drivers/pci/pci.h
41383 +++ b/drivers/pci/pci.h
41384 @@ -98,7 +98,7 @@ struct pci_vpd_ops {
41385 struct pci_vpd {
41386 unsigned int len;
41387 const struct pci_vpd_ops *ops;
41388 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41389 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41390 };
41391
41392 extern int pci_vpd_pci22_init(struct pci_dev *dev);
41393 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41394 index 8474b6a..ee81993 100644
41395 --- a/drivers/pci/pcie/aspm.c
41396 +++ b/drivers/pci/pcie/aspm.c
41397 @@ -27,9 +27,9 @@
41398 #define MODULE_PARAM_PREFIX "pcie_aspm."
41399
41400 /* Note: those are not register definitions */
41401 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41402 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41403 -#define ASPM_STATE_L1 (4) /* L1 state */
41404 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41405 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41406 +#define ASPM_STATE_L1 (4U) /* L1 state */
41407 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41408 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41409
41410 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41411 index 6186f03..1a78714 100644
41412 --- a/drivers/pci/probe.c
41413 +++ b/drivers/pci/probe.c
41414 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41415 struct pci_bus_region region;
41416 bool bar_too_big = false, bar_disabled = false;
41417
41418 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41419 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41420
41421 /* No printks while decoding is disabled! */
41422 if (!dev->mmio_always_on) {
41423 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41424 index 9b8505c..f00870a 100644
41425 --- a/drivers/pci/proc.c
41426 +++ b/drivers/pci/proc.c
41427 @@ -465,7 +465,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41428 static int __init pci_proc_init(void)
41429 {
41430 struct pci_dev *dev = NULL;
41431 +
41432 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41433 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41434 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41435 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41436 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41437 +#endif
41438 +#else
41439 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41440 +#endif
41441 proc_create("devices", 0, proc_bus_pci_dir,
41442 &proc_bus_pci_dev_operations);
41443 proc_initialized = 1;
41444 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41445 index 2111dbb..79e434b 100644
41446 --- a/drivers/platform/x86/msi-laptop.c
41447 +++ b/drivers/platform/x86/msi-laptop.c
41448 @@ -820,12 +820,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41449 int result;
41450
41451 /* allow userland write sysfs file */
41452 - dev_attr_bluetooth.store = store_bluetooth;
41453 - dev_attr_wlan.store = store_wlan;
41454 - dev_attr_threeg.store = store_threeg;
41455 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41456 - dev_attr_wlan.attr.mode |= S_IWUSR;
41457 - dev_attr_threeg.attr.mode |= S_IWUSR;
41458 + pax_open_kernel();
41459 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41460 + *(void **)&dev_attr_wlan.store = store_wlan;
41461 + *(void **)&dev_attr_threeg.store = store_threeg;
41462 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41463 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41464 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41465 + pax_close_kernel();
41466
41467 /* disable hardware control by fn key */
41468 result = ec_read(MSI_STANDARD_EC_SCM_LOAD_ADDRESS, &data);
41469 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41470 index 0fe987f..6f3d5c3 100644
41471 --- a/drivers/platform/x86/sony-laptop.c
41472 +++ b/drivers/platform/x86/sony-laptop.c
41473 @@ -2356,7 +2356,7 @@ static void sony_nc_lid_resume_cleanup(struct platform_device *pd)
41474 }
41475
41476 /* High speed charging function */
41477 -static struct device_attribute *hsc_handle;
41478 +static device_attribute_no_const *hsc_handle;
41479
41480 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41481 struct device_attribute *attr,
41482 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41483 index f946ca7..f25c833 100644
41484 --- a/drivers/platform/x86/thinkpad_acpi.c
41485 +++ b/drivers/platform/x86/thinkpad_acpi.c
41486 @@ -2097,7 +2097,7 @@ static int hotkey_mask_get(void)
41487 return 0;
41488 }
41489
41490 -void static hotkey_mask_warn_incomplete_mask(void)
41491 +static void hotkey_mask_warn_incomplete_mask(void)
41492 {
41493 /* log only what the user can fix... */
41494 const u32 wantedmask = hotkey_driver_mask &
41495 @@ -2328,11 +2328,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41496 }
41497 }
41498
41499 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41500 - struct tp_nvram_state *newn,
41501 - const u32 event_mask)
41502 -{
41503 -
41504 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41505 do { \
41506 if ((event_mask & (1 << __scancode)) && \
41507 @@ -2346,36 +2341,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41508 tpacpi_hotkey_send_key(__scancode); \
41509 } while (0)
41510
41511 - void issue_volchange(const unsigned int oldvol,
41512 - const unsigned int newvol)
41513 - {
41514 - unsigned int i = oldvol;
41515 +static void issue_volchange(const unsigned int oldvol,
41516 + const unsigned int newvol,
41517 + const u32 event_mask)
41518 +{
41519 + unsigned int i = oldvol;
41520
41521 - while (i > newvol) {
41522 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41523 - i--;
41524 - }
41525 - while (i < newvol) {
41526 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41527 - i++;
41528 - }
41529 + while (i > newvol) {
41530 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41531 + i--;
41532 }
41533 + while (i < newvol) {
41534 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41535 + i++;
41536 + }
41537 +}
41538
41539 - void issue_brightnesschange(const unsigned int oldbrt,
41540 - const unsigned int newbrt)
41541 - {
41542 - unsigned int i = oldbrt;
41543 +static void issue_brightnesschange(const unsigned int oldbrt,
41544 + const unsigned int newbrt,
41545 + const u32 event_mask)
41546 +{
41547 + unsigned int i = oldbrt;
41548
41549 - while (i > newbrt) {
41550 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41551 - i--;
41552 - }
41553 - while (i < newbrt) {
41554 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41555 - i++;
41556 - }
41557 + while (i > newbrt) {
41558 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41559 + i--;
41560 + }
41561 + while (i < newbrt) {
41562 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41563 + i++;
41564 }
41565 +}
41566
41567 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41568 + struct tp_nvram_state *newn,
41569 + const u32 event_mask)
41570 +{
41571 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41572 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41573 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41574 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41575 oldn->volume_level != newn->volume_level) {
41576 /* recently muted, or repeated mute keypress, or
41577 * multiple presses ending in mute */
41578 - issue_volchange(oldn->volume_level, newn->volume_level);
41579 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41580 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41581 }
41582 } else {
41583 @@ -2419,7 +2420,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41584 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41585 }
41586 if (oldn->volume_level != newn->volume_level) {
41587 - issue_volchange(oldn->volume_level, newn->volume_level);
41588 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41589 } else if (oldn->volume_toggle != newn->volume_toggle) {
41590 /* repeated vol up/down keypress at end of scale ? */
41591 if (newn->volume_level == 0)
41592 @@ -2432,7 +2433,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41593 /* handle brightness */
41594 if (oldn->brightness_level != newn->brightness_level) {
41595 issue_brightnesschange(oldn->brightness_level,
41596 - newn->brightness_level);
41597 + newn->brightness_level,
41598 + event_mask);
41599 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41600 /* repeated key presses that didn't change state */
41601 if (newn->brightness_level == 0)
41602 @@ -2441,10 +2443,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41603 && !tp_features.bright_unkfw)
41604 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41605 }
41606 +}
41607
41608 #undef TPACPI_COMPARE_KEY
41609 #undef TPACPI_MAY_SEND_KEY
41610 -}
41611
41612 /*
41613 * Polling driver
41614 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41615 index 769d265..a3a05ca 100644
41616 --- a/drivers/pnp/pnpbios/bioscalls.c
41617 +++ b/drivers/pnp/pnpbios/bioscalls.c
41618 @@ -58,7 +58,7 @@ do { \
41619 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41620 } while(0)
41621
41622 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41623 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41624 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41625
41626 /*
41627 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41628
41629 cpu = get_cpu();
41630 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41631 +
41632 + pax_open_kernel();
41633 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41634 + pax_close_kernel();
41635
41636 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41637 spin_lock_irqsave(&pnp_bios_lock, flags);
41638 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41639 :"memory");
41640 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41641
41642 + pax_open_kernel();
41643 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41644 + pax_close_kernel();
41645 +
41646 put_cpu();
41647
41648 /* If we get here and this is set then the PnP BIOS faulted on us. */
41649 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41650 return status;
41651 }
41652
41653 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41654 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41655 {
41656 int i;
41657
41658 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41659 pnp_bios_callpoint.offset = header->fields.pm16offset;
41660 pnp_bios_callpoint.segment = PNP_CS16;
41661
41662 + pax_open_kernel();
41663 +
41664 for_each_possible_cpu(i) {
41665 struct desc_struct *gdt = get_cpu_gdt_table(i);
41666 if (!gdt)
41667 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41668 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41669 (unsigned long)__va(header->fields.pm16dseg));
41670 }
41671 +
41672 + pax_close_kernel();
41673 }
41674 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41675 index 3e6db1c..1fbbdae 100644
41676 --- a/drivers/pnp/resource.c
41677 +++ b/drivers/pnp/resource.c
41678 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41679 return 1;
41680
41681 /* check if the resource is valid */
41682 - if (*irq < 0 || *irq > 15)
41683 + if (*irq > 15)
41684 return 0;
41685
41686 /* check if the resource is reserved */
41687 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41688 return 1;
41689
41690 /* check if the resource is valid */
41691 - if (*dma < 0 || *dma == 4 || *dma > 7)
41692 + if (*dma == 4 || *dma > 7)
41693 return 0;
41694
41695 /* check if the resource is reserved */
41696 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41697 index 7df7c5f..bd48c47 100644
41698 --- a/drivers/power/pda_power.c
41699 +++ b/drivers/power/pda_power.c
41700 @@ -37,7 +37,11 @@ static int polling;
41701
41702 #ifdef CONFIG_USB_OTG_UTILS
41703 static struct usb_phy *transceiver;
41704 -static struct notifier_block otg_nb;
41705 +static int otg_handle_notification(struct notifier_block *nb,
41706 + unsigned long event, void *unused);
41707 +static struct notifier_block otg_nb = {
41708 + .notifier_call = otg_handle_notification
41709 +};
41710 #endif
41711
41712 static struct regulator *ac_draw;
41713 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41714
41715 #ifdef CONFIG_USB_OTG_UTILS
41716 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41717 - otg_nb.notifier_call = otg_handle_notification;
41718 ret = usb_register_notifier(transceiver, &otg_nb);
41719 if (ret) {
41720 dev_err(dev, "failure to register otg notifier\n");
41721 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41722 index cc439fd..8fa30df 100644
41723 --- a/drivers/power/power_supply.h
41724 +++ b/drivers/power/power_supply.h
41725 @@ -16,12 +16,12 @@ struct power_supply;
41726
41727 #ifdef CONFIG_SYSFS
41728
41729 -extern void power_supply_init_attrs(struct device_type *dev_type);
41730 +extern void power_supply_init_attrs(void);
41731 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41732
41733 #else
41734
41735 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41736 +static inline void power_supply_init_attrs(void) {}
41737 #define power_supply_uevent NULL
41738
41739 #endif /* CONFIG_SYSFS */
41740 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41741 index 8a7cfb3..72e6e9b 100644
41742 --- a/drivers/power/power_supply_core.c
41743 +++ b/drivers/power/power_supply_core.c
41744 @@ -24,7 +24,10 @@
41745 struct class *power_supply_class;
41746 EXPORT_SYMBOL_GPL(power_supply_class);
41747
41748 -static struct device_type power_supply_dev_type;
41749 +extern const struct attribute_group *power_supply_attr_groups[];
41750 +static struct device_type power_supply_dev_type = {
41751 + .groups = power_supply_attr_groups,
41752 +};
41753
41754 static int __power_supply_changed_work(struct device *dev, void *data)
41755 {
41756 @@ -393,7 +396,7 @@ static int __init power_supply_class_init(void)
41757 return PTR_ERR(power_supply_class);
41758
41759 power_supply_class->dev_uevent = power_supply_uevent;
41760 - power_supply_init_attrs(&power_supply_dev_type);
41761 + power_supply_init_attrs();
41762
41763 return 0;
41764 }
41765 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41766 index 40fa3b7..d9c2e0e 100644
41767 --- a/drivers/power/power_supply_sysfs.c
41768 +++ b/drivers/power/power_supply_sysfs.c
41769 @@ -229,17 +229,15 @@ static struct attribute_group power_supply_attr_group = {
41770 .is_visible = power_supply_attr_is_visible,
41771 };
41772
41773 -static const struct attribute_group *power_supply_attr_groups[] = {
41774 +const struct attribute_group *power_supply_attr_groups[] = {
41775 &power_supply_attr_group,
41776 NULL,
41777 };
41778
41779 -void power_supply_init_attrs(struct device_type *dev_type)
41780 +void power_supply_init_attrs(void)
41781 {
41782 int i;
41783
41784 - dev_type->groups = power_supply_attr_groups;
41785 -
41786 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41787 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41788 }
41789 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41790 index 4d7c635..9860196 100644
41791 --- a/drivers/regulator/max8660.c
41792 +++ b/drivers/regulator/max8660.c
41793 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41794 max8660->shadow_regs[MAX8660_OVER1] = 5;
41795 } else {
41796 /* Otherwise devices can be toggled via software */
41797 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41798 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41799 + pax_open_kernel();
41800 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41801 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41802 + pax_close_kernel();
41803 }
41804
41805 /*
41806 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41807 index 9a8ea91..c483dd9 100644
41808 --- a/drivers/regulator/max8973-regulator.c
41809 +++ b/drivers/regulator/max8973-regulator.c
41810 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41811 if (!pdata->enable_ext_control) {
41812 max->desc.enable_reg = MAX8973_VOUT;
41813 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41814 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41815 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41816 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41817 + pax_open_kernel();
41818 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41819 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41820 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41821 + pax_close_kernel();
41822 }
41823
41824 max->enable_external_control = pdata->enable_ext_control;
41825 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41826 index 0d84b1f..c2da6ac 100644
41827 --- a/drivers/regulator/mc13892-regulator.c
41828 +++ b/drivers/regulator/mc13892-regulator.c
41829 @@ -540,10 +540,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41830 }
41831 mc13xxx_unlock(mc13892);
41832
41833 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41834 + pax_open_kernel();
41835 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41836 = mc13892_vcam_set_mode;
41837 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41838 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41839 = mc13892_vcam_get_mode;
41840 + pax_close_kernel();
41841
41842 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41843 ARRAY_SIZE(mc13892_regulators));
41844 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41845 index 16630aa..6afc992 100644
41846 --- a/drivers/rtc/rtc-cmos.c
41847 +++ b/drivers/rtc/rtc-cmos.c
41848 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41849 hpet_rtc_timer_init();
41850
41851 /* export at least the first block of NVRAM */
41852 - nvram.size = address_space - NVRAM_OFFSET;
41853 + pax_open_kernel();
41854 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41855 + pax_close_kernel();
41856 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41857 if (retval < 0) {
41858 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41859 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41860 index 9a86b4b..3a383dc 100644
41861 --- a/drivers/rtc/rtc-dev.c
41862 +++ b/drivers/rtc/rtc-dev.c
41863 @@ -14,6 +14,7 @@
41864 #include <linux/module.h>
41865 #include <linux/rtc.h>
41866 #include <linux/sched.h>
41867 +#include <linux/grsecurity.h>
41868 #include "rtc-core.h"
41869
41870 static dev_t rtc_devt;
41871 @@ -345,6 +346,8 @@ static long rtc_dev_ioctl(struct file *file,
41872 if (copy_from_user(&tm, uarg, sizeof(tm)))
41873 return -EFAULT;
41874
41875 + gr_log_timechange();
41876 +
41877 return rtc_set_time(rtc, &tm);
41878
41879 case RTC_PIE_ON:
41880 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41881 index e0d0ba4..3c65868 100644
41882 --- a/drivers/rtc/rtc-ds1307.c
41883 +++ b/drivers/rtc/rtc-ds1307.c
41884 @@ -106,7 +106,7 @@ struct ds1307 {
41885 u8 offset; /* register's offset */
41886 u8 regs[11];
41887 u16 nvram_offset;
41888 - struct bin_attribute *nvram;
41889 + bin_attribute_no_const *nvram;
41890 enum ds_type type;
41891 unsigned long flags;
41892 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41893 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41894 index 130f29a..6179d03 100644
41895 --- a/drivers/rtc/rtc-m48t59.c
41896 +++ b/drivers/rtc/rtc-m48t59.c
41897 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41898 goto out;
41899 }
41900
41901 - m48t59_nvram_attr.size = pdata->offset;
41902 + pax_open_kernel();
41903 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
41904 + pax_close_kernel();
41905
41906 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
41907 if (ret) {
41908 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
41909 index e693af6..2e525b6 100644
41910 --- a/drivers/scsi/bfa/bfa_fcpim.h
41911 +++ b/drivers/scsi/bfa/bfa_fcpim.h
41912 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
41913
41914 struct bfa_itn_s {
41915 bfa_isr_func_t isr;
41916 -};
41917 +} __no_const;
41918
41919 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
41920 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
41921 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
41922 index 23a90e7..9cf04ee 100644
41923 --- a/drivers/scsi/bfa/bfa_ioc.h
41924 +++ b/drivers/scsi/bfa/bfa_ioc.h
41925 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
41926 bfa_ioc_disable_cbfn_t disable_cbfn;
41927 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
41928 bfa_ioc_reset_cbfn_t reset_cbfn;
41929 -};
41930 +} __no_const;
41931
41932 /*
41933 * IOC event notification mechanism.
41934 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
41935 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
41936 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
41937 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
41938 -};
41939 +} __no_const;
41940
41941 /*
41942 * Queue element to wait for room in request queue. FIFO order is
41943 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
41944 index 593085a..47aa999 100644
41945 --- a/drivers/scsi/hosts.c
41946 +++ b/drivers/scsi/hosts.c
41947 @@ -42,7 +42,7 @@
41948 #include "scsi_logging.h"
41949
41950
41951 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41952 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
41953
41954
41955 static void scsi_host_cls_release(struct device *dev)
41956 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
41957 * subtract one because we increment first then return, but we need to
41958 * know what the next host number was before increment
41959 */
41960 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
41961 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
41962 shost->dma_channel = 0xff;
41963
41964 /* These three are default values which can be overridden */
41965 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
41966 index 4f33806..afd6f60 100644
41967 --- a/drivers/scsi/hpsa.c
41968 +++ b/drivers/scsi/hpsa.c
41969 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
41970 unsigned long flags;
41971
41972 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
41973 - return h->access.command_completed(h, q);
41974 + return h->access->command_completed(h, q);
41975
41976 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
41977 a = rq->head[rq->current_entry];
41978 @@ -3374,7 +3374,7 @@ static void start_io(struct ctlr_info *h)
41979 while (!list_empty(&h->reqQ)) {
41980 c = list_entry(h->reqQ.next, struct CommandList, list);
41981 /* can't do anything if fifo is full */
41982 - if ((h->access.fifo_full(h))) {
41983 + if ((h->access->fifo_full(h))) {
41984 dev_warn(&h->pdev->dev, "fifo full\n");
41985 break;
41986 }
41987 @@ -3396,7 +3396,7 @@ static void start_io(struct ctlr_info *h)
41988
41989 /* Tell the controller execute command */
41990 spin_unlock_irqrestore(&h->lock, flags);
41991 - h->access.submit_command(h, c);
41992 + h->access->submit_command(h, c);
41993 spin_lock_irqsave(&h->lock, flags);
41994 }
41995 spin_unlock_irqrestore(&h->lock, flags);
41996 @@ -3404,17 +3404,17 @@ static void start_io(struct ctlr_info *h)
41997
41998 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
41999 {
42000 - return h->access.command_completed(h, q);
42001 + return h->access->command_completed(h, q);
42002 }
42003
42004 static inline bool interrupt_pending(struct ctlr_info *h)
42005 {
42006 - return h->access.intr_pending(h);
42007 + return h->access->intr_pending(h);
42008 }
42009
42010 static inline long interrupt_not_for_us(struct ctlr_info *h)
42011 {
42012 - return (h->access.intr_pending(h) == 0) ||
42013 + return (h->access->intr_pending(h) == 0) ||
42014 (h->interrupts_enabled == 0);
42015 }
42016
42017 @@ -4316,7 +4316,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42018 if (prod_index < 0)
42019 return -ENODEV;
42020 h->product_name = products[prod_index].product_name;
42021 - h->access = *(products[prod_index].access);
42022 + h->access = products[prod_index].access;
42023
42024 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42025 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42026 @@ -4598,7 +4598,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42027
42028 assert_spin_locked(&lockup_detector_lock);
42029 remove_ctlr_from_lockup_detector_list(h);
42030 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42031 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42032 spin_lock_irqsave(&h->lock, flags);
42033 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42034 spin_unlock_irqrestore(&h->lock, flags);
42035 @@ -4775,7 +4775,7 @@ reinit_after_soft_reset:
42036 }
42037
42038 /* make sure the board interrupts are off */
42039 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42040 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42041
42042 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42043 goto clean2;
42044 @@ -4809,7 +4809,7 @@ reinit_after_soft_reset:
42045 * fake ones to scoop up any residual completions.
42046 */
42047 spin_lock_irqsave(&h->lock, flags);
42048 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42049 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42050 spin_unlock_irqrestore(&h->lock, flags);
42051 free_irqs(h);
42052 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42053 @@ -4828,9 +4828,9 @@ reinit_after_soft_reset:
42054 dev_info(&h->pdev->dev, "Board READY.\n");
42055 dev_info(&h->pdev->dev,
42056 "Waiting for stale completions to drain.\n");
42057 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42058 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42059 msleep(10000);
42060 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42061 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42062
42063 rc = controller_reset_failed(h->cfgtable);
42064 if (rc)
42065 @@ -4851,7 +4851,7 @@ reinit_after_soft_reset:
42066 }
42067
42068 /* Turn the interrupts on so we can service requests */
42069 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42070 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42071
42072 hpsa_hba_inquiry(h);
42073 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42074 @@ -4903,7 +4903,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42075 * To write all data in the battery backed cache to disks
42076 */
42077 hpsa_flush_cache(h);
42078 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42079 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42080 hpsa_free_irqs_and_disable_msix(h);
42081 }
42082
42083 @@ -5071,7 +5071,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42084 return;
42085 }
42086 /* Change the access methods to the performant access methods */
42087 - h->access = SA5_performant_access;
42088 + h->access = &SA5_performant_access;
42089 h->transMethod = CFGTBL_Trans_Performant;
42090 }
42091
42092 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42093 index 9816479..c5d4e97 100644
42094 --- a/drivers/scsi/hpsa.h
42095 +++ b/drivers/scsi/hpsa.h
42096 @@ -79,7 +79,7 @@ struct ctlr_info {
42097 unsigned int msix_vector;
42098 unsigned int msi_vector;
42099 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42100 - struct access_method access;
42101 + struct access_method *access;
42102
42103 /* queue and queue Info */
42104 struct list_head reqQ;
42105 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42106 index c772d8d..35c362c 100644
42107 --- a/drivers/scsi/libfc/fc_exch.c
42108 +++ b/drivers/scsi/libfc/fc_exch.c
42109 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42110 u16 pool_max_index;
42111
42112 struct {
42113 - atomic_t no_free_exch;
42114 - atomic_t no_free_exch_xid;
42115 - atomic_t xid_not_found;
42116 - atomic_t xid_busy;
42117 - atomic_t seq_not_found;
42118 - atomic_t non_bls_resp;
42119 + atomic_unchecked_t no_free_exch;
42120 + atomic_unchecked_t no_free_exch_xid;
42121 + atomic_unchecked_t xid_not_found;
42122 + atomic_unchecked_t xid_busy;
42123 + atomic_unchecked_t seq_not_found;
42124 + atomic_unchecked_t non_bls_resp;
42125 } stats;
42126 };
42127
42128 @@ -725,7 +725,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42129 /* allocate memory for exchange */
42130 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42131 if (!ep) {
42132 - atomic_inc(&mp->stats.no_free_exch);
42133 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42134 goto out;
42135 }
42136 memset(ep, 0, sizeof(*ep));
42137 @@ -786,7 +786,7 @@ out:
42138 return ep;
42139 err:
42140 spin_unlock_bh(&pool->lock);
42141 - atomic_inc(&mp->stats.no_free_exch_xid);
42142 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42143 mempool_free(ep, mp->ep_pool);
42144 return NULL;
42145 }
42146 @@ -929,7 +929,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42147 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42148 ep = fc_exch_find(mp, xid);
42149 if (!ep) {
42150 - atomic_inc(&mp->stats.xid_not_found);
42151 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42152 reject = FC_RJT_OX_ID;
42153 goto out;
42154 }
42155 @@ -959,7 +959,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42156 ep = fc_exch_find(mp, xid);
42157 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42158 if (ep) {
42159 - atomic_inc(&mp->stats.xid_busy);
42160 + atomic_inc_unchecked(&mp->stats.xid_busy);
42161 reject = FC_RJT_RX_ID;
42162 goto rel;
42163 }
42164 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42165 }
42166 xid = ep->xid; /* get our XID */
42167 } else if (!ep) {
42168 - atomic_inc(&mp->stats.xid_not_found);
42169 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42170 reject = FC_RJT_RX_ID; /* XID not found */
42171 goto out;
42172 }
42173 @@ -987,7 +987,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42174 } else {
42175 sp = &ep->seq;
42176 if (sp->id != fh->fh_seq_id) {
42177 - atomic_inc(&mp->stats.seq_not_found);
42178 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42179 if (f_ctl & FC_FC_END_SEQ) {
42180 /*
42181 * Update sequence_id based on incoming last
42182 @@ -1437,22 +1437,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42183
42184 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42185 if (!ep) {
42186 - atomic_inc(&mp->stats.xid_not_found);
42187 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42188 goto out;
42189 }
42190 if (ep->esb_stat & ESB_ST_COMPLETE) {
42191 - atomic_inc(&mp->stats.xid_not_found);
42192 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42193 goto rel;
42194 }
42195 if (ep->rxid == FC_XID_UNKNOWN)
42196 ep->rxid = ntohs(fh->fh_rx_id);
42197 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42198 - atomic_inc(&mp->stats.xid_not_found);
42199 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42200 goto rel;
42201 }
42202 if (ep->did != ntoh24(fh->fh_s_id) &&
42203 ep->did != FC_FID_FLOGI) {
42204 - atomic_inc(&mp->stats.xid_not_found);
42205 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42206 goto rel;
42207 }
42208 sof = fr_sof(fp);
42209 @@ -1461,7 +1461,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42210 sp->ssb_stat |= SSB_ST_RESP;
42211 sp->id = fh->fh_seq_id;
42212 } else if (sp->id != fh->fh_seq_id) {
42213 - atomic_inc(&mp->stats.seq_not_found);
42214 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42215 goto rel;
42216 }
42217
42218 @@ -1525,9 +1525,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42219 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42220
42221 if (!sp)
42222 - atomic_inc(&mp->stats.xid_not_found);
42223 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42224 else
42225 - atomic_inc(&mp->stats.non_bls_resp);
42226 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42227
42228 fc_frame_free(fp);
42229 }
42230 @@ -2174,13 +2174,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42231
42232 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42233 mp = ema->mp;
42234 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42235 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42236 st->fc_no_free_exch_xid +=
42237 - atomic_read(&mp->stats.no_free_exch_xid);
42238 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42239 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42240 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42241 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42242 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42243 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42244 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42245 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42246 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42247 }
42248 }
42249 EXPORT_SYMBOL(fc_exch_update_stats);
42250 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42251 index bdb81cd..d3c7c2c 100644
42252 --- a/drivers/scsi/libsas/sas_ata.c
42253 +++ b/drivers/scsi/libsas/sas_ata.c
42254 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42255 .postreset = ata_std_postreset,
42256 .error_handler = ata_std_error_handler,
42257 .post_internal_cmd = sas_ata_post_internal,
42258 - .qc_defer = ata_std_qc_defer,
42259 + .qc_defer = ata_std_qc_defer,
42260 .qc_prep = ata_noop_qc_prep,
42261 .qc_issue = sas_ata_qc_issue,
42262 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42263 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42264 index df4c13a..a51e90c 100644
42265 --- a/drivers/scsi/lpfc/lpfc.h
42266 +++ b/drivers/scsi/lpfc/lpfc.h
42267 @@ -424,7 +424,7 @@ struct lpfc_vport {
42268 struct dentry *debug_nodelist;
42269 struct dentry *vport_debugfs_root;
42270 struct lpfc_debugfs_trc *disc_trc;
42271 - atomic_t disc_trc_cnt;
42272 + atomic_unchecked_t disc_trc_cnt;
42273 #endif
42274 uint8_t stat_data_enabled;
42275 uint8_t stat_data_blocked;
42276 @@ -842,8 +842,8 @@ struct lpfc_hba {
42277 struct timer_list fabric_block_timer;
42278 unsigned long bit_flags;
42279 #define FABRIC_COMANDS_BLOCKED 0
42280 - atomic_t num_rsrc_err;
42281 - atomic_t num_cmd_success;
42282 + atomic_unchecked_t num_rsrc_err;
42283 + atomic_unchecked_t num_cmd_success;
42284 unsigned long last_rsrc_error_time;
42285 unsigned long last_ramp_down_time;
42286 unsigned long last_ramp_up_time;
42287 @@ -879,7 +879,7 @@ struct lpfc_hba {
42288
42289 struct dentry *debug_slow_ring_trc;
42290 struct lpfc_debugfs_trc *slow_ring_trc;
42291 - atomic_t slow_ring_trc_cnt;
42292 + atomic_unchecked_t slow_ring_trc_cnt;
42293 /* iDiag debugfs sub-directory */
42294 struct dentry *idiag_root;
42295 struct dentry *idiag_pci_cfg;
42296 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42297 index f63f5ff..de29189 100644
42298 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42299 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42300 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42301
42302 #include <linux/debugfs.h>
42303
42304 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42305 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42306 static unsigned long lpfc_debugfs_start_time = 0L;
42307
42308 /* iDiag */
42309 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42310 lpfc_debugfs_enable = 0;
42311
42312 len = 0;
42313 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42314 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42315 (lpfc_debugfs_max_disc_trc - 1);
42316 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42317 dtp = vport->disc_trc + i;
42318 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42319 lpfc_debugfs_enable = 0;
42320
42321 len = 0;
42322 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42323 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42324 (lpfc_debugfs_max_slow_ring_trc - 1);
42325 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42326 dtp = phba->slow_ring_trc + i;
42327 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42328 !vport || !vport->disc_trc)
42329 return;
42330
42331 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42332 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42333 (lpfc_debugfs_max_disc_trc - 1);
42334 dtp = vport->disc_trc + index;
42335 dtp->fmt = fmt;
42336 dtp->data1 = data1;
42337 dtp->data2 = data2;
42338 dtp->data3 = data3;
42339 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42340 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42341 dtp->jif = jiffies;
42342 #endif
42343 return;
42344 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42345 !phba || !phba->slow_ring_trc)
42346 return;
42347
42348 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42349 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42350 (lpfc_debugfs_max_slow_ring_trc - 1);
42351 dtp = phba->slow_ring_trc + index;
42352 dtp->fmt = fmt;
42353 dtp->data1 = data1;
42354 dtp->data2 = data2;
42355 dtp->data3 = data3;
42356 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42357 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42358 dtp->jif = jiffies;
42359 #endif
42360 return;
42361 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42362 "slow_ring buffer\n");
42363 goto debug_failed;
42364 }
42365 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42366 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42367 memset(phba->slow_ring_trc, 0,
42368 (sizeof(struct lpfc_debugfs_trc) *
42369 lpfc_debugfs_max_slow_ring_trc));
42370 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42371 "buffer\n");
42372 goto debug_failed;
42373 }
42374 - atomic_set(&vport->disc_trc_cnt, 0);
42375 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42376
42377 snprintf(name, sizeof(name), "discovery_trace");
42378 vport->debug_disc_trc =
42379 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42380 index 89ad558..76956c4 100644
42381 --- a/drivers/scsi/lpfc/lpfc_init.c
42382 +++ b/drivers/scsi/lpfc/lpfc_init.c
42383 @@ -10618,8 +10618,10 @@ lpfc_init(void)
42384 "misc_register returned with status %d", error);
42385
42386 if (lpfc_enable_npiv) {
42387 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42388 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42389 + pax_open_kernel();
42390 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42391 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42392 + pax_close_kernel();
42393 }
42394 lpfc_transport_template =
42395 fc_attach_transport(&lpfc_transport_functions);
42396 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42397 index 60e5a17..ff7a793 100644
42398 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42399 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42400 @@ -305,7 +305,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42401 uint32_t evt_posted;
42402
42403 spin_lock_irqsave(&phba->hbalock, flags);
42404 - atomic_inc(&phba->num_rsrc_err);
42405 + atomic_inc_unchecked(&phba->num_rsrc_err);
42406 phba->last_rsrc_error_time = jiffies;
42407
42408 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42409 @@ -346,7 +346,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42410 unsigned long flags;
42411 struct lpfc_hba *phba = vport->phba;
42412 uint32_t evt_posted;
42413 - atomic_inc(&phba->num_cmd_success);
42414 + atomic_inc_unchecked(&phba->num_cmd_success);
42415
42416 if (vport->cfg_lun_queue_depth <= queue_depth)
42417 return;
42418 @@ -390,8 +390,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42419 unsigned long num_rsrc_err, num_cmd_success;
42420 int i;
42421
42422 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42423 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42424 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42425 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42426
42427 /*
42428 * The error and success command counters are global per
42429 @@ -419,8 +419,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42430 }
42431 }
42432 lpfc_destroy_vport_work_array(phba, vports);
42433 - atomic_set(&phba->num_rsrc_err, 0);
42434 - atomic_set(&phba->num_cmd_success, 0);
42435 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42436 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42437 }
42438
42439 /**
42440 @@ -454,8 +454,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42441 }
42442 }
42443 lpfc_destroy_vport_work_array(phba, vports);
42444 - atomic_set(&phba->num_rsrc_err, 0);
42445 - atomic_set(&phba->num_cmd_success, 0);
42446 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42447 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42448 }
42449
42450 /**
42451 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42452 index b46f5e9..c4c4ccb 100644
42453 --- a/drivers/scsi/pmcraid.c
42454 +++ b/drivers/scsi/pmcraid.c
42455 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42456 res->scsi_dev = scsi_dev;
42457 scsi_dev->hostdata = res;
42458 res->change_detected = 0;
42459 - atomic_set(&res->read_failures, 0);
42460 - atomic_set(&res->write_failures, 0);
42461 + atomic_set_unchecked(&res->read_failures, 0);
42462 + atomic_set_unchecked(&res->write_failures, 0);
42463 rc = 0;
42464 }
42465 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42466 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42467
42468 /* If this was a SCSI read/write command keep count of errors */
42469 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42470 - atomic_inc(&res->read_failures);
42471 + atomic_inc_unchecked(&res->read_failures);
42472 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42473 - atomic_inc(&res->write_failures);
42474 + atomic_inc_unchecked(&res->write_failures);
42475
42476 if (!RES_IS_GSCSI(res->cfg_entry) &&
42477 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42478 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42479 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42480 * hrrq_id assigned here in queuecommand
42481 */
42482 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42483 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42484 pinstance->num_hrrq;
42485 cmd->cmd_done = pmcraid_io_done;
42486
42487 @@ -3859,7 +3859,7 @@ static long pmcraid_ioctl_passthrough(
42488 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42489 * hrrq_id assigned here in queuecommand
42490 */
42491 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42492 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42493 pinstance->num_hrrq;
42494
42495 if (request_size) {
42496 @@ -4497,7 +4497,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42497
42498 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42499 /* add resources only after host is added into system */
42500 - if (!atomic_read(&pinstance->expose_resources))
42501 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42502 return;
42503
42504 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42505 @@ -5324,8 +5324,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42506 init_waitqueue_head(&pinstance->reset_wait_q);
42507
42508 atomic_set(&pinstance->outstanding_cmds, 0);
42509 - atomic_set(&pinstance->last_message_id, 0);
42510 - atomic_set(&pinstance->expose_resources, 0);
42511 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42512 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42513
42514 INIT_LIST_HEAD(&pinstance->free_res_q);
42515 INIT_LIST_HEAD(&pinstance->used_res_q);
42516 @@ -6038,7 +6038,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42517 /* Schedule worker thread to handle CCN and take care of adding and
42518 * removing devices to OS
42519 */
42520 - atomic_set(&pinstance->expose_resources, 1);
42521 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42522 schedule_work(&pinstance->worker_q);
42523 return rc;
42524
42525 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42526 index e1d150f..6c6df44 100644
42527 --- a/drivers/scsi/pmcraid.h
42528 +++ b/drivers/scsi/pmcraid.h
42529 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42530 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42531
42532 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42533 - atomic_t last_message_id;
42534 + atomic_unchecked_t last_message_id;
42535
42536 /* configuration table */
42537 struct pmcraid_config_table *cfg_table;
42538 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42539 atomic_t outstanding_cmds;
42540
42541 /* should add/delete resources to mid-layer now ?*/
42542 - atomic_t expose_resources;
42543 + atomic_unchecked_t expose_resources;
42544
42545
42546
42547 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42548 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42549 };
42550 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42551 - atomic_t read_failures; /* count of failed READ commands */
42552 - atomic_t write_failures; /* count of failed WRITE commands */
42553 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42554 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42555
42556 /* To indicate add/delete/modify during CCN */
42557 u8 change_detected;
42558 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42559 index 83d7984..a27d947 100644
42560 --- a/drivers/scsi/qla2xxx/qla_attr.c
42561 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42562 @@ -1969,7 +1969,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42563 return 0;
42564 }
42565
42566 -struct fc_function_template qla2xxx_transport_functions = {
42567 +fc_function_template_no_const qla2xxx_transport_functions = {
42568
42569 .show_host_node_name = 1,
42570 .show_host_port_name = 1,
42571 @@ -2016,7 +2016,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42572 .bsg_timeout = qla24xx_bsg_timeout,
42573 };
42574
42575 -struct fc_function_template qla2xxx_transport_vport_functions = {
42576 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42577
42578 .show_host_node_name = 1,
42579 .show_host_port_name = 1,
42580 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42581 index 2411d1a..4673766 100644
42582 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42583 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42584 @@ -515,8 +515,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42585 struct device_attribute;
42586 extern struct device_attribute *qla2x00_host_attrs[];
42587 struct fc_function_template;
42588 -extern struct fc_function_template qla2xxx_transport_functions;
42589 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42590 +extern fc_function_template_no_const qla2xxx_transport_functions;
42591 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42592 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42593 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42594 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42595 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42596 index 10d23f8..a7d5d4c 100644
42597 --- a/drivers/scsi/qla2xxx/qla_os.c
42598 +++ b/drivers/scsi/qla2xxx/qla_os.c
42599 @@ -1472,8 +1472,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42600 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42601 /* Ok, a 64bit DMA mask is applicable. */
42602 ha->flags.enable_64bit_addressing = 1;
42603 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42604 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42605 + pax_open_kernel();
42606 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42607 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42608 + pax_close_kernel();
42609 return;
42610 }
42611 }
42612 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42613 index 329d553..f20d31d 100644
42614 --- a/drivers/scsi/qla4xxx/ql4_def.h
42615 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42616 @@ -273,7 +273,7 @@ struct ddb_entry {
42617 * (4000 only) */
42618 atomic_t relogin_timer; /* Max Time to wait for
42619 * relogin to complete */
42620 - atomic_t relogin_retry_count; /* Num of times relogin has been
42621 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42622 * retried */
42623 uint32_t default_time2wait; /* Default Min time between
42624 * relogins (+aens) */
42625 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42626 index 4cec123..7c1329f 100644
42627 --- a/drivers/scsi/qla4xxx/ql4_os.c
42628 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42629 @@ -2621,12 +2621,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42630 */
42631 if (!iscsi_is_session_online(cls_sess)) {
42632 /* Reset retry relogin timer */
42633 - atomic_inc(&ddb_entry->relogin_retry_count);
42634 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42635 DEBUG2(ql4_printk(KERN_INFO, ha,
42636 "%s: index[%d] relogin timed out-retrying"
42637 " relogin (%d), retry (%d)\n", __func__,
42638 ddb_entry->fw_ddb_index,
42639 - atomic_read(&ddb_entry->relogin_retry_count),
42640 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42641 ddb_entry->default_time2wait + 4));
42642 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42643 atomic_set(&ddb_entry->retry_relogin_timer,
42644 @@ -4738,7 +4738,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42645
42646 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42647 atomic_set(&ddb_entry->relogin_timer, 0);
42648 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42649 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42650 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42651 ddb_entry->default_relogin_timeout =
42652 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42653 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42654 index 2c0d0ec..4e8681a 100644
42655 --- a/drivers/scsi/scsi.c
42656 +++ b/drivers/scsi/scsi.c
42657 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42658 unsigned long timeout;
42659 int rtn = 0;
42660
42661 - atomic_inc(&cmd->device->iorequest_cnt);
42662 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42663
42664 /* check if the device is still usable */
42665 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42666 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42667 index f1bf5af..f67e943 100644
42668 --- a/drivers/scsi/scsi_lib.c
42669 +++ b/drivers/scsi/scsi_lib.c
42670 @@ -1454,7 +1454,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42671 shost = sdev->host;
42672 scsi_init_cmd_errh(cmd);
42673 cmd->result = DID_NO_CONNECT << 16;
42674 - atomic_inc(&cmd->device->iorequest_cnt);
42675 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42676
42677 /*
42678 * SCSI request completion path will do scsi_device_unbusy(),
42679 @@ -1480,9 +1480,9 @@ static void scsi_softirq_done(struct request *rq)
42680
42681 INIT_LIST_HEAD(&cmd->eh_entry);
42682
42683 - atomic_inc(&cmd->device->iodone_cnt);
42684 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42685 if (cmd->result)
42686 - atomic_inc(&cmd->device->ioerr_cnt);
42687 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42688
42689 disposition = scsi_decide_disposition(cmd);
42690 if (disposition != SUCCESS &&
42691 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42692 index 931a7d9..0c2a754 100644
42693 --- a/drivers/scsi/scsi_sysfs.c
42694 +++ b/drivers/scsi/scsi_sysfs.c
42695 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42696 char *buf) \
42697 { \
42698 struct scsi_device *sdev = to_scsi_device(dev); \
42699 - unsigned long long count = atomic_read(&sdev->field); \
42700 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42701 return snprintf(buf, 20, "0x%llx\n", count); \
42702 } \
42703 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42704 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42705 index 84a1fdf..693b0d6 100644
42706 --- a/drivers/scsi/scsi_tgt_lib.c
42707 +++ b/drivers/scsi/scsi_tgt_lib.c
42708 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42709 int err;
42710
42711 dprintk("%lx %u\n", uaddr, len);
42712 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42713 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42714 if (err) {
42715 /*
42716 * TODO: need to fixup sg_tablesize, max_segment_size,
42717 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42718 index e894ca7..de9d7660 100644
42719 --- a/drivers/scsi/scsi_transport_fc.c
42720 +++ b/drivers/scsi/scsi_transport_fc.c
42721 @@ -498,7 +498,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42722 * Netlink Infrastructure
42723 */
42724
42725 -static atomic_t fc_event_seq;
42726 +static atomic_unchecked_t fc_event_seq;
42727
42728 /**
42729 * fc_get_event_number - Obtain the next sequential FC event number
42730 @@ -511,7 +511,7 @@ static atomic_t fc_event_seq;
42731 u32
42732 fc_get_event_number(void)
42733 {
42734 - return atomic_add_return(1, &fc_event_seq);
42735 + return atomic_add_return_unchecked(1, &fc_event_seq);
42736 }
42737 EXPORT_SYMBOL(fc_get_event_number);
42738
42739 @@ -659,7 +659,7 @@ static __init int fc_transport_init(void)
42740 {
42741 int error;
42742
42743 - atomic_set(&fc_event_seq, 0);
42744 + atomic_set_unchecked(&fc_event_seq, 0);
42745
42746 error = transport_class_register(&fc_host_class);
42747 if (error)
42748 @@ -849,7 +849,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42749 char *cp;
42750
42751 *val = simple_strtoul(buf, &cp, 0);
42752 - if ((*cp && (*cp != '\n')) || (*val < 0))
42753 + if (*cp && (*cp != '\n'))
42754 return -EINVAL;
42755 /*
42756 * Check for overflow; dev_loss_tmo is u32
42757 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42758 index 31969f2..2b348f0 100644
42759 --- a/drivers/scsi/scsi_transport_iscsi.c
42760 +++ b/drivers/scsi/scsi_transport_iscsi.c
42761 @@ -79,7 +79,7 @@ struct iscsi_internal {
42762 struct transport_container session_cont;
42763 };
42764
42765 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42766 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42767 static struct workqueue_struct *iscsi_eh_timer_workq;
42768
42769 static DEFINE_IDA(iscsi_sess_ida);
42770 @@ -1064,7 +1064,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42771 int err;
42772
42773 ihost = shost->shost_data;
42774 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42775 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42776
42777 if (target_id == ISCSI_MAX_TARGET) {
42778 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42779 @@ -2943,7 +2943,7 @@ static __init int iscsi_transport_init(void)
42780 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42781 ISCSI_TRANSPORT_VERSION);
42782
42783 - atomic_set(&iscsi_session_nr, 0);
42784 + atomic_set_unchecked(&iscsi_session_nr, 0);
42785
42786 err = class_register(&iscsi_transport_class);
42787 if (err)
42788 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42789 index f379c7f..e8fc69c 100644
42790 --- a/drivers/scsi/scsi_transport_srp.c
42791 +++ b/drivers/scsi/scsi_transport_srp.c
42792 @@ -33,7 +33,7 @@
42793 #include "scsi_transport_srp_internal.h"
42794
42795 struct srp_host_attrs {
42796 - atomic_t next_port_id;
42797 + atomic_unchecked_t next_port_id;
42798 };
42799 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42800
42801 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42802 struct Scsi_Host *shost = dev_to_shost(dev);
42803 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42804
42805 - atomic_set(&srp_host->next_port_id, 0);
42806 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42807 return 0;
42808 }
42809
42810 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42811 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42812 rport->roles = ids->roles;
42813
42814 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42815 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42816 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42817
42818 transport_setup_device(&rport->dev);
42819 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42820 index 7992635..609faf8 100644
42821 --- a/drivers/scsi/sd.c
42822 +++ b/drivers/scsi/sd.c
42823 @@ -2909,7 +2909,7 @@ static int sd_probe(struct device *dev)
42824 sdkp->disk = gd;
42825 sdkp->index = index;
42826 atomic_set(&sdkp->openers, 0);
42827 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42828 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42829
42830 if (!sdp->request_queue->rq_timeout) {
42831 if (sdp->type != TYPE_MOD)
42832 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42833 index be2c9a6..275525c 100644
42834 --- a/drivers/scsi/sg.c
42835 +++ b/drivers/scsi/sg.c
42836 @@ -1101,7 +1101,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42837 sdp->disk->disk_name,
42838 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42839 NULL,
42840 - (char *)arg);
42841 + (char __user *)arg);
42842 case BLKTRACESTART:
42843 return blk_trace_startstop(sdp->device->request_queue, 1);
42844 case BLKTRACESTOP:
42845 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42846 index 19ee901..6e8c2ef 100644
42847 --- a/drivers/spi/spi.c
42848 +++ b/drivers/spi/spi.c
42849 @@ -1616,7 +1616,7 @@ int spi_bus_unlock(struct spi_master *master)
42850 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42851
42852 /* portable code must never pass more than 32 bytes */
42853 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42854 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42855
42856 static u8 *buf;
42857
42858 diff --git a/drivers/staging/iio/iio_hwmon.c b/drivers/staging/iio/iio_hwmon.c
42859 index c7a5f97..71ecd35 100644
42860 --- a/drivers/staging/iio/iio_hwmon.c
42861 +++ b/drivers/staging/iio/iio_hwmon.c
42862 @@ -72,7 +72,7 @@ static void iio_hwmon_free_attrs(struct iio_hwmon_state *st)
42863 static int iio_hwmon_probe(struct platform_device *pdev)
42864 {
42865 struct iio_hwmon_state *st;
42866 - struct sensor_device_attribute *a;
42867 + sensor_device_attribute_no_const *a;
42868 int ret, i;
42869 int in_i = 1, temp_i = 1, curr_i = 1;
42870 enum iio_chan_type type;
42871 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42872 index 34afc16..ffe44dd 100644
42873 --- a/drivers/staging/octeon/ethernet-rx.c
42874 +++ b/drivers/staging/octeon/ethernet-rx.c
42875 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42876 /* Increment RX stats for virtual ports */
42877 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42878 #ifdef CONFIG_64BIT
42879 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42880 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42881 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42882 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42883 #else
42884 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42885 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42886 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42887 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42888 #endif
42889 }
42890 netif_receive_skb(skb);
42891 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42892 dev->name);
42893 */
42894 #ifdef CONFIG_64BIT
42895 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42896 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42897 #else
42898 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42899 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42900 #endif
42901 dev_kfree_skb_irq(skb);
42902 }
42903 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
42904 index ef32dc1..a159d68 100644
42905 --- a/drivers/staging/octeon/ethernet.c
42906 +++ b/drivers/staging/octeon/ethernet.c
42907 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
42908 * since the RX tasklet also increments it.
42909 */
42910 #ifdef CONFIG_64BIT
42911 - atomic64_add(rx_status.dropped_packets,
42912 - (atomic64_t *)&priv->stats.rx_dropped);
42913 + atomic64_add_unchecked(rx_status.dropped_packets,
42914 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42915 #else
42916 - atomic_add(rx_status.dropped_packets,
42917 - (atomic_t *)&priv->stats.rx_dropped);
42918 + atomic_add_unchecked(rx_status.dropped_packets,
42919 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
42920 #endif
42921 }
42922
42923 diff --git a/drivers/staging/ramster/tmem.c b/drivers/staging/ramster/tmem.c
42924 index a2b7e03..aaf3630 100644
42925 --- a/drivers/staging/ramster/tmem.c
42926 +++ b/drivers/staging/ramster/tmem.c
42927 @@ -50,25 +50,25 @@
42928 * A tmem host implementation must use this function to register callbacks
42929 * for memory allocation.
42930 */
42931 -static struct tmem_hostops tmem_hostops;
42932 +static struct tmem_hostops *tmem_hostops;
42933
42934 static void tmem_objnode_tree_init(void);
42935
42936 void tmem_register_hostops(struct tmem_hostops *m)
42937 {
42938 tmem_objnode_tree_init();
42939 - tmem_hostops = *m;
42940 + tmem_hostops = m;
42941 }
42942
42943 /*
42944 * A tmem host implementation must use this function to register
42945 * callbacks for a page-accessible memory (PAM) implementation.
42946 */
42947 -static struct tmem_pamops tmem_pamops;
42948 +static struct tmem_pamops *tmem_pamops;
42949
42950 void tmem_register_pamops(struct tmem_pamops *m)
42951 {
42952 - tmem_pamops = *m;
42953 + tmem_pamops = m;
42954 }
42955
42956 /*
42957 @@ -174,7 +174,7 @@ static void tmem_obj_init(struct tmem_obj *obj, struct tmem_hashbucket *hb,
42958 obj->pampd_count = 0;
42959 #ifdef CONFIG_RAMSTER
42960 if (tmem_pamops.new_obj != NULL)
42961 - (*tmem_pamops.new_obj)(obj);
42962 + (tmem_pamops->new_obj)(obj);
42963 #endif
42964 SET_SENTINEL(obj, OBJ);
42965
42966 @@ -210,7 +210,7 @@ static void tmem_pool_flush(struct tmem_pool *pool, bool destroy)
42967 rbnode = rb_next(rbnode);
42968 tmem_pampd_destroy_all_in_obj(obj, true);
42969 tmem_obj_free(obj, hb);
42970 - (*tmem_hostops.obj_free)(obj, pool);
42971 + (tmem_hostops->obj_free)(obj, pool);
42972 }
42973 spin_unlock(&hb->lock);
42974 }
42975 @@ -261,7 +261,7 @@ static struct tmem_objnode *tmem_objnode_alloc(struct tmem_obj *obj)
42976 ASSERT_SENTINEL(obj, OBJ);
42977 BUG_ON(obj->pool == NULL);
42978 ASSERT_SENTINEL(obj->pool, POOL);
42979 - objnode = (*tmem_hostops.objnode_alloc)(obj->pool);
42980 + objnode = (tmem_hostops->objnode_alloc)(obj->pool);
42981 if (unlikely(objnode == NULL))
42982 goto out;
42983 objnode->obj = obj;
42984 @@ -290,7 +290,7 @@ static void tmem_objnode_free(struct tmem_objnode *objnode)
42985 ASSERT_SENTINEL(pool, POOL);
42986 objnode->obj->objnode_count--;
42987 objnode->obj = NULL;
42988 - (*tmem_hostops.objnode_free)(objnode, pool);
42989 + (tmem_hostops->objnode_free)(objnode, pool);
42990 }
42991
42992 /*
42993 @@ -348,7 +348,7 @@ static void *tmem_pampd_replace_in_obj(struct tmem_obj *obj, uint32_t index,
42994 void *old_pampd = *(void **)slot;
42995 *(void **)slot = new_pampd;
42996 if (!no_free)
42997 - (*tmem_pamops.free)(old_pampd, obj->pool,
42998 + (tmem_pamops->free)(old_pampd, obj->pool,
42999 NULL, 0, false);
43000 ret = new_pampd;
43001 }
43002 @@ -505,7 +505,7 @@ static void tmem_objnode_node_destroy(struct tmem_obj *obj,
43003 if (objnode->slots[i]) {
43004 if (ht == 1) {
43005 obj->pampd_count--;
43006 - (*tmem_pamops.free)(objnode->slots[i],
43007 + (tmem_pamops->free)(objnode->slots[i],
43008 obj->pool, NULL, 0, true);
43009 objnode->slots[i] = NULL;
43010 continue;
43011 @@ -524,7 +524,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43012 return;
43013 if (obj->objnode_tree_height == 0) {
43014 obj->pampd_count--;
43015 - (*tmem_pamops.free)(obj->objnode_tree_root,
43016 + (tmem_pamops->free)(obj->objnode_tree_root,
43017 obj->pool, NULL, 0, true);
43018 } else {
43019 tmem_objnode_node_destroy(obj, obj->objnode_tree_root,
43020 @@ -535,7 +535,7 @@ static void tmem_pampd_destroy_all_in_obj(struct tmem_obj *obj,
43021 obj->objnode_tree_root = NULL;
43022 #ifdef CONFIG_RAMSTER
43023 if (tmem_pamops.free_obj != NULL)
43024 - (*tmem_pamops.free_obj)(obj->pool, obj, pool_destroy);
43025 + (tmem_pamops->free_obj)(obj->pool, obj, pool_destroy);
43026 #endif
43027 }
43028
43029 @@ -574,7 +574,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43030 /* if found, is a dup put, flush the old one */
43031 pampd_del = tmem_pampd_delete_from_obj(obj, index);
43032 BUG_ON(pampd_del != pampd);
43033 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43034 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43035 if (obj->pampd_count == 0) {
43036 objnew = obj;
43037 objfound = NULL;
43038 @@ -582,7 +582,7 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43039 pampd = NULL;
43040 }
43041 } else {
43042 - obj = objnew = (*tmem_hostops.obj_alloc)(pool);
43043 + obj = objnew = (tmem_hostops->obj_alloc)(pool);
43044 if (unlikely(obj == NULL)) {
43045 ret = -ENOMEM;
43046 goto out;
43047 @@ -597,16 +597,16 @@ int tmem_put(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43048 if (unlikely(ret == -ENOMEM))
43049 /* may have partially built objnode tree ("stump") */
43050 goto delete_and_free;
43051 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(pool));
43052 + (tmem_pamops->create_finish)(pampd, is_ephemeral(pool));
43053 goto out;
43054
43055 delete_and_free:
43056 (void)tmem_pampd_delete_from_obj(obj, index);
43057 if (pampd)
43058 - (*tmem_pamops.free)(pampd, pool, NULL, 0, true);
43059 + (tmem_pamops->free)(pampd, pool, NULL, 0, true);
43060 if (objnew) {
43061 tmem_obj_free(objnew, hb);
43062 - (*tmem_hostops.obj_free)(objnew, pool);
43063 + (tmem_hostops->obj_free)(objnew, pool);
43064 }
43065 out:
43066 spin_unlock(&hb->lock);
43067 @@ -651,7 +651,7 @@ void tmem_localify_finish(struct tmem_obj *obj, uint32_t index,
43068 if (pampd != NULL) {
43069 BUG_ON(obj == NULL);
43070 (void)tmem_pampd_replace_in_obj(obj, index, pampd, 1);
43071 - (*tmem_pamops.create_finish)(pampd, is_ephemeral(obj->pool));
43072 + (tmem_pamops->create_finish)(pampd, is_ephemeral(obj->pool));
43073 } else if (delete) {
43074 BUG_ON(obj == NULL);
43075 (void)tmem_pampd_delete_from_obj(obj, index);
43076 @@ -671,7 +671,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43077 int ret = 0;
43078
43079 if (!is_ephemeral(pool))
43080 - new_pampd = (*tmem_pamops.repatriate_preload)(
43081 + new_pampd = (tmem_pamops->repatriate_preload)(
43082 old_pampd, pool, oidp, index, &intransit);
43083 if (intransit)
43084 ret = -EAGAIN;
43085 @@ -680,7 +680,7 @@ static int tmem_repatriate(void **ppampd, struct tmem_hashbucket *hb,
43086 /* must release the hb->lock else repatriate can't sleep */
43087 spin_unlock(&hb->lock);
43088 if (!intransit)
43089 - ret = (*tmem_pamops.repatriate)(old_pampd, new_pampd, pool,
43090 + ret = (tmem_pamops->repatriate)(old_pampd, new_pampd, pool,
43091 oidp, index, free, data);
43092 if (ret == -EAGAIN) {
43093 /* rare I think, but should cond_resched()??? */
43094 @@ -714,7 +714,7 @@ int tmem_replace(struct tmem_pool *pool, struct tmem_oid *oidp,
43095 new_pampd = tmem_pampd_replace_in_obj(obj, index, new_pampd, 0);
43096 /* if we bug here, pamops wasn't properly set up for ramster */
43097 BUG_ON(tmem_pamops.replace_in_obj == NULL);
43098 - ret = (*tmem_pamops.replace_in_obj)(new_pampd, obj);
43099 + ret = (tmem_pamops->replace_in_obj)(new_pampd, obj);
43100 out:
43101 spin_unlock(&hb->lock);
43102 return ret;
43103 @@ -776,15 +776,15 @@ int tmem_get(struct tmem_pool *pool, struct tmem_oid *oidp, uint32_t index,
43104 if (free) {
43105 if (obj->pampd_count == 0) {
43106 tmem_obj_free(obj, hb);
43107 - (*tmem_hostops.obj_free)(obj, pool);
43108 + (tmem_hostops->obj_free)(obj, pool);
43109 obj = NULL;
43110 }
43111 }
43112 if (free)
43113 - ret = (*tmem_pamops.get_data_and_free)(
43114 + ret = (tmem_pamops->get_data_and_free)(
43115 data, sizep, raw, pampd, pool, oidp, index);
43116 else
43117 - ret = (*tmem_pamops.get_data)(
43118 + ret = (tmem_pamops->get_data)(
43119 data, sizep, raw, pampd, pool, oidp, index);
43120 if (ret < 0)
43121 goto out;
43122 @@ -816,10 +816,10 @@ int tmem_flush_page(struct tmem_pool *pool,
43123 pampd = tmem_pampd_delete_from_obj(obj, index);
43124 if (pampd == NULL)
43125 goto out;
43126 - (*tmem_pamops.free)(pampd, pool, oidp, index, true);
43127 + (tmem_pamops->free)(pampd, pool, oidp, index, true);
43128 if (obj->pampd_count == 0) {
43129 tmem_obj_free(obj, hb);
43130 - (*tmem_hostops.obj_free)(obj, pool);
43131 + (tmem_hostops->obj_free)(obj, pool);
43132 }
43133 ret = 0;
43134
43135 @@ -844,7 +844,7 @@ int tmem_flush_object(struct tmem_pool *pool, struct tmem_oid *oidp)
43136 goto out;
43137 tmem_pampd_destroy_all_in_obj(obj, false);
43138 tmem_obj_free(obj, hb);
43139 - (*tmem_hostops.obj_free)(obj, pool);
43140 + (tmem_hostops->obj_free)(obj, pool);
43141 ret = 0;
43142
43143 out:
43144 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43145 index dc23395..cf7e9b1 100644
43146 --- a/drivers/staging/rtl8712/rtl871x_io.h
43147 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43148 @@ -108,7 +108,7 @@ struct _io_ops {
43149 u8 *pmem);
43150 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43151 u8 *pmem);
43152 -};
43153 +} __no_const;
43154
43155 struct io_req {
43156 struct list_head list;
43157 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43158 index 1f5088b..0e59820 100644
43159 --- a/drivers/staging/sbe-2t3e3/netdev.c
43160 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43161 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43162 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43163
43164 if (rlen)
43165 - if (copy_to_user(data, &resp, rlen))
43166 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43167 return -EFAULT;
43168
43169 return 0;
43170 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43171 index 5dddc4d..34fcb2f 100644
43172 --- a/drivers/staging/usbip/vhci.h
43173 +++ b/drivers/staging/usbip/vhci.h
43174 @@ -83,7 +83,7 @@ struct vhci_hcd {
43175 unsigned resuming:1;
43176 unsigned long re_timeout;
43177
43178 - atomic_t seqnum;
43179 + atomic_unchecked_t seqnum;
43180
43181 /*
43182 * NOTE:
43183 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43184 index c3aa219..bf8b3de 100644
43185 --- a/drivers/staging/usbip/vhci_hcd.c
43186 +++ b/drivers/staging/usbip/vhci_hcd.c
43187 @@ -451,7 +451,7 @@ static void vhci_tx_urb(struct urb *urb)
43188 return;
43189 }
43190
43191 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43192 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43193 if (priv->seqnum == 0xffff)
43194 dev_info(&urb->dev->dev, "seqnum max\n");
43195
43196 @@ -703,7 +703,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43197 return -ENOMEM;
43198 }
43199
43200 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43201 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43202 if (unlink->seqnum == 0xffff)
43203 pr_info("seqnum max\n");
43204
43205 @@ -907,7 +907,7 @@ static int vhci_start(struct usb_hcd *hcd)
43206 vdev->rhport = rhport;
43207 }
43208
43209 - atomic_set(&vhci->seqnum, 0);
43210 + atomic_set_unchecked(&vhci->seqnum, 0);
43211 spin_lock_init(&vhci->lock);
43212
43213 hcd->power_budget = 0; /* no limit */
43214 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43215 index ba5f1c0..11d8122 100644
43216 --- a/drivers/staging/usbip/vhci_rx.c
43217 +++ b/drivers/staging/usbip/vhci_rx.c
43218 @@ -77,7 +77,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43219 if (!urb) {
43220 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43221 pr_info("max seqnum %d\n",
43222 - atomic_read(&the_controller->seqnum));
43223 + atomic_read_unchecked(&the_controller->seqnum));
43224 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43225 return;
43226 }
43227 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43228 index 5f13890..36a044b 100644
43229 --- a/drivers/staging/vt6655/hostap.c
43230 +++ b/drivers/staging/vt6655/hostap.c
43231 @@ -73,14 +73,13 @@ static int msglevel =MSG_LEVEL_INFO;
43232 *
43233 */
43234
43235 +static net_device_ops_no_const apdev_netdev_ops;
43236 +
43237 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43238 {
43239 PSDevice apdev_priv;
43240 struct net_device *dev = pDevice->dev;
43241 int ret;
43242 - const struct net_device_ops apdev_netdev_ops = {
43243 - .ndo_start_xmit = pDevice->tx_80211,
43244 - };
43245
43246 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43247
43248 @@ -92,6 +91,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43249 *apdev_priv = *pDevice;
43250 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43251
43252 + /* only half broken now */
43253 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43254 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43255
43256 pDevice->apdev->type = ARPHRD_IEEE80211;
43257 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43258 index 26a7d0e..897b083 100644
43259 --- a/drivers/staging/vt6656/hostap.c
43260 +++ b/drivers/staging/vt6656/hostap.c
43261 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43262 *
43263 */
43264
43265 +static net_device_ops_no_const apdev_netdev_ops;
43266 +
43267 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43268 {
43269 PSDevice apdev_priv;
43270 struct net_device *dev = pDevice->dev;
43271 int ret;
43272 - const struct net_device_ops apdev_netdev_ops = {
43273 - .ndo_start_xmit = pDevice->tx_80211,
43274 - };
43275
43276 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43277
43278 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43279 *apdev_priv = *pDevice;
43280 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43281
43282 + /* only half broken now */
43283 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43284 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43285
43286 pDevice->apdev->type = ARPHRD_IEEE80211;
43287 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43288 index 56c8e60..1920c63 100644
43289 --- a/drivers/staging/zcache/tmem.c
43290 +++ b/drivers/staging/zcache/tmem.c
43291 @@ -39,7 +39,7 @@
43292 * A tmem host implementation must use this function to register callbacks
43293 * for memory allocation.
43294 */
43295 -static struct tmem_hostops tmem_hostops;
43296 +static tmem_hostops_no_const tmem_hostops;
43297
43298 static void tmem_objnode_tree_init(void);
43299
43300 @@ -53,7 +53,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43301 * A tmem host implementation must use this function to register
43302 * callbacks for a page-accessible memory (PAM) implementation
43303 */
43304 -static struct tmem_pamops tmem_pamops;
43305 +static tmem_pamops_no_const tmem_pamops;
43306
43307 void tmem_register_pamops(struct tmem_pamops *m)
43308 {
43309 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43310 index 0d4aa82..f7832d4 100644
43311 --- a/drivers/staging/zcache/tmem.h
43312 +++ b/drivers/staging/zcache/tmem.h
43313 @@ -180,6 +180,7 @@ struct tmem_pamops {
43314 void (*new_obj)(struct tmem_obj *);
43315 int (*replace_in_obj)(void *, struct tmem_obj *);
43316 };
43317 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43318 extern void tmem_register_pamops(struct tmem_pamops *m);
43319
43320 /* memory allocation methods provided by the host implementation */
43321 @@ -189,6 +190,7 @@ struct tmem_hostops {
43322 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43323 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43324 };
43325 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43326 extern void tmem_register_hostops(struct tmem_hostops *m);
43327
43328 /* core tmem accessor functions */
43329 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43330 index 96f4981..4daaa7e 100644
43331 --- a/drivers/target/target_core_device.c
43332 +++ b/drivers/target/target_core_device.c
43333 @@ -1370,7 +1370,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43334 spin_lock_init(&dev->se_port_lock);
43335 spin_lock_init(&dev->se_tmr_lock);
43336 spin_lock_init(&dev->qf_cmd_lock);
43337 - atomic_set(&dev->dev_ordered_id, 0);
43338 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43339 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43340 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43341 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43342 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43343 index fcf880f..a4d1e8f 100644
43344 --- a/drivers/target/target_core_transport.c
43345 +++ b/drivers/target/target_core_transport.c
43346 @@ -1077,7 +1077,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43347 * Used to determine when ORDERED commands should go from
43348 * Dormant to Active status.
43349 */
43350 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43351 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43352 smp_mb__after_atomic_inc();
43353 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43354 cmd->se_ordered_id, cmd->sam_task_attr,
43355 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43356 index b09c8d1f..c4225c0 100644
43357 --- a/drivers/tty/cyclades.c
43358 +++ b/drivers/tty/cyclades.c
43359 @@ -1589,10 +1589,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43360 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43361 info->port.count);
43362 #endif
43363 - info->port.count++;
43364 + atomic_inc(&info->port.count);
43365 #ifdef CY_DEBUG_COUNT
43366 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43367 - current->pid, info->port.count);
43368 + current->pid, atomic_read(&info->port.count));
43369 #endif
43370
43371 /*
43372 @@ -3991,7 +3991,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43373 for (j = 0; j < cy_card[i].nports; j++) {
43374 info = &cy_card[i].ports[j];
43375
43376 - if (info->port.count) {
43377 + if (atomic_read(&info->port.count)) {
43378 /* XXX is the ldisc num worth this? */
43379 struct tty_struct *tty;
43380 struct tty_ldisc *ld;
43381 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43382 index 13ee53b..418d164 100644
43383 --- a/drivers/tty/hvc/hvc_console.c
43384 +++ b/drivers/tty/hvc/hvc_console.c
43385 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43386
43387 spin_lock_irqsave(&hp->port.lock, flags);
43388 /* Check and then increment for fast path open. */
43389 - if (hp->port.count++ > 0) {
43390 + if (atomic_inc_return(&hp->port.count) > 1) {
43391 spin_unlock_irqrestore(&hp->port.lock, flags);
43392 hvc_kick();
43393 return 0;
43394 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43395
43396 spin_lock_irqsave(&hp->port.lock, flags);
43397
43398 - if (--hp->port.count == 0) {
43399 + if (atomic_dec_return(&hp->port.count) == 0) {
43400 spin_unlock_irqrestore(&hp->port.lock, flags);
43401 /* We are done with the tty pointer now. */
43402 tty_port_tty_set(&hp->port, NULL);
43403 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43404 */
43405 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43406 } else {
43407 - if (hp->port.count < 0)
43408 + if (atomic_read(&hp->port.count) < 0)
43409 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43410 - hp->vtermno, hp->port.count);
43411 + hp->vtermno, atomic_read(&hp->port.count));
43412 spin_unlock_irqrestore(&hp->port.lock, flags);
43413 }
43414 }
43415 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43416 * open->hangup case this can be called after the final close so prevent
43417 * that from happening for now.
43418 */
43419 - if (hp->port.count <= 0) {
43420 + if (atomic_read(&hp->port.count) <= 0) {
43421 spin_unlock_irqrestore(&hp->port.lock, flags);
43422 return;
43423 }
43424
43425 - hp->port.count = 0;
43426 + atomic_set(&hp->port.count, 0);
43427 spin_unlock_irqrestore(&hp->port.lock, flags);
43428 tty_port_tty_set(&hp->port, NULL);
43429
43430 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43431 return -EPIPE;
43432
43433 /* FIXME what's this (unprotected) check for? */
43434 - if (hp->port.count <= 0)
43435 + if (atomic_read(&hp->port.count) <= 0)
43436 return -EIO;
43437
43438 spin_lock_irqsave(&hp->lock, flags);
43439 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43440 index 8776357..b2d4afd 100644
43441 --- a/drivers/tty/hvc/hvcs.c
43442 +++ b/drivers/tty/hvc/hvcs.c
43443 @@ -83,6 +83,7 @@
43444 #include <asm/hvcserver.h>
43445 #include <asm/uaccess.h>
43446 #include <asm/vio.h>
43447 +#include <asm/local.h>
43448
43449 /*
43450 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43451 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43452
43453 spin_lock_irqsave(&hvcsd->lock, flags);
43454
43455 - if (hvcsd->port.count > 0) {
43456 + if (atomic_read(&hvcsd->port.count) > 0) {
43457 spin_unlock_irqrestore(&hvcsd->lock, flags);
43458 printk(KERN_INFO "HVCS: vterm state unchanged. "
43459 "The hvcs device node is still in use.\n");
43460 @@ -1132,7 +1133,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43461 }
43462 }
43463
43464 - hvcsd->port.count = 0;
43465 + atomic_set(&hvcsd->port.count, 0);
43466 hvcsd->port.tty = tty;
43467 tty->driver_data = hvcsd;
43468
43469 @@ -1185,7 +1186,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43470 unsigned long flags;
43471
43472 spin_lock_irqsave(&hvcsd->lock, flags);
43473 - hvcsd->port.count++;
43474 + atomic_inc(&hvcsd->port.count);
43475 hvcsd->todo_mask |= HVCS_SCHED_READ;
43476 spin_unlock_irqrestore(&hvcsd->lock, flags);
43477
43478 @@ -1221,7 +1222,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43479 hvcsd = tty->driver_data;
43480
43481 spin_lock_irqsave(&hvcsd->lock, flags);
43482 - if (--hvcsd->port.count == 0) {
43483 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43484
43485 vio_disable_interrupts(hvcsd->vdev);
43486
43487 @@ -1246,10 +1247,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43488
43489 free_irq(irq, hvcsd);
43490 return;
43491 - } else if (hvcsd->port.count < 0) {
43492 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43493 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43494 " is missmanaged.\n",
43495 - hvcsd->vdev->unit_address, hvcsd->port.count);
43496 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43497 }
43498
43499 spin_unlock_irqrestore(&hvcsd->lock, flags);
43500 @@ -1271,7 +1272,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43501
43502 spin_lock_irqsave(&hvcsd->lock, flags);
43503 /* Preserve this so that we know how many kref refs to put */
43504 - temp_open_count = hvcsd->port.count;
43505 + temp_open_count = atomic_read(&hvcsd->port.count);
43506
43507 /*
43508 * Don't kref put inside the spinlock because the destruction
43509 @@ -1286,7 +1287,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43510 tty->driver_data = NULL;
43511 hvcsd->port.tty = NULL;
43512
43513 - hvcsd->port.count = 0;
43514 + atomic_set(&hvcsd->port.count, 0);
43515
43516 /* This will drop any buffered data on the floor which is OK in a hangup
43517 * scenario. */
43518 @@ -1357,7 +1358,7 @@ static int hvcs_write(struct tty_struct *tty,
43519 * the middle of a write operation? This is a crummy place to do this
43520 * but we want to keep it all in the spinlock.
43521 */
43522 - if (hvcsd->port.count <= 0) {
43523 + if (atomic_read(&hvcsd->port.count) <= 0) {
43524 spin_unlock_irqrestore(&hvcsd->lock, flags);
43525 return -ENODEV;
43526 }
43527 @@ -1431,7 +1432,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43528 {
43529 struct hvcs_struct *hvcsd = tty->driver_data;
43530
43531 - if (!hvcsd || hvcsd->port.count <= 0)
43532 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43533 return 0;
43534
43535 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43536 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43537 index 2cde13d..645d78f 100644
43538 --- a/drivers/tty/ipwireless/tty.c
43539 +++ b/drivers/tty/ipwireless/tty.c
43540 @@ -29,6 +29,7 @@
43541 #include <linux/tty_driver.h>
43542 #include <linux/tty_flip.h>
43543 #include <linux/uaccess.h>
43544 +#include <asm/local.h>
43545
43546 #include "tty.h"
43547 #include "network.h"
43548 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43549 mutex_unlock(&tty->ipw_tty_mutex);
43550 return -ENODEV;
43551 }
43552 - if (tty->port.count == 0)
43553 + if (atomic_read(&tty->port.count) == 0)
43554 tty->tx_bytes_queued = 0;
43555
43556 - tty->port.count++;
43557 + atomic_inc(&tty->port.count);
43558
43559 tty->port.tty = linux_tty;
43560 linux_tty->driver_data = tty;
43561 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43562
43563 static void do_ipw_close(struct ipw_tty *tty)
43564 {
43565 - tty->port.count--;
43566 -
43567 - if (tty->port.count == 0) {
43568 + if (atomic_dec_return(&tty->port.count) == 0) {
43569 struct tty_struct *linux_tty = tty->port.tty;
43570
43571 if (linux_tty != NULL) {
43572 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43573 return;
43574
43575 mutex_lock(&tty->ipw_tty_mutex);
43576 - if (tty->port.count == 0) {
43577 + if (atomic_read(&tty->port.count) == 0) {
43578 mutex_unlock(&tty->ipw_tty_mutex);
43579 return;
43580 }
43581 @@ -170,7 +169,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43582 return;
43583 }
43584
43585 - if (!tty->port.count) {
43586 + if (!atomic_read(&tty->port.count)) {
43587 mutex_unlock(&tty->ipw_tty_mutex);
43588 return;
43589 }
43590 @@ -212,7 +211,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43591 return -ENODEV;
43592
43593 mutex_lock(&tty->ipw_tty_mutex);
43594 - if (!tty->port.count) {
43595 + if (!atomic_read(&tty->port.count)) {
43596 mutex_unlock(&tty->ipw_tty_mutex);
43597 return -EINVAL;
43598 }
43599 @@ -252,7 +251,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43600 if (!tty)
43601 return -ENODEV;
43602
43603 - if (!tty->port.count)
43604 + if (!atomic_read(&tty->port.count))
43605 return -EINVAL;
43606
43607 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43608 @@ -294,7 +293,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43609 if (!tty)
43610 return 0;
43611
43612 - if (!tty->port.count)
43613 + if (!atomic_read(&tty->port.count))
43614 return 0;
43615
43616 return tty->tx_bytes_queued;
43617 @@ -375,7 +374,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43618 if (!tty)
43619 return -ENODEV;
43620
43621 - if (!tty->port.count)
43622 + if (!atomic_read(&tty->port.count))
43623 return -EINVAL;
43624
43625 return get_control_lines(tty);
43626 @@ -391,7 +390,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43627 if (!tty)
43628 return -ENODEV;
43629
43630 - if (!tty->port.count)
43631 + if (!atomic_read(&tty->port.count))
43632 return -EINVAL;
43633
43634 return set_control_lines(tty, set, clear);
43635 @@ -405,7 +404,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43636 if (!tty)
43637 return -ENODEV;
43638
43639 - if (!tty->port.count)
43640 + if (!atomic_read(&tty->port.count))
43641 return -EINVAL;
43642
43643 /* FIXME: Exactly how is the tty object locked here .. */
43644 @@ -561,7 +560,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43645 * are gone */
43646 mutex_lock(&ttyj->ipw_tty_mutex);
43647 }
43648 - while (ttyj->port.count)
43649 + while (atomic_read(&ttyj->port.count))
43650 do_ipw_close(ttyj);
43651 ipwireless_disassociate_network_ttys(network,
43652 ttyj->channel_idx);
43653 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43654 index f9d2850..b006f04 100644
43655 --- a/drivers/tty/moxa.c
43656 +++ b/drivers/tty/moxa.c
43657 @@ -1193,7 +1193,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43658 }
43659
43660 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43661 - ch->port.count++;
43662 + atomic_inc(&ch->port.count);
43663 tty->driver_data = ch;
43664 tty_port_tty_set(&ch->port, tty);
43665 mutex_lock(&ch->port.mutex);
43666 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43667 index bfd6771..e0d93c4 100644
43668 --- a/drivers/tty/n_gsm.c
43669 +++ b/drivers/tty/n_gsm.c
43670 @@ -1636,7 +1636,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43671 spin_lock_init(&dlci->lock);
43672 mutex_init(&dlci->mutex);
43673 dlci->fifo = &dlci->_fifo;
43674 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43675 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43676 kfree(dlci);
43677 return NULL;
43678 }
43679 @@ -2936,7 +2936,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43680 struct gsm_dlci *dlci = tty->driver_data;
43681 struct tty_port *port = &dlci->port;
43682
43683 - port->count++;
43684 + atomic_inc(&port->count);
43685 dlci_get(dlci);
43686 dlci_get(dlci->gsm->dlci[0]);
43687 mux_get(dlci->gsm);
43688 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43689 index 19083ef..6e34e97 100644
43690 --- a/drivers/tty/n_tty.c
43691 +++ b/drivers/tty/n_tty.c
43692 @@ -2196,6 +2196,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43693 {
43694 *ops = tty_ldisc_N_TTY;
43695 ops->owner = NULL;
43696 - ops->refcount = ops->flags = 0;
43697 + atomic_set(&ops->refcount, 0);
43698 + ops->flags = 0;
43699 }
43700 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43701 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43702 index ac35c90..c47deac 100644
43703 --- a/drivers/tty/pty.c
43704 +++ b/drivers/tty/pty.c
43705 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
43706 panic("Couldn't register Unix98 pts driver");
43707
43708 /* Now create the /dev/ptmx special device */
43709 + pax_open_kernel();
43710 tty_default_fops(&ptmx_fops);
43711 - ptmx_fops.open = ptmx_open;
43712 + *(void **)&ptmx_fops.open = ptmx_open;
43713 + pax_close_kernel();
43714
43715 cdev_init(&ptmx_cdev, &ptmx_fops);
43716 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43717 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43718 index e42009a..566a036 100644
43719 --- a/drivers/tty/rocket.c
43720 +++ b/drivers/tty/rocket.c
43721 @@ -925,7 +925,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43722 tty->driver_data = info;
43723 tty_port_tty_set(port, tty);
43724
43725 - if (port->count++ == 0) {
43726 + if (atomic_inc_return(&port->count) == 1) {
43727 atomic_inc(&rp_num_ports_open);
43728
43729 #ifdef ROCKET_DEBUG_OPEN
43730 @@ -934,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43731 #endif
43732 }
43733 #ifdef ROCKET_DEBUG_OPEN
43734 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43735 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43736 #endif
43737
43738 /*
43739 @@ -1529,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty)
43740 spin_unlock_irqrestore(&info->port.lock, flags);
43741 return;
43742 }
43743 - if (info->port.count)
43744 + if (atomic_read(&info->port.count))
43745 atomic_dec(&rp_num_ports_open);
43746 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43747 spin_unlock_irqrestore(&info->port.lock, flags);
43748 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43749 index 1002054..dd644a8 100644
43750 --- a/drivers/tty/serial/kgdboc.c
43751 +++ b/drivers/tty/serial/kgdboc.c
43752 @@ -24,8 +24,9 @@
43753 #define MAX_CONFIG_LEN 40
43754
43755 static struct kgdb_io kgdboc_io_ops;
43756 +static struct kgdb_io kgdboc_io_ops_console;
43757
43758 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43759 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43760 static int configured = -1;
43761
43762 static char config[MAX_CONFIG_LEN];
43763 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43764 kgdboc_unregister_kbd();
43765 if (configured == 1)
43766 kgdb_unregister_io_module(&kgdboc_io_ops);
43767 + else if (configured == 2)
43768 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43769 }
43770
43771 static int configure_kgdboc(void)
43772 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43773 int err;
43774 char *cptr = config;
43775 struct console *cons;
43776 + int is_console = 0;
43777
43778 err = kgdboc_option_setup(config);
43779 if (err || !strlen(config) || isspace(config[0]))
43780 goto noconfig;
43781
43782 err = -ENODEV;
43783 - kgdboc_io_ops.is_console = 0;
43784 kgdb_tty_driver = NULL;
43785
43786 kgdboc_use_kms = 0;
43787 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43788 int idx;
43789 if (cons->device && cons->device(cons, &idx) == p &&
43790 idx == tty_line) {
43791 - kgdboc_io_ops.is_console = 1;
43792 + is_console = 1;
43793 break;
43794 }
43795 cons = cons->next;
43796 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43797 kgdb_tty_line = tty_line;
43798
43799 do_register:
43800 - err = kgdb_register_io_module(&kgdboc_io_ops);
43801 + if (is_console) {
43802 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43803 + configured = 2;
43804 + } else {
43805 + err = kgdb_register_io_module(&kgdboc_io_ops);
43806 + configured = 1;
43807 + }
43808 if (err)
43809 goto noconfig;
43810
43811 @@ -205,8 +214,6 @@ do_register:
43812 if (err)
43813 goto nmi_con_failed;
43814
43815 - configured = 1;
43816 -
43817 return 0;
43818
43819 nmi_con_failed:
43820 @@ -223,7 +230,7 @@ noconfig:
43821 static int __init init_kgdboc(void)
43822 {
43823 /* Already configured? */
43824 - if (configured == 1)
43825 + if (configured >= 1)
43826 return 0;
43827
43828 return configure_kgdboc();
43829 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43830 if (config[len - 1] == '\n')
43831 config[len - 1] = '\0';
43832
43833 - if (configured == 1)
43834 + if (configured >= 1)
43835 cleanup_kgdboc();
43836
43837 /* Go and configure with the new params. */
43838 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43839 .post_exception = kgdboc_post_exp_handler,
43840 };
43841
43842 +static struct kgdb_io kgdboc_io_ops_console = {
43843 + .name = "kgdboc",
43844 + .read_char = kgdboc_get_char,
43845 + .write_char = kgdboc_put_char,
43846 + .pre_exception = kgdboc_pre_exp_handler,
43847 + .post_exception = kgdboc_post_exp_handler,
43848 + .is_console = 1
43849 +};
43850 +
43851 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43852 /* This is only available if kgdboc is a built in for early debugging */
43853 static int __init kgdboc_early_init(char *opt)
43854 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43855 index e514b3a..c73d614 100644
43856 --- a/drivers/tty/serial/samsung.c
43857 +++ b/drivers/tty/serial/samsung.c
43858 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43859 }
43860 }
43861
43862 +static int s3c64xx_serial_startup(struct uart_port *port);
43863 static int s3c24xx_serial_startup(struct uart_port *port)
43864 {
43865 struct s3c24xx_uart_port *ourport = to_ourport(port);
43866 int ret;
43867
43868 + /* Startup sequence is different for s3c64xx and higher SoC's */
43869 + if (s3c24xx_serial_has_interrupt_mask(port))
43870 + return s3c64xx_serial_startup(port);
43871 +
43872 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43873 port->mapbase, port->membase);
43874
43875 @@ -1122,10 +1127,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43876 /* setup info for port */
43877 port->dev = &platdev->dev;
43878
43879 - /* Startup sequence is different for s3c64xx and higher SoC's */
43880 - if (s3c24xx_serial_has_interrupt_mask(port))
43881 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43882 -
43883 port->uartclk = 1;
43884
43885 if (cfg->uart_flags & UPF_CONS_FLOW) {
43886 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43887 index 2c7230a..2104f16 100644
43888 --- a/drivers/tty/serial/serial_core.c
43889 +++ b/drivers/tty/serial/serial_core.c
43890 @@ -1455,7 +1455,7 @@ static void uart_hangup(struct tty_struct *tty)
43891 uart_flush_buffer(tty);
43892 uart_shutdown(tty, state);
43893 spin_lock_irqsave(&port->lock, flags);
43894 - port->count = 0;
43895 + atomic_set(&port->count, 0);
43896 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43897 spin_unlock_irqrestore(&port->lock, flags);
43898 tty_port_tty_set(port, NULL);
43899 @@ -1551,7 +1551,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43900 goto end;
43901 }
43902
43903 - port->count++;
43904 + atomic_inc(&port->count);
43905 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43906 retval = -ENXIO;
43907 goto err_dec_count;
43908 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43909 /*
43910 * Make sure the device is in D0 state.
43911 */
43912 - if (port->count == 1)
43913 + if (atomic_read(&port->count) == 1)
43914 uart_change_pm(state, 0);
43915
43916 /*
43917 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43918 end:
43919 return retval;
43920 err_dec_count:
43921 - port->count--;
43922 + atomic_inc(&port->count);
43923 mutex_unlock(&port->mutex);
43924 goto end;
43925 }
43926 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43927 index 9e071f6..f30ae69 100644
43928 --- a/drivers/tty/synclink.c
43929 +++ b/drivers/tty/synclink.c
43930 @@ -3095,7 +3095,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43931
43932 if (debug_level >= DEBUG_LEVEL_INFO)
43933 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43934 - __FILE__,__LINE__, info->device_name, info->port.count);
43935 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43936
43937 if (tty_port_close_start(&info->port, tty, filp) == 0)
43938 goto cleanup;
43939 @@ -3113,7 +3113,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43940 cleanup:
43941 if (debug_level >= DEBUG_LEVEL_INFO)
43942 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43943 - tty->driver->name, info->port.count);
43944 + tty->driver->name, atomic_read(&info->port.count));
43945
43946 } /* end of mgsl_close() */
43947
43948 @@ -3212,8 +3212,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43949
43950 mgsl_flush_buffer(tty);
43951 shutdown(info);
43952 -
43953 - info->port.count = 0;
43954 +
43955 + atomic_set(&info->port.count, 0);
43956 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43957 info->port.tty = NULL;
43958
43959 @@ -3302,12 +3302,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43960
43961 if (debug_level >= DEBUG_LEVEL_INFO)
43962 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43963 - __FILE__,__LINE__, tty->driver->name, port->count );
43964 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43965
43966 spin_lock_irqsave(&info->irq_spinlock, flags);
43967 if (!tty_hung_up_p(filp)) {
43968 extra_count = true;
43969 - port->count--;
43970 + atomic_dec(&port->count);
43971 }
43972 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43973 port->blocked_open++;
43974 @@ -3336,7 +3336,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43975
43976 if (debug_level >= DEBUG_LEVEL_INFO)
43977 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43978 - __FILE__,__LINE__, tty->driver->name, port->count );
43979 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43980
43981 tty_unlock(tty);
43982 schedule();
43983 @@ -3348,12 +3348,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43984
43985 /* FIXME: Racy on hangup during close wait */
43986 if (extra_count)
43987 - port->count++;
43988 + atomic_inc(&port->count);
43989 port->blocked_open--;
43990
43991 if (debug_level >= DEBUG_LEVEL_INFO)
43992 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43993 - __FILE__,__LINE__, tty->driver->name, port->count );
43994 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43995
43996 if (!retval)
43997 port->flags |= ASYNC_NORMAL_ACTIVE;
43998 @@ -3405,7 +3405,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43999
44000 if (debug_level >= DEBUG_LEVEL_INFO)
44001 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
44002 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44003 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44004
44005 /* If port is closing, signal caller to try again */
44006 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44007 @@ -3424,10 +3424,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
44008 spin_unlock_irqrestore(&info->netlock, flags);
44009 goto cleanup;
44010 }
44011 - info->port.count++;
44012 + atomic_inc(&info->port.count);
44013 spin_unlock_irqrestore(&info->netlock, flags);
44014
44015 - if (info->port.count == 1) {
44016 + if (atomic_read(&info->port.count) == 1) {
44017 /* 1st open on this device, init hardware */
44018 retval = startup(info);
44019 if (retval < 0)
44020 @@ -3451,8 +3451,8 @@ cleanup:
44021 if (retval) {
44022 if (tty->count == 1)
44023 info->port.tty = NULL; /* tty layer will release tty struct */
44024 - if(info->port.count)
44025 - info->port.count--;
44026 + if (atomic_read(&info->port.count))
44027 + atomic_dec(&info->port.count);
44028 }
44029
44030 return retval;
44031 @@ -7662,7 +7662,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44032 unsigned short new_crctype;
44033
44034 /* return error if TTY interface open */
44035 - if (info->port.count)
44036 + if (atomic_read(&info->port.count))
44037 return -EBUSY;
44038
44039 switch (encoding)
44040 @@ -7757,7 +7757,7 @@ static int hdlcdev_open(struct net_device *dev)
44041
44042 /* arbitrate between network and tty opens */
44043 spin_lock_irqsave(&info->netlock, flags);
44044 - if (info->port.count != 0 || info->netcount != 0) {
44045 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44046 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44047 spin_unlock_irqrestore(&info->netlock, flags);
44048 return -EBUSY;
44049 @@ -7843,7 +7843,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44050 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44051
44052 /* return error if TTY interface open */
44053 - if (info->port.count)
44054 + if (atomic_read(&info->port.count))
44055 return -EBUSY;
44056
44057 if (cmd != SIOCWANDEV)
44058 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
44059 index aba1e59..877ac33 100644
44060 --- a/drivers/tty/synclink_gt.c
44061 +++ b/drivers/tty/synclink_gt.c
44062 @@ -671,7 +671,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44063 tty->driver_data = info;
44064 info->port.tty = tty;
44065
44066 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
44067 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
44068
44069 /* If port is closing, signal caller to try again */
44070 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44071 @@ -692,10 +692,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44072 mutex_unlock(&info->port.mutex);
44073 goto cleanup;
44074 }
44075 - info->port.count++;
44076 + atomic_inc(&info->port.count);
44077 spin_unlock_irqrestore(&info->netlock, flags);
44078
44079 - if (info->port.count == 1) {
44080 + if (atomic_read(&info->port.count) == 1) {
44081 /* 1st open on this device, init hardware */
44082 retval = startup(info);
44083 if (retval < 0) {
44084 @@ -716,8 +716,8 @@ cleanup:
44085 if (retval) {
44086 if (tty->count == 1)
44087 info->port.tty = NULL; /* tty layer will release tty struct */
44088 - if(info->port.count)
44089 - info->port.count--;
44090 + if(atomic_read(&info->port.count))
44091 + atomic_dec(&info->port.count);
44092 }
44093
44094 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
44095 @@ -730,7 +730,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44096
44097 if (sanity_check(info, tty->name, "close"))
44098 return;
44099 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
44100 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
44101
44102 if (tty_port_close_start(&info->port, tty, filp) == 0)
44103 goto cleanup;
44104 @@ -747,7 +747,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44105 tty_port_close_end(&info->port, tty);
44106 info->port.tty = NULL;
44107 cleanup:
44108 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
44109 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
44110 }
44111
44112 static void hangup(struct tty_struct *tty)
44113 @@ -765,7 +765,7 @@ static void hangup(struct tty_struct *tty)
44114 shutdown(info);
44115
44116 spin_lock_irqsave(&info->port.lock, flags);
44117 - info->port.count = 0;
44118 + atomic_set(&info->port.count, 0);
44119 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44120 info->port.tty = NULL;
44121 spin_unlock_irqrestore(&info->port.lock, flags);
44122 @@ -1450,7 +1450,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44123 unsigned short new_crctype;
44124
44125 /* return error if TTY interface open */
44126 - if (info->port.count)
44127 + if (atomic_read(&info->port.count))
44128 return -EBUSY;
44129
44130 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44131 @@ -1545,7 +1545,7 @@ static int hdlcdev_open(struct net_device *dev)
44132
44133 /* arbitrate between network and tty opens */
44134 spin_lock_irqsave(&info->netlock, flags);
44135 - if (info->port.count != 0 || info->netcount != 0) {
44136 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44137 DBGINFO(("%s hdlc_open busy\n", dev->name));
44138 spin_unlock_irqrestore(&info->netlock, flags);
44139 return -EBUSY;
44140 @@ -1630,7 +1630,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44141 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44142
44143 /* return error if TTY interface open */
44144 - if (info->port.count)
44145 + if (atomic_read(&info->port.count))
44146 return -EBUSY;
44147
44148 if (cmd != SIOCWANDEV)
44149 @@ -2419,7 +2419,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44150 if (port == NULL)
44151 continue;
44152 spin_lock(&port->lock);
44153 - if ((port->port.count || port->netcount) &&
44154 + if ((atomic_read(&port->port.count) || port->netcount) &&
44155 port->pending_bh && !port->bh_running &&
44156 !port->bh_requested) {
44157 DBGISR(("%s bh queued\n", port->device_name));
44158 @@ -3308,7 +3308,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44159 spin_lock_irqsave(&info->lock, flags);
44160 if (!tty_hung_up_p(filp)) {
44161 extra_count = true;
44162 - port->count--;
44163 + atomic_dec(&port->count);
44164 }
44165 spin_unlock_irqrestore(&info->lock, flags);
44166 port->blocked_open++;
44167 @@ -3345,7 +3345,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44168 remove_wait_queue(&port->open_wait, &wait);
44169
44170 if (extra_count)
44171 - port->count++;
44172 + atomic_inc(&port->count);
44173 port->blocked_open--;
44174
44175 if (!retval)
44176 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44177 index fd43fb6..34704ad 100644
44178 --- a/drivers/tty/synclinkmp.c
44179 +++ b/drivers/tty/synclinkmp.c
44180 @@ -751,7 +751,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44181
44182 if (debug_level >= DEBUG_LEVEL_INFO)
44183 printk("%s(%d):%s open(), old ref count = %d\n",
44184 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44185 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44186
44187 /* If port is closing, signal caller to try again */
44188 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44189 @@ -770,10 +770,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44190 spin_unlock_irqrestore(&info->netlock, flags);
44191 goto cleanup;
44192 }
44193 - info->port.count++;
44194 + atomic_inc(&info->port.count);
44195 spin_unlock_irqrestore(&info->netlock, flags);
44196
44197 - if (info->port.count == 1) {
44198 + if (atomic_read(&info->port.count) == 1) {
44199 /* 1st open on this device, init hardware */
44200 retval = startup(info);
44201 if (retval < 0)
44202 @@ -797,8 +797,8 @@ cleanup:
44203 if (retval) {
44204 if (tty->count == 1)
44205 info->port.tty = NULL; /* tty layer will release tty struct */
44206 - if(info->port.count)
44207 - info->port.count--;
44208 + if(atomic_read(&info->port.count))
44209 + atomic_dec(&info->port.count);
44210 }
44211
44212 return retval;
44213 @@ -816,7 +816,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44214
44215 if (debug_level >= DEBUG_LEVEL_INFO)
44216 printk("%s(%d):%s close() entry, count=%d\n",
44217 - __FILE__,__LINE__, info->device_name, info->port.count);
44218 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44219
44220 if (tty_port_close_start(&info->port, tty, filp) == 0)
44221 goto cleanup;
44222 @@ -835,7 +835,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44223 cleanup:
44224 if (debug_level >= DEBUG_LEVEL_INFO)
44225 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44226 - tty->driver->name, info->port.count);
44227 + tty->driver->name, atomic_read(&info->port.count));
44228 }
44229
44230 /* Called by tty_hangup() when a hangup is signaled.
44231 @@ -858,7 +858,7 @@ static void hangup(struct tty_struct *tty)
44232 shutdown(info);
44233
44234 spin_lock_irqsave(&info->port.lock, flags);
44235 - info->port.count = 0;
44236 + atomic_set(&info->port.count, 0);
44237 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44238 info->port.tty = NULL;
44239 spin_unlock_irqrestore(&info->port.lock, flags);
44240 @@ -1566,7 +1566,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44241 unsigned short new_crctype;
44242
44243 /* return error if TTY interface open */
44244 - if (info->port.count)
44245 + if (atomic_read(&info->port.count))
44246 return -EBUSY;
44247
44248 switch (encoding)
44249 @@ -1661,7 +1661,7 @@ static int hdlcdev_open(struct net_device *dev)
44250
44251 /* arbitrate between network and tty opens */
44252 spin_lock_irqsave(&info->netlock, flags);
44253 - if (info->port.count != 0 || info->netcount != 0) {
44254 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44255 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44256 spin_unlock_irqrestore(&info->netlock, flags);
44257 return -EBUSY;
44258 @@ -1747,7 +1747,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44259 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44260
44261 /* return error if TTY interface open */
44262 - if (info->port.count)
44263 + if (atomic_read(&info->port.count))
44264 return -EBUSY;
44265
44266 if (cmd != SIOCWANDEV)
44267 @@ -2632,7 +2632,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44268 * do not request bottom half processing if the
44269 * device is not open in a normal mode.
44270 */
44271 - if ( port && (port->port.count || port->netcount) &&
44272 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44273 port->pending_bh && !port->bh_running &&
44274 !port->bh_requested ) {
44275 if ( debug_level >= DEBUG_LEVEL_ISR )
44276 @@ -3330,12 +3330,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44277
44278 if (debug_level >= DEBUG_LEVEL_INFO)
44279 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44280 - __FILE__,__LINE__, tty->driver->name, port->count );
44281 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44282
44283 spin_lock_irqsave(&info->lock, flags);
44284 if (!tty_hung_up_p(filp)) {
44285 extra_count = true;
44286 - port->count--;
44287 + atomic_dec(&port->count);
44288 }
44289 spin_unlock_irqrestore(&info->lock, flags);
44290 port->blocked_open++;
44291 @@ -3364,7 +3364,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44292
44293 if (debug_level >= DEBUG_LEVEL_INFO)
44294 printk("%s(%d):%s block_til_ready() count=%d\n",
44295 - __FILE__,__LINE__, tty->driver->name, port->count );
44296 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44297
44298 tty_unlock(tty);
44299 schedule();
44300 @@ -3375,12 +3375,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44301 remove_wait_queue(&port->open_wait, &wait);
44302
44303 if (extra_count)
44304 - port->count++;
44305 + atomic_inc(&port->count);
44306 port->blocked_open--;
44307
44308 if (debug_level >= DEBUG_LEVEL_INFO)
44309 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44310 - __FILE__,__LINE__, tty->driver->name, port->count );
44311 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44312
44313 if (!retval)
44314 port->flags |= ASYNC_NORMAL_ACTIVE;
44315 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44316 index b3c4a25..723916f 100644
44317 --- a/drivers/tty/sysrq.c
44318 +++ b/drivers/tty/sysrq.c
44319 @@ -867,7 +867,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44320 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44321 size_t count, loff_t *ppos)
44322 {
44323 - if (count) {
44324 + if (count && capable(CAP_SYS_ADMIN)) {
44325 char c;
44326
44327 if (get_user(c, buf))
44328 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44329 index da9fde8..c07975f 100644
44330 --- a/drivers/tty/tty_io.c
44331 +++ b/drivers/tty/tty_io.c
44332 @@ -3391,7 +3391,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44333
44334 void tty_default_fops(struct file_operations *fops)
44335 {
44336 - *fops = tty_fops;
44337 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44338 }
44339
44340 /*
44341 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44342 index c578229..45aa9ee 100644
44343 --- a/drivers/tty/tty_ldisc.c
44344 +++ b/drivers/tty/tty_ldisc.c
44345 @@ -56,7 +56,7 @@ static void put_ldisc(struct tty_ldisc *ld)
44346 if (atomic_dec_and_test(&ld->users)) {
44347 struct tty_ldisc_ops *ldo = ld->ops;
44348
44349 - ldo->refcount--;
44350 + atomic_dec(&ldo->refcount);
44351 module_put(ldo->owner);
44352 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44353
44354 @@ -91,7 +91,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44355 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44356 tty_ldiscs[disc] = new_ldisc;
44357 new_ldisc->num = disc;
44358 - new_ldisc->refcount = 0;
44359 + atomic_set(&new_ldisc->refcount, 0);
44360 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44361
44362 return ret;
44363 @@ -119,7 +119,7 @@ int tty_unregister_ldisc(int disc)
44364 return -EINVAL;
44365
44366 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44367 - if (tty_ldiscs[disc]->refcount)
44368 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44369 ret = -EBUSY;
44370 else
44371 tty_ldiscs[disc] = NULL;
44372 @@ -140,7 +140,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44373 if (ldops) {
44374 ret = ERR_PTR(-EAGAIN);
44375 if (try_module_get(ldops->owner)) {
44376 - ldops->refcount++;
44377 + atomic_inc(&ldops->refcount);
44378 ret = ldops;
44379 }
44380 }
44381 @@ -153,7 +153,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44382 unsigned long flags;
44383
44384 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44385 - ldops->refcount--;
44386 + atomic_dec(&ldops->refcount);
44387 module_put(ldops->owner);
44388 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44389 }
44390 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44391 index b7ff59d..7c6105e 100644
44392 --- a/drivers/tty/tty_port.c
44393 +++ b/drivers/tty/tty_port.c
44394 @@ -218,7 +218,7 @@ void tty_port_hangup(struct tty_port *port)
44395 unsigned long flags;
44396
44397 spin_lock_irqsave(&port->lock, flags);
44398 - port->count = 0;
44399 + atomic_set(&port->count, 0);
44400 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44401 if (port->tty) {
44402 set_bit(TTY_IO_ERROR, &port->tty->flags);
44403 @@ -344,7 +344,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44404 /* The port lock protects the port counts */
44405 spin_lock_irqsave(&port->lock, flags);
44406 if (!tty_hung_up_p(filp))
44407 - port->count--;
44408 + atomic_dec(&port->count);
44409 port->blocked_open++;
44410 spin_unlock_irqrestore(&port->lock, flags);
44411
44412 @@ -386,7 +386,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44413 we must not mess that up further */
44414 spin_lock_irqsave(&port->lock, flags);
44415 if (!tty_hung_up_p(filp))
44416 - port->count++;
44417 + atomic_inc(&port->count);
44418 port->blocked_open--;
44419 if (retval == 0)
44420 port->flags |= ASYNC_NORMAL_ACTIVE;
44421 @@ -406,19 +406,19 @@ int tty_port_close_start(struct tty_port *port,
44422 return 0;
44423 }
44424
44425 - if (tty->count == 1 && port->count != 1) {
44426 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44427 printk(KERN_WARNING
44428 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44429 - port->count);
44430 - port->count = 1;
44431 + atomic_read(&port->count));
44432 + atomic_set(&port->count, 1);
44433 }
44434 - if (--port->count < 0) {
44435 + if (atomic_dec_return(&port->count) < 0) {
44436 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44437 - port->count);
44438 - port->count = 0;
44439 + atomic_read(&port->count));
44440 + atomic_set(&port->count, 0);
44441 }
44442
44443 - if (port->count) {
44444 + if (atomic_read(&port->count)) {
44445 spin_unlock_irqrestore(&port->lock, flags);
44446 if (port->ops->drop)
44447 port->ops->drop(port);
44448 @@ -516,7 +516,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44449 {
44450 spin_lock_irq(&port->lock);
44451 if (!tty_hung_up_p(filp))
44452 - ++port->count;
44453 + atomic_inc(&port->count);
44454 spin_unlock_irq(&port->lock);
44455 tty_port_tty_set(port, tty);
44456
44457 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44458 index 681765b..d3ccdf2 100644
44459 --- a/drivers/tty/vt/keyboard.c
44460 +++ b/drivers/tty/vt/keyboard.c
44461 @@ -660,6 +660,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44462 kbd->kbdmode == VC_OFF) &&
44463 value != KVAL(K_SAK))
44464 return; /* SAK is allowed even in raw mode */
44465 +
44466 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44467 + {
44468 + void *func = fn_handler[value];
44469 + if (func == fn_show_state || func == fn_show_ptregs ||
44470 + func == fn_show_mem)
44471 + return;
44472 + }
44473 +#endif
44474 +
44475 fn_handler[value](vc);
44476 }
44477
44478 @@ -1808,9 +1818,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44479 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44480 return -EFAULT;
44481
44482 - if (!capable(CAP_SYS_TTY_CONFIG))
44483 - perm = 0;
44484 -
44485 switch (cmd) {
44486 case KDGKBENT:
44487 /* Ensure another thread doesn't free it under us */
44488 @@ -1825,6 +1832,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44489 spin_unlock_irqrestore(&kbd_event_lock, flags);
44490 return put_user(val, &user_kbe->kb_value);
44491 case KDSKBENT:
44492 + if (!capable(CAP_SYS_TTY_CONFIG))
44493 + perm = 0;
44494 +
44495 if (!perm)
44496 return -EPERM;
44497 if (!i && v == K_NOSUCHMAP) {
44498 @@ -1915,9 +1925,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44499 int i, j, k;
44500 int ret;
44501
44502 - if (!capable(CAP_SYS_TTY_CONFIG))
44503 - perm = 0;
44504 -
44505 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44506 if (!kbs) {
44507 ret = -ENOMEM;
44508 @@ -1951,6 +1958,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44509 kfree(kbs);
44510 return ((p && *p) ? -EOVERFLOW : 0);
44511 case KDSKBSENT:
44512 + if (!capable(CAP_SYS_TTY_CONFIG))
44513 + perm = 0;
44514 +
44515 if (!perm) {
44516 ret = -EPERM;
44517 goto reterr;
44518 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44519 index 5110f36..8dc0a74 100644
44520 --- a/drivers/uio/uio.c
44521 +++ b/drivers/uio/uio.c
44522 @@ -25,6 +25,7 @@
44523 #include <linux/kobject.h>
44524 #include <linux/cdev.h>
44525 #include <linux/uio_driver.h>
44526 +#include <asm/local.h>
44527
44528 #define UIO_MAX_DEVICES (1U << MINORBITS)
44529
44530 @@ -32,10 +33,10 @@ struct uio_device {
44531 struct module *owner;
44532 struct device *dev;
44533 int minor;
44534 - atomic_t event;
44535 + atomic_unchecked_t event;
44536 struct fasync_struct *async_queue;
44537 wait_queue_head_t wait;
44538 - int vma_count;
44539 + local_t vma_count;
44540 struct uio_info *info;
44541 struct kobject *map_dir;
44542 struct kobject *portio_dir;
44543 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44544 struct device_attribute *attr, char *buf)
44545 {
44546 struct uio_device *idev = dev_get_drvdata(dev);
44547 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44548 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44549 }
44550
44551 static struct device_attribute uio_class_attributes[] = {
44552 @@ -408,7 +409,7 @@ void uio_event_notify(struct uio_info *info)
44553 {
44554 struct uio_device *idev = info->uio_dev;
44555
44556 - atomic_inc(&idev->event);
44557 + atomic_inc_unchecked(&idev->event);
44558 wake_up_interruptible(&idev->wait);
44559 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44560 }
44561 @@ -461,7 +462,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44562 }
44563
44564 listener->dev = idev;
44565 - listener->event_count = atomic_read(&idev->event);
44566 + listener->event_count = atomic_read_unchecked(&idev->event);
44567 filep->private_data = listener;
44568
44569 if (idev->info->open) {
44570 @@ -512,7 +513,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44571 return -EIO;
44572
44573 poll_wait(filep, &idev->wait, wait);
44574 - if (listener->event_count != atomic_read(&idev->event))
44575 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44576 return POLLIN | POLLRDNORM;
44577 return 0;
44578 }
44579 @@ -537,7 +538,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44580 do {
44581 set_current_state(TASK_INTERRUPTIBLE);
44582
44583 - event_count = atomic_read(&idev->event);
44584 + event_count = atomic_read_unchecked(&idev->event);
44585 if (event_count != listener->event_count) {
44586 if (copy_to_user(buf, &event_count, count))
44587 retval = -EFAULT;
44588 @@ -606,13 +607,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44589 static void uio_vma_open(struct vm_area_struct *vma)
44590 {
44591 struct uio_device *idev = vma->vm_private_data;
44592 - idev->vma_count++;
44593 + local_inc(&idev->vma_count);
44594 }
44595
44596 static void uio_vma_close(struct vm_area_struct *vma)
44597 {
44598 struct uio_device *idev = vma->vm_private_data;
44599 - idev->vma_count--;
44600 + local_dec(&idev->vma_count);
44601 }
44602
44603 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44604 @@ -819,7 +820,7 @@ int __uio_register_device(struct module *owner,
44605 idev->owner = owner;
44606 idev->info = info;
44607 init_waitqueue_head(&idev->wait);
44608 - atomic_set(&idev->event, 0);
44609 + atomic_set_unchecked(&idev->event, 0);
44610
44611 ret = uio_get_minor(idev);
44612 if (ret)
44613 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44614 index b7eb86a..36d28af 100644
44615 --- a/drivers/usb/atm/cxacru.c
44616 +++ b/drivers/usb/atm/cxacru.c
44617 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44618 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44619 if (ret < 2)
44620 return -EINVAL;
44621 - if (index < 0 || index > 0x7f)
44622 + if (index > 0x7f)
44623 return -EINVAL;
44624 pos += tmp;
44625
44626 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44627 index 35f10bf..6a38a0b 100644
44628 --- a/drivers/usb/atm/usbatm.c
44629 +++ b/drivers/usb/atm/usbatm.c
44630 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44631 if (printk_ratelimit())
44632 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44633 __func__, vpi, vci);
44634 - atomic_inc(&vcc->stats->rx_err);
44635 + atomic_inc_unchecked(&vcc->stats->rx_err);
44636 return;
44637 }
44638
44639 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44640 if (length > ATM_MAX_AAL5_PDU) {
44641 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44642 __func__, length, vcc);
44643 - atomic_inc(&vcc->stats->rx_err);
44644 + atomic_inc_unchecked(&vcc->stats->rx_err);
44645 goto out;
44646 }
44647
44648 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44649 if (sarb->len < pdu_length) {
44650 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44651 __func__, pdu_length, sarb->len, vcc);
44652 - atomic_inc(&vcc->stats->rx_err);
44653 + atomic_inc_unchecked(&vcc->stats->rx_err);
44654 goto out;
44655 }
44656
44657 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44658 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44659 __func__, vcc);
44660 - atomic_inc(&vcc->stats->rx_err);
44661 + atomic_inc_unchecked(&vcc->stats->rx_err);
44662 goto out;
44663 }
44664
44665 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44666 if (printk_ratelimit())
44667 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44668 __func__, length);
44669 - atomic_inc(&vcc->stats->rx_drop);
44670 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44671 goto out;
44672 }
44673
44674 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44675
44676 vcc->push(vcc, skb);
44677
44678 - atomic_inc(&vcc->stats->rx);
44679 + atomic_inc_unchecked(&vcc->stats->rx);
44680 out:
44681 skb_trim(sarb, 0);
44682 }
44683 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44684 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44685
44686 usbatm_pop(vcc, skb);
44687 - atomic_inc(&vcc->stats->tx);
44688 + atomic_inc_unchecked(&vcc->stats->tx);
44689
44690 skb = skb_dequeue(&instance->sndqueue);
44691 }
44692 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44693 if (!left--)
44694 return sprintf(page,
44695 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44696 - atomic_read(&atm_dev->stats.aal5.tx),
44697 - atomic_read(&atm_dev->stats.aal5.tx_err),
44698 - atomic_read(&atm_dev->stats.aal5.rx),
44699 - atomic_read(&atm_dev->stats.aal5.rx_err),
44700 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44701 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44702 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44703 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44704 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44705 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44706
44707 if (!left--) {
44708 if (instance->disconnected)
44709 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44710 index cbacea9..246cccd 100644
44711 --- a/drivers/usb/core/devices.c
44712 +++ b/drivers/usb/core/devices.c
44713 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44714 * time it gets called.
44715 */
44716 static struct device_connect_event {
44717 - atomic_t count;
44718 + atomic_unchecked_t count;
44719 wait_queue_head_t wait;
44720 } device_event = {
44721 .count = ATOMIC_INIT(1),
44722 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44723
44724 void usbfs_conn_disc_event(void)
44725 {
44726 - atomic_add(2, &device_event.count);
44727 + atomic_add_unchecked(2, &device_event.count);
44728 wake_up(&device_event.wait);
44729 }
44730
44731 @@ -645,7 +645,7 @@ static unsigned int usb_device_poll(struct file *file,
44732
44733 poll_wait(file, &device_event.wait, wait);
44734
44735 - event_count = atomic_read(&device_event.count);
44736 + event_count = atomic_read_unchecked(&device_event.count);
44737 if (file->f_version != event_count) {
44738 file->f_version = event_count;
44739 return POLLIN | POLLRDNORM;
44740 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44741 index 8e64adf..9a33a3c 100644
44742 --- a/drivers/usb/core/hcd.c
44743 +++ b/drivers/usb/core/hcd.c
44744 @@ -1522,7 +1522,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44745 */
44746 usb_get_urb(urb);
44747 atomic_inc(&urb->use_count);
44748 - atomic_inc(&urb->dev->urbnum);
44749 + atomic_inc_unchecked(&urb->dev->urbnum);
44750 usbmon_urb_submit(&hcd->self, urb);
44751
44752 /* NOTE requirements on root-hub callers (usbfs and the hub
44753 @@ -1549,7 +1549,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44754 urb->hcpriv = NULL;
44755 INIT_LIST_HEAD(&urb->urb_list);
44756 atomic_dec(&urb->use_count);
44757 - atomic_dec(&urb->dev->urbnum);
44758 + atomic_dec_unchecked(&urb->dev->urbnum);
44759 if (atomic_read(&urb->reject))
44760 wake_up(&usb_kill_urb_queue);
44761 usb_put_urb(urb);
44762 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44763 index 131f736..99004c3 100644
44764 --- a/drivers/usb/core/message.c
44765 +++ b/drivers/usb/core/message.c
44766 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44767 * method can wait for it to complete. Since you don't have a handle on the
44768 * URB used, you can't cancel the request.
44769 */
44770 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44771 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44772 __u8 requesttype, __u16 value, __u16 index, void *data,
44773 __u16 size, int timeout)
44774 {
44775 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44776 index 818e4a0..0fc9589 100644
44777 --- a/drivers/usb/core/sysfs.c
44778 +++ b/drivers/usb/core/sysfs.c
44779 @@ -226,7 +226,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44780 struct usb_device *udev;
44781
44782 udev = to_usb_device(dev);
44783 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44784 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44785 }
44786 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44787
44788 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44789 index f81b925..78d22ec 100644
44790 --- a/drivers/usb/core/usb.c
44791 +++ b/drivers/usb/core/usb.c
44792 @@ -388,7 +388,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44793 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44794 dev->state = USB_STATE_ATTACHED;
44795 dev->lpm_disable_count = 1;
44796 - atomic_set(&dev->urbnum, 0);
44797 + atomic_set_unchecked(&dev->urbnum, 0);
44798
44799 INIT_LIST_HEAD(&dev->ep0.urb_list);
44800 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44801 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44802 index 5e29dde..eca992f 100644
44803 --- a/drivers/usb/early/ehci-dbgp.c
44804 +++ b/drivers/usb/early/ehci-dbgp.c
44805 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44806
44807 #ifdef CONFIG_KGDB
44808 static struct kgdb_io kgdbdbgp_io_ops;
44809 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44810 +static struct kgdb_io kgdbdbgp_io_ops_console;
44811 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44812 #else
44813 #define dbgp_kgdb_mode (0)
44814 #endif
44815 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44816 .write_char = kgdbdbgp_write_char,
44817 };
44818
44819 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44820 + .name = "kgdbdbgp",
44821 + .read_char = kgdbdbgp_read_char,
44822 + .write_char = kgdbdbgp_write_char,
44823 + .is_console = 1
44824 +};
44825 +
44826 static int kgdbdbgp_wait_time;
44827
44828 static int __init kgdbdbgp_parse_config(char *str)
44829 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44830 ptr++;
44831 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44832 }
44833 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44834 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44835 + if (early_dbgp_console.index != -1)
44836 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44837 + else
44838 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44839
44840 return 0;
44841 }
44842 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44843 index 598dcc1..032dd4f 100644
44844 --- a/drivers/usb/gadget/u_serial.c
44845 +++ b/drivers/usb/gadget/u_serial.c
44846 @@ -735,9 +735,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44847 spin_lock_irq(&port->port_lock);
44848
44849 /* already open? Great. */
44850 - if (port->port.count) {
44851 + if (atomic_read(&port->port.count)) {
44852 status = 0;
44853 - port->port.count++;
44854 + atomic_inc(&port->port.count);
44855
44856 /* currently opening/closing? wait ... */
44857 } else if (port->openclose) {
44858 @@ -796,7 +796,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44859 tty->driver_data = port;
44860 port->port.tty = tty;
44861
44862 - port->port.count = 1;
44863 + atomic_set(&port->port.count, 1);
44864 port->openclose = false;
44865
44866 /* if connected, start the I/O stream */
44867 @@ -838,11 +838,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44868
44869 spin_lock_irq(&port->port_lock);
44870
44871 - if (port->port.count != 1) {
44872 - if (port->port.count == 0)
44873 + if (atomic_read(&port->port.count) != 1) {
44874 + if (atomic_read(&port->port.count) == 0)
44875 WARN_ON(1);
44876 else
44877 - --port->port.count;
44878 + atomic_dec(&port->port.count);
44879 goto exit;
44880 }
44881
44882 @@ -852,7 +852,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44883 * and sleep if necessary
44884 */
44885 port->openclose = true;
44886 - port->port.count = 0;
44887 + atomic_set(&port->port.count, 0);
44888
44889 gser = port->port_usb;
44890 if (gser && gser->disconnect)
44891 @@ -1159,7 +1159,7 @@ static int gs_closed(struct gs_port *port)
44892 int cond;
44893
44894 spin_lock_irq(&port->port_lock);
44895 - cond = (port->port.count == 0) && !port->openclose;
44896 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44897 spin_unlock_irq(&port->port_lock);
44898 return cond;
44899 }
44900 @@ -1273,7 +1273,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44901 /* if it's already open, start I/O ... and notify the serial
44902 * protocol about open/close status (connect/disconnect).
44903 */
44904 - if (port->port.count) {
44905 + if (atomic_read(&port->port.count)) {
44906 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44907 gs_start_io(port);
44908 if (gser->connect)
44909 @@ -1320,7 +1320,7 @@ void gserial_disconnect(struct gserial *gser)
44910
44911 port->port_usb = NULL;
44912 gser->ioport = NULL;
44913 - if (port->port.count > 0 || port->openclose) {
44914 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44915 wake_up_interruptible(&port->drain_wait);
44916 if (port->port.tty)
44917 tty_hangup(port->port.tty);
44918 @@ -1336,7 +1336,7 @@ void gserial_disconnect(struct gserial *gser)
44919
44920 /* finally, free any unused/unusable I/O buffers */
44921 spin_lock_irqsave(&port->port_lock, flags);
44922 - if (port->port.count == 0 && !port->openclose)
44923 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44924 gs_buf_free(&port->port_write_buf);
44925 gs_free_requests(gser->out, &port->read_pool, NULL);
44926 gs_free_requests(gser->out, &port->read_queue, NULL);
44927 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44928 index 5f3bcd3..bfca43f 100644
44929 --- a/drivers/usb/serial/console.c
44930 +++ b/drivers/usb/serial/console.c
44931 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44932
44933 info->port = port;
44934
44935 - ++port->port.count;
44936 + atomic_inc(&port->port.count);
44937 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44938 if (serial->type->set_termios) {
44939 /*
44940 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44941 }
44942 /* Now that any required fake tty operations are completed restore
44943 * the tty port count */
44944 - --port->port.count;
44945 + atomic_dec(&port->port.count);
44946 /* The console is special in terms of closing the device so
44947 * indicate this port is now acting as a system console. */
44948 port->port.console = 1;
44949 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44950 free_tty:
44951 kfree(tty);
44952 reset_open_count:
44953 - port->port.count = 0;
44954 + atomic_set(&port->port.count, 0);
44955 usb_autopm_put_interface(serial->interface);
44956 error_get_interface:
44957 usb_serial_put(serial);
44958 diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
44959 index 6c3586a..a94e621 100644
44960 --- a/drivers/usb/storage/realtek_cr.c
44961 +++ b/drivers/usb/storage/realtek_cr.c
44962 @@ -429,7 +429,7 @@ static int rts51x_read_status(struct us_data *us,
44963
44964 buf = kmalloc(len, GFP_NOIO);
44965 if (buf == NULL)
44966 - return USB_STOR_TRANSPORT_ERROR;
44967 + return -ENOMEM;
44968
44969 US_DEBUGP("%s, lun = %d\n", __func__, lun);
44970
44971 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44972 index 75f70f0..d467e1a 100644
44973 --- a/drivers/usb/storage/usb.h
44974 +++ b/drivers/usb/storage/usb.h
44975 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44976 __u8 useProtocol;
44977 __u8 useTransport;
44978 int (*initFunction)(struct us_data *);
44979 -};
44980 +} __do_const;
44981
44982
44983 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44984 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44985 index d6bea3e..60b250e 100644
44986 --- a/drivers/usb/wusbcore/wa-hc.h
44987 +++ b/drivers/usb/wusbcore/wa-hc.h
44988 @@ -192,7 +192,7 @@ struct wahc {
44989 struct list_head xfer_delayed_list;
44990 spinlock_t xfer_list_lock;
44991 struct work_struct xfer_work;
44992 - atomic_t xfer_id_count;
44993 + atomic_unchecked_t xfer_id_count;
44994 };
44995
44996
44997 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44998 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44999 spin_lock_init(&wa->xfer_list_lock);
45000 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
45001 - atomic_set(&wa->xfer_id_count, 1);
45002 + atomic_set_unchecked(&wa->xfer_id_count, 1);
45003 }
45004
45005 /**
45006 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
45007 index 57c01ab..8a05959 100644
45008 --- a/drivers/usb/wusbcore/wa-xfer.c
45009 +++ b/drivers/usb/wusbcore/wa-xfer.c
45010 @@ -296,7 +296,7 @@ out:
45011 */
45012 static void wa_xfer_id_init(struct wa_xfer *xfer)
45013 {
45014 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
45015 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
45016 }
45017
45018 /*
45019 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
45020 index 8c55011..eed4ae1a 100644
45021 --- a/drivers/video/aty/aty128fb.c
45022 +++ b/drivers/video/aty/aty128fb.c
45023 @@ -149,7 +149,7 @@ enum {
45024 };
45025
45026 /* Must match above enum */
45027 -static char * const r128_family[] = {
45028 +static const char * const r128_family[] = {
45029 "AGP",
45030 "PCI",
45031 "PRO AGP",
45032 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
45033 index 4f27fdc..d3537e6 100644
45034 --- a/drivers/video/aty/atyfb_base.c
45035 +++ b/drivers/video/aty/atyfb_base.c
45036 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
45037 par->accel_flags = var->accel_flags; /* hack */
45038
45039 if (var->accel_flags) {
45040 - info->fbops->fb_sync = atyfb_sync;
45041 + pax_open_kernel();
45042 + *(void **)&info->fbops->fb_sync = atyfb_sync;
45043 + pax_close_kernel();
45044 info->flags &= ~FBINFO_HWACCEL_DISABLED;
45045 } else {
45046 - info->fbops->fb_sync = NULL;
45047 + pax_open_kernel();
45048 + *(void **)&info->fbops->fb_sync = NULL;
45049 + pax_close_kernel();
45050 info->flags |= FBINFO_HWACCEL_DISABLED;
45051 }
45052
45053 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
45054 index 95ec042..e6affdd 100644
45055 --- a/drivers/video/aty/mach64_cursor.c
45056 +++ b/drivers/video/aty/mach64_cursor.c
45057 @@ -7,6 +7,7 @@
45058 #include <linux/string.h>
45059
45060 #include <asm/io.h>
45061 +#include <asm/pgtable.h>
45062
45063 #ifdef __sparc__
45064 #include <asm/fbio.h>
45065 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
45066 info->sprite.buf_align = 16; /* and 64 lines tall. */
45067 info->sprite.flags = FB_PIXMAP_IO;
45068
45069 - info->fbops->fb_cursor = atyfb_cursor;
45070 + pax_open_kernel();
45071 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
45072 + pax_close_kernel();
45073
45074 return 0;
45075 }
45076 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
45077 index 6c5ed6b..b727c88 100644
45078 --- a/drivers/video/backlight/kb3886_bl.c
45079 +++ b/drivers/video/backlight/kb3886_bl.c
45080 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
45081 static unsigned long kb3886bl_flags;
45082 #define KB3886BL_SUSPENDED 0x01
45083
45084 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
45085 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
45086 {
45087 .ident = "Sahara Touch-iT",
45088 .matches = {
45089 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
45090 index 88cad6b..dd746c7 100644
45091 --- a/drivers/video/fb_defio.c
45092 +++ b/drivers/video/fb_defio.c
45093 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
45094
45095 BUG_ON(!fbdefio);
45096 mutex_init(&fbdefio->lock);
45097 - info->fbops->fb_mmap = fb_deferred_io_mmap;
45098 + pax_open_kernel();
45099 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
45100 + pax_close_kernel();
45101 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
45102 INIT_LIST_HEAD(&fbdefio->pagelist);
45103 if (fbdefio->delay == 0) /* set a default of 1 s */
45104 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
45105 page->mapping = NULL;
45106 }
45107
45108 - info->fbops->fb_mmap = NULL;
45109 + *(void **)&info->fbops->fb_mmap = NULL;
45110 mutex_destroy(&fbdefio->lock);
45111 }
45112 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
45113 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
45114 index 5c3960d..15cf8fc 100644
45115 --- a/drivers/video/fbcmap.c
45116 +++ b/drivers/video/fbcmap.c
45117 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
45118 rc = -ENODEV;
45119 goto out;
45120 }
45121 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
45122 - !info->fbops->fb_setcmap)) {
45123 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45124 rc = -EINVAL;
45125 goto out1;
45126 }
45127 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45128 index dc61c12..e29796e 100644
45129 --- a/drivers/video/fbmem.c
45130 +++ b/drivers/video/fbmem.c
45131 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45132 image->dx += image->width + 8;
45133 }
45134 } else if (rotate == FB_ROTATE_UD) {
45135 - for (x = 0; x < num && image->dx >= 0; x++) {
45136 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45137 info->fbops->fb_imageblit(info, image);
45138 image->dx -= image->width + 8;
45139 }
45140 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45141 image->dy += image->height + 8;
45142 }
45143 } else if (rotate == FB_ROTATE_CCW) {
45144 - for (x = 0; x < num && image->dy >= 0; x++) {
45145 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45146 info->fbops->fb_imageblit(info, image);
45147 image->dy -= image->height + 8;
45148 }
45149 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45150 return -EFAULT;
45151 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45152 return -EINVAL;
45153 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45154 + if (con2fb.framebuffer >= FB_MAX)
45155 return -EINVAL;
45156 if (!registered_fb[con2fb.framebuffer])
45157 request_module("fb%d", con2fb.framebuffer);
45158 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45159 index 7672d2e..b56437f 100644
45160 --- a/drivers/video/i810/i810_accel.c
45161 +++ b/drivers/video/i810/i810_accel.c
45162 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45163 }
45164 }
45165 printk("ringbuffer lockup!!!\n");
45166 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45167 i810_report_error(mmio);
45168 par->dev_flags |= LOCKUP;
45169 info->pixmap.scan_align = 1;
45170 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45171 index 3c14e43..eafa544 100644
45172 --- a/drivers/video/logo/logo_linux_clut224.ppm
45173 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45174 @@ -1,1604 +1,1123 @@
45175 P3
45176 -# Standard 224-color Linux logo
45177 80 80
45178 255
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 0 0 0 0 0 0 0 0 0 0 0 0
45183 - 0 0 0 0 0 0 0 0 0 0 0 0
45184 - 0 0 0 0 0 0 0 0 0 0 0 0
45185 - 0 0 0 0 0 0 0 0 0 0 0 0
45186 - 0 0 0 0 0 0 0 0 0 0 0 0
45187 - 0 0 0 0 0 0 0 0 0 0 0 0
45188 - 6 6 6 6 6 6 10 10 10 10 10 10
45189 - 10 10 10 6 6 6 6 6 6 6 6 6
45190 - 0 0 0 0 0 0 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 0 0 0 0 0 0 0 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 0 0 0 0 0 0 0 0 0 0 0 0
45203 - 0 0 0 0 0 0 0 0 0 0 0 0
45204 - 0 0 0 0 0 0 0 0 0 0 0 0
45205 - 0 0 0 0 0 0 0 0 0 0 0 0
45206 - 0 0 0 0 0 0 0 0 0 0 0 0
45207 - 0 0 0 6 6 6 10 10 10 14 14 14
45208 - 22 22 22 26 26 26 30 30 30 34 34 34
45209 - 30 30 30 30 30 30 26 26 26 18 18 18
45210 - 14 14 14 10 10 10 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 1 0 0 1 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 - 6 6 6 14 14 14 26 26 26 42 42 42
45228 - 54 54 54 66 66 66 78 78 78 78 78 78
45229 - 78 78 78 74 74 74 66 66 66 54 54 54
45230 - 42 42 42 26 26 26 18 18 18 10 10 10
45231 - 6 6 6 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 1 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 10 10 10
45247 - 22 22 22 42 42 42 66 66 66 86 86 86
45248 - 66 66 66 38 38 38 38 38 38 22 22 22
45249 - 26 26 26 34 34 34 54 54 54 66 66 66
45250 - 86 86 86 70 70 70 46 46 46 26 26 26
45251 - 14 14 14 6 6 6 0 0 0 0 0 0
45252 - 0 0 0 0 0 0 0 0 0 0 0 0
45253 - 0 0 0 0 0 0 0 0 0 0 0 0
45254 - 0 0 0 0 0 0 0 0 0 0 0 0
45255 - 0 0 0 0 0 0 0 0 0 0 0 0
45256 - 0 0 0 0 0 0 0 0 0 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 1 0 0 1 0 0 1 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 10 10 10 26 26 26
45267 - 50 50 50 82 82 82 58 58 58 6 6 6
45268 - 2 2 6 2 2 6 2 2 6 2 2 6
45269 - 2 2 6 2 2 6 2 2 6 2 2 6
45270 - 6 6 6 54 54 54 86 86 86 66 66 66
45271 - 38 38 38 18 18 18 6 6 6 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 0 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 0 0 0
45282 - 0 0 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 6 6 6 22 22 22 50 50 50
45287 - 78 78 78 34 34 34 2 2 6 2 2 6
45288 - 2 2 6 2 2 6 2 2 6 2 2 6
45289 - 2 2 6 2 2 6 2 2 6 2 2 6
45290 - 2 2 6 2 2 6 6 6 6 70 70 70
45291 - 78 78 78 46 46 46 22 22 22 6 6 6
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 0 0 0 0 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 1 0 0 1 0 0 1 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 - 6 6 6 18 18 18 42 42 42 82 82 82
45307 - 26 26 26 2 2 6 2 2 6 2 2 6
45308 - 2 2 6 2 2 6 2 2 6 2 2 6
45309 - 2 2 6 2 2 6 2 2 6 14 14 14
45310 - 46 46 46 34 34 34 6 6 6 2 2 6
45311 - 42 42 42 78 78 78 42 42 42 18 18 18
45312 - 6 6 6 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 0 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 1 0 0 0 0 0 1 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 - 10 10 10 30 30 30 66 66 66 58 58 58
45327 - 2 2 6 2 2 6 2 2 6 2 2 6
45328 - 2 2 6 2 2 6 2 2 6 2 2 6
45329 - 2 2 6 2 2 6 2 2 6 26 26 26
45330 - 86 86 86 101 101 101 46 46 46 10 10 10
45331 - 2 2 6 58 58 58 70 70 70 34 34 34
45332 - 10 10 10 0 0 0 0 0 0 0 0 0
45333 - 0 0 0 0 0 0 0 0 0 0 0 0
45334 - 0 0 0 0 0 0 0 0 0 0 0 0
45335 - 0 0 0 0 0 0 0 0 0 0 0 0
45336 - 0 0 0 0 0 0 0 0 0 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 1 0 0 1 0 0 1 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 - 14 14 14 42 42 42 86 86 86 10 10 10
45347 - 2 2 6 2 2 6 2 2 6 2 2 6
45348 - 2 2 6 2 2 6 2 2 6 2 2 6
45349 - 2 2 6 2 2 6 2 2 6 30 30 30
45350 - 94 94 94 94 94 94 58 58 58 26 26 26
45351 - 2 2 6 6 6 6 78 78 78 54 54 54
45352 - 22 22 22 6 6 6 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 0 0 0
45362 - 0 0 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 6 6 6
45366 - 22 22 22 62 62 62 62 62 62 2 2 6
45367 - 2 2 6 2 2 6 2 2 6 2 2 6
45368 - 2 2 6 2 2 6 2 2 6 2 2 6
45369 - 2 2 6 2 2 6 2 2 6 26 26 26
45370 - 54 54 54 38 38 38 18 18 18 10 10 10
45371 - 2 2 6 2 2 6 34 34 34 82 82 82
45372 - 38 38 38 14 14 14 0 0 0 0 0 0
45373 - 0 0 0 0 0 0 0 0 0 0 0 0
45374 - 0 0 0 0 0 0 0 0 0 0 0 0
45375 - 0 0 0 0 0 0 0 0 0 0 0 0
45376 - 0 0 0 0 0 0 0 0 0 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 1 0 0 1 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 6 6 6
45386 - 30 30 30 78 78 78 30 30 30 2 2 6
45387 - 2 2 6 2 2 6 2 2 6 2 2 6
45388 - 2 2 6 2 2 6 2 2 6 2 2 6
45389 - 2 2 6 2 2 6 2 2 6 10 10 10
45390 - 10 10 10 2 2 6 2 2 6 2 2 6
45391 - 2 2 6 2 2 6 2 2 6 78 78 78
45392 - 50 50 50 18 18 18 6 6 6 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 1 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 0 0 0
45402 - 0 0 0 0 0 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 10 10 10
45406 - 38 38 38 86 86 86 14 14 14 2 2 6
45407 - 2 2 6 2 2 6 2 2 6 2 2 6
45408 - 2 2 6 2 2 6 2 2 6 2 2 6
45409 - 2 2 6 2 2 6 2 2 6 2 2 6
45410 - 2 2 6 2 2 6 2 2 6 2 2 6
45411 - 2 2 6 2 2 6 2 2 6 54 54 54
45412 - 66 66 66 26 26 26 6 6 6 0 0 0
45413 - 0 0 0 0 0 0 0 0 0 0 0 0
45414 - 0 0 0 0 0 0 0 0 0 0 0 0
45415 - 0 0 0 0 0 0 0 0 0 0 0 0
45416 - 0 0 0 0 0 0 0 0 0 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 1 0 0 1 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 14 14 14
45426 - 42 42 42 82 82 82 2 2 6 2 2 6
45427 - 2 2 6 6 6 6 10 10 10 2 2 6
45428 - 2 2 6 2 2 6 2 2 6 2 2 6
45429 - 2 2 6 2 2 6 2 2 6 6 6 6
45430 - 14 14 14 10 10 10 2 2 6 2 2 6
45431 - 2 2 6 2 2 6 2 2 6 18 18 18
45432 - 82 82 82 34 34 34 10 10 10 0 0 0
45433 - 0 0 0 0 0 0 0 0 0 0 0 0
45434 - 0 0 0 0 0 0 0 0 0 0 0 0
45435 - 0 0 0 0 0 0 0 0 0 0 0 0
45436 - 0 0 0 0 0 0 0 0 0 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 1 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 0 0 0
45442 - 0 0 0 0 0 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 14 14 14
45446 - 46 46 46 86 86 86 2 2 6 2 2 6
45447 - 6 6 6 6 6 6 22 22 22 34 34 34
45448 - 6 6 6 2 2 6 2 2 6 2 2 6
45449 - 2 2 6 2 2 6 18 18 18 34 34 34
45450 - 10 10 10 50 50 50 22 22 22 2 2 6
45451 - 2 2 6 2 2 6 2 2 6 10 10 10
45452 - 86 86 86 42 42 42 14 14 14 0 0 0
45453 - 0 0 0 0 0 0 0 0 0 0 0 0
45454 - 0 0 0 0 0 0 0 0 0 0 0 0
45455 - 0 0 0 0 0 0 0 0 0 0 0 0
45456 - 0 0 0 0 0 0 0 0 0 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45466 - 46 46 46 86 86 86 2 2 6 2 2 6
45467 - 38 38 38 116 116 116 94 94 94 22 22 22
45468 - 22 22 22 2 2 6 2 2 6 2 2 6
45469 - 14 14 14 86 86 86 138 138 138 162 162 162
45470 -154 154 154 38 38 38 26 26 26 6 6 6
45471 - 2 2 6 2 2 6 2 2 6 2 2 6
45472 - 86 86 86 46 46 46 14 14 14 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 0 0 0
45482 - 0 0 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 14 14 14
45486 - 46 46 46 86 86 86 2 2 6 14 14 14
45487 -134 134 134 198 198 198 195 195 195 116 116 116
45488 - 10 10 10 2 2 6 2 2 6 6 6 6
45489 -101 98 89 187 187 187 210 210 210 218 218 218
45490 -214 214 214 134 134 134 14 14 14 6 6 6
45491 - 2 2 6 2 2 6 2 2 6 2 2 6
45492 - 86 86 86 50 50 50 18 18 18 6 6 6
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 1 0 0 0
45500 - 0 0 1 0 0 1 0 0 1 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 14 14 14
45506 - 46 46 46 86 86 86 2 2 6 54 54 54
45507 -218 218 218 195 195 195 226 226 226 246 246 246
45508 - 58 58 58 2 2 6 2 2 6 30 30 30
45509 -210 210 210 253 253 253 174 174 174 123 123 123
45510 -221 221 221 234 234 234 74 74 74 2 2 6
45511 - 2 2 6 2 2 6 2 2 6 2 2 6
45512 - 70 70 70 58 58 58 22 22 22 6 6 6
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 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 14 14 14
45526 - 46 46 46 82 82 82 2 2 6 106 106 106
45527 -170 170 170 26 26 26 86 86 86 226 226 226
45528 -123 123 123 10 10 10 14 14 14 46 46 46
45529 -231 231 231 190 190 190 6 6 6 70 70 70
45530 - 90 90 90 238 238 238 158 158 158 2 2 6
45531 - 2 2 6 2 2 6 2 2 6 2 2 6
45532 - 70 70 70 58 58 58 22 22 22 6 6 6
45533 - 0 0 0 0 0 0 0 0 0 0 0 0
45534 - 0 0 0 0 0 0 0 0 0 0 0 0
45535 - 0 0 0 0 0 0 0 0 0 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 1 0 0 0
45540 - 0 0 1 0 0 1 0 0 1 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 0 0 0
45542 - 0 0 0 0 0 0 0 0 0 0 0 0
45543 - 0 0 0 0 0 0 0 0 0 0 0 0
45544 - 0 0 0 0 0 0 0 0 0 0 0 0
45545 - 0 0 0 0 0 0 0 0 0 14 14 14
45546 - 42 42 42 86 86 86 6 6 6 116 116 116
45547 -106 106 106 6 6 6 70 70 70 149 149 149
45548 -128 128 128 18 18 18 38 38 38 54 54 54
45549 -221 221 221 106 106 106 2 2 6 14 14 14
45550 - 46 46 46 190 190 190 198 198 198 2 2 6
45551 - 2 2 6 2 2 6 2 2 6 2 2 6
45552 - 74 74 74 62 62 62 22 22 22 6 6 6
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 1 0 0 0
45560 - 0 0 1 0 0 0 0 0 1 0 0 0
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 14 14 14
45566 - 42 42 42 94 94 94 14 14 14 101 101 101
45567 -128 128 128 2 2 6 18 18 18 116 116 116
45568 -118 98 46 121 92 8 121 92 8 98 78 10
45569 -162 162 162 106 106 106 2 2 6 2 2 6
45570 - 2 2 6 195 195 195 195 195 195 6 6 6
45571 - 2 2 6 2 2 6 2 2 6 2 2 6
45572 - 74 74 74 62 62 62 22 22 22 6 6 6
45573 - 0 0 0 0 0 0 0 0 0 0 0 0
45574 - 0 0 0 0 0 0 0 0 0 0 0 0
45575 - 0 0 0 0 0 0 0 0 0 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 1 0 0 1
45580 - 0 0 1 0 0 0 0 0 1 0 0 0
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 10 10 10
45586 - 38 38 38 90 90 90 14 14 14 58 58 58
45587 -210 210 210 26 26 26 54 38 6 154 114 10
45588 -226 170 11 236 186 11 225 175 15 184 144 12
45589 -215 174 15 175 146 61 37 26 9 2 2 6
45590 - 70 70 70 246 246 246 138 138 138 2 2 6
45591 - 2 2 6 2 2 6 2 2 6 2 2 6
45592 - 70 70 70 66 66 66 26 26 26 6 6 6
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 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 10 10 10
45606 - 38 38 38 86 86 86 14 14 14 10 10 10
45607 -195 195 195 188 164 115 192 133 9 225 175 15
45608 -239 182 13 234 190 10 232 195 16 232 200 30
45609 -245 207 45 241 208 19 232 195 16 184 144 12
45610 -218 194 134 211 206 186 42 42 42 2 2 6
45611 - 2 2 6 2 2 6 2 2 6 2 2 6
45612 - 50 50 50 74 74 74 30 30 30 6 6 6
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 0 0 0 0 0 0
45622 - 0 0 0 0 0 0 0 0 0 0 0 0
45623 - 0 0 0 0 0 0 0 0 0 0 0 0
45624 - 0 0 0 0 0 0 0 0 0 0 0 0
45625 - 0 0 0 0 0 0 0 0 0 10 10 10
45626 - 34 34 34 86 86 86 14 14 14 2 2 6
45627 -121 87 25 192 133 9 219 162 10 239 182 13
45628 -236 186 11 232 195 16 241 208 19 244 214 54
45629 -246 218 60 246 218 38 246 215 20 241 208 19
45630 -241 208 19 226 184 13 121 87 25 2 2 6
45631 - 2 2 6 2 2 6 2 2 6 2 2 6
45632 - 50 50 50 82 82 82 34 34 34 10 10 10
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 0 0 0 0 0 0
45642 - 0 0 0 0 0 0 0 0 0 0 0 0
45643 - 0 0 0 0 0 0 0 0 0 0 0 0
45644 - 0 0 0 0 0 0 0 0 0 0 0 0
45645 - 0 0 0 0 0 0 0 0 0 10 10 10
45646 - 34 34 34 82 82 82 30 30 30 61 42 6
45647 -180 123 7 206 145 10 230 174 11 239 182 13
45648 -234 190 10 238 202 15 241 208 19 246 218 74
45649 -246 218 38 246 215 20 246 215 20 246 215 20
45650 -226 184 13 215 174 15 184 144 12 6 6 6
45651 - 2 2 6 2 2 6 2 2 6 2 2 6
45652 - 26 26 26 94 94 94 42 42 42 14 14 14
45653 - 0 0 0 0 0 0 0 0 0 0 0 0
45654 - 0 0 0 0 0 0 0 0 0 0 0 0
45655 - 0 0 0 0 0 0 0 0 0 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 0 0 0 0 0 0 0 0 0
45662 - 0 0 0 0 0 0 0 0 0 0 0 0
45663 - 0 0 0 0 0 0 0 0 0 0 0 0
45664 - 0 0 0 0 0 0 0 0 0 0 0 0
45665 - 0 0 0 0 0 0 0 0 0 10 10 10
45666 - 30 30 30 78 78 78 50 50 50 104 69 6
45667 -192 133 9 216 158 10 236 178 12 236 186 11
45668 -232 195 16 241 208 19 244 214 54 245 215 43
45669 -246 215 20 246 215 20 241 208 19 198 155 10
45670 -200 144 11 216 158 10 156 118 10 2 2 6
45671 - 2 2 6 2 2 6 2 2 6 2 2 6
45672 - 6 6 6 90 90 90 54 54 54 18 18 18
45673 - 6 6 6 0 0 0 0 0 0 0 0 0
45674 - 0 0 0 0 0 0 0 0 0 0 0 0
45675 - 0 0 0 0 0 0 0 0 0 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 0 0 0 0 0 0 0 0 0 0 0 0
45682 - 0 0 0 0 0 0 0 0 0 0 0 0
45683 - 0 0 0 0 0 0 0 0 0 0 0 0
45684 - 0 0 0 0 0 0 0 0 0 0 0 0
45685 - 0 0 0 0 0 0 0 0 0 10 10 10
45686 - 30 30 30 78 78 78 46 46 46 22 22 22
45687 -137 92 6 210 162 10 239 182 13 238 190 10
45688 -238 202 15 241 208 19 246 215 20 246 215 20
45689 -241 208 19 203 166 17 185 133 11 210 150 10
45690 -216 158 10 210 150 10 102 78 10 2 2 6
45691 - 6 6 6 54 54 54 14 14 14 2 2 6
45692 - 2 2 6 62 62 62 74 74 74 30 30 30
45693 - 10 10 10 0 0 0 0 0 0 0 0 0
45694 - 0 0 0 0 0 0 0 0 0 0 0 0
45695 - 0 0 0 0 0 0 0 0 0 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 0 0 0
45701 - 0 0 0 0 0 0 0 0 0 0 0 0
45702 - 0 0 0 0 0 0 0 0 0 0 0 0
45703 - 0 0 0 0 0 0 0 0 0 0 0 0
45704 - 0 0 0 0 0 0 0 0 0 0 0 0
45705 - 0 0 0 0 0 0 0 0 0 10 10 10
45706 - 34 34 34 78 78 78 50 50 50 6 6 6
45707 - 94 70 30 139 102 15 190 146 13 226 184 13
45708 -232 200 30 232 195 16 215 174 15 190 146 13
45709 -168 122 10 192 133 9 210 150 10 213 154 11
45710 -202 150 34 182 157 106 101 98 89 2 2 6
45711 - 2 2 6 78 78 78 116 116 116 58 58 58
45712 - 2 2 6 22 22 22 90 90 90 46 46 46
45713 - 18 18 18 6 6 6 0 0 0 0 0 0
45714 - 0 0 0 0 0 0 0 0 0 0 0 0
45715 - 0 0 0 0 0 0 0 0 0 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 0 0 0
45721 - 0 0 0 0 0 0 0 0 0 0 0 0
45722 - 0 0 0 0 0 0 0 0 0 0 0 0
45723 - 0 0 0 0 0 0 0 0 0 0 0 0
45724 - 0 0 0 0 0 0 0 0 0 0 0 0
45725 - 0 0 0 0 0 0 0 0 0 10 10 10
45726 - 38 38 38 86 86 86 50 50 50 6 6 6
45727 -128 128 128 174 154 114 156 107 11 168 122 10
45728 -198 155 10 184 144 12 197 138 11 200 144 11
45729 -206 145 10 206 145 10 197 138 11 188 164 115
45730 -195 195 195 198 198 198 174 174 174 14 14 14
45731 - 2 2 6 22 22 22 116 116 116 116 116 116
45732 - 22 22 22 2 2 6 74 74 74 70 70 70
45733 - 30 30 30 10 10 10 0 0 0 0 0 0
45734 - 0 0 0 0 0 0 0 0 0 0 0 0
45735 - 0 0 0 0 0 0 0 0 0 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 0 0 0 0 0 0
45741 - 0 0 0 0 0 0 0 0 0 0 0 0
45742 - 0 0 0 0 0 0 0 0 0 0 0 0
45743 - 0 0 0 0 0 0 0 0 0 0 0 0
45744 - 0 0 0 0 0 0 0 0 0 0 0 0
45745 - 0 0 0 0 0 0 6 6 6 18 18 18
45746 - 50 50 50 101 101 101 26 26 26 10 10 10
45747 -138 138 138 190 190 190 174 154 114 156 107 11
45748 -197 138 11 200 144 11 197 138 11 192 133 9
45749 -180 123 7 190 142 34 190 178 144 187 187 187
45750 -202 202 202 221 221 221 214 214 214 66 66 66
45751 - 2 2 6 2 2 6 50 50 50 62 62 62
45752 - 6 6 6 2 2 6 10 10 10 90 90 90
45753 - 50 50 50 18 18 18 6 6 6 0 0 0
45754 - 0 0 0 0 0 0 0 0 0 0 0 0
45755 - 0 0 0 0 0 0 0 0 0 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 0 0 0 0 0 0 0 0 0
45761 - 0 0 0 0 0 0 0 0 0 0 0 0
45762 - 0 0 0 0 0 0 0 0 0 0 0 0
45763 - 0 0 0 0 0 0 0 0 0 0 0 0
45764 - 0 0 0 0 0 0 0 0 0 0 0 0
45765 - 0 0 0 0 0 0 10 10 10 34 34 34
45766 - 74 74 74 74 74 74 2 2 6 6 6 6
45767 -144 144 144 198 198 198 190 190 190 178 166 146
45768 -154 121 60 156 107 11 156 107 11 168 124 44
45769 -174 154 114 187 187 187 190 190 190 210 210 210
45770 -246 246 246 253 253 253 253 253 253 182 182 182
45771 - 6 6 6 2 2 6 2 2 6 2 2 6
45772 - 2 2 6 2 2 6 2 2 6 62 62 62
45773 - 74 74 74 34 34 34 14 14 14 0 0 0
45774 - 0 0 0 0 0 0 0 0 0 0 0 0
45775 - 0 0 0 0 0 0 0 0 0 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 0 0 0 0 0 0 0 0 0 0 0 0
45781 - 0 0 0 0 0 0 0 0 0 0 0 0
45782 - 0 0 0 0 0 0 0 0 0 0 0 0
45783 - 0 0 0 0 0 0 0 0 0 0 0 0
45784 - 0 0 0 0 0 0 0 0 0 0 0 0
45785 - 0 0 0 10 10 10 22 22 22 54 54 54
45786 - 94 94 94 18 18 18 2 2 6 46 46 46
45787 -234 234 234 221 221 221 190 190 190 190 190 190
45788 -190 190 190 187 187 187 187 187 187 190 190 190
45789 -190 190 190 195 195 195 214 214 214 242 242 242
45790 -253 253 253 253 253 253 253 253 253 253 253 253
45791 - 82 82 82 2 2 6 2 2 6 2 2 6
45792 - 2 2 6 2 2 6 2 2 6 14 14 14
45793 - 86 86 86 54 54 54 22 22 22 6 6 6
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 0 0 0 0 0 0 0 0 0 0 0 0
45801 - 0 0 0 0 0 0 0 0 0 0 0 0
45802 - 0 0 0 0 0 0 0 0 0 0 0 0
45803 - 0 0 0 0 0 0 0 0 0 0 0 0
45804 - 0 0 0 0 0 0 0 0 0 0 0 0
45805 - 6 6 6 18 18 18 46 46 46 90 90 90
45806 - 46 46 46 18 18 18 6 6 6 182 182 182
45807 -253 253 253 246 246 246 206 206 206 190 190 190
45808 -190 190 190 190 190 190 190 190 190 190 190 190
45809 -206 206 206 231 231 231 250 250 250 253 253 253
45810 -253 253 253 253 253 253 253 253 253 253 253 253
45811 -202 202 202 14 14 14 2 2 6 2 2 6
45812 - 2 2 6 2 2 6 2 2 6 2 2 6
45813 - 42 42 42 86 86 86 42 42 42 18 18 18
45814 - 6 6 6 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 0 0 0 0 0 0 0 0 0 0 0 0
45821 - 0 0 0 0 0 0 0 0 0 0 0 0
45822 - 0 0 0 0 0 0 0 0 0 0 0 0
45823 - 0 0 0 0 0 0 0 0 0 0 0 0
45824 - 0 0 0 0 0 0 0 0 0 6 6 6
45825 - 14 14 14 38 38 38 74 74 74 66 66 66
45826 - 2 2 6 6 6 6 90 90 90 250 250 250
45827 -253 253 253 253 253 253 238 238 238 198 198 198
45828 -190 190 190 190 190 190 195 195 195 221 221 221
45829 -246 246 246 253 253 253 253 253 253 253 253 253
45830 -253 253 253 253 253 253 253 253 253 253 253 253
45831 -253 253 253 82 82 82 2 2 6 2 2 6
45832 - 2 2 6 2 2 6 2 2 6 2 2 6
45833 - 2 2 6 78 78 78 70 70 70 34 34 34
45834 - 14 14 14 6 6 6 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 0 0 0
45840 - 0 0 0 0 0 0 0 0 0 0 0 0
45841 - 0 0 0 0 0 0 0 0 0 0 0 0
45842 - 0 0 0 0 0 0 0 0 0 0 0 0
45843 - 0 0 0 0 0 0 0 0 0 0 0 0
45844 - 0 0 0 0 0 0 0 0 0 14 14 14
45845 - 34 34 34 66 66 66 78 78 78 6 6 6
45846 - 2 2 6 18 18 18 218 218 218 253 253 253
45847 -253 253 253 253 253 253 253 253 253 246 246 246
45848 -226 226 226 231 231 231 246 246 246 253 253 253
45849 -253 253 253 253 253 253 253 253 253 253 253 253
45850 -253 253 253 253 253 253 253 253 253 253 253 253
45851 -253 253 253 178 178 178 2 2 6 2 2 6
45852 - 2 2 6 2 2 6 2 2 6 2 2 6
45853 - 2 2 6 18 18 18 90 90 90 62 62 62
45854 - 30 30 30 10 10 10 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 0 0 0
45860 - 0 0 0 0 0 0 0 0 0 0 0 0
45861 - 0 0 0 0 0 0 0 0 0 0 0 0
45862 - 0 0 0 0 0 0 0 0 0 0 0 0
45863 - 0 0 0 0 0 0 0 0 0 0 0 0
45864 - 0 0 0 0 0 0 10 10 10 26 26 26
45865 - 58 58 58 90 90 90 18 18 18 2 2 6
45866 - 2 2 6 110 110 110 253 253 253 253 253 253
45867 -253 253 253 253 253 253 253 253 253 253 253 253
45868 -250 250 250 253 253 253 253 253 253 253 253 253
45869 -253 253 253 253 253 253 253 253 253 253 253 253
45870 -253 253 253 253 253 253 253 253 253 253 253 253
45871 -253 253 253 231 231 231 18 18 18 2 2 6
45872 - 2 2 6 2 2 6 2 2 6 2 2 6
45873 - 2 2 6 2 2 6 18 18 18 94 94 94
45874 - 54 54 54 26 26 26 10 10 10 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 0 0 0
45880 - 0 0 0 0 0 0 0 0 0 0 0 0
45881 - 0 0 0 0 0 0 0 0 0 0 0 0
45882 - 0 0 0 0 0 0 0 0 0 0 0 0
45883 - 0 0 0 0 0 0 0 0 0 0 0 0
45884 - 0 0 0 6 6 6 22 22 22 50 50 50
45885 - 90 90 90 26 26 26 2 2 6 2 2 6
45886 - 14 14 14 195 195 195 250 250 250 253 253 253
45887 -253 253 253 253 253 253 253 253 253 253 253 253
45888 -253 253 253 253 253 253 253 253 253 253 253 253
45889 -253 253 253 253 253 253 253 253 253 253 253 253
45890 -253 253 253 253 253 253 253 253 253 253 253 253
45891 -250 250 250 242 242 242 54 54 54 2 2 6
45892 - 2 2 6 2 2 6 2 2 6 2 2 6
45893 - 2 2 6 2 2 6 2 2 6 38 38 38
45894 - 86 86 86 50 50 50 22 22 22 6 6 6
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 0 0 0 0 0 0
45900 - 0 0 0 0 0 0 0 0 0 0 0 0
45901 - 0 0 0 0 0 0 0 0 0 0 0 0
45902 - 0 0 0 0 0 0 0 0 0 0 0 0
45903 - 0 0 0 0 0 0 0 0 0 0 0 0
45904 - 6 6 6 14 14 14 38 38 38 82 82 82
45905 - 34 34 34 2 2 6 2 2 6 2 2 6
45906 - 42 42 42 195 195 195 246 246 246 253 253 253
45907 -253 253 253 253 253 253 253 253 253 250 250 250
45908 -242 242 242 242 242 242 250 250 250 253 253 253
45909 -253 253 253 253 253 253 253 253 253 253 253 253
45910 -253 253 253 250 250 250 246 246 246 238 238 238
45911 -226 226 226 231 231 231 101 101 101 6 6 6
45912 - 2 2 6 2 2 6 2 2 6 2 2 6
45913 - 2 2 6 2 2 6 2 2 6 2 2 6
45914 - 38 38 38 82 82 82 42 42 42 14 14 14
45915 - 6 6 6 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 0 0 0 0 0 0
45920 - 0 0 0 0 0 0 0 0 0 0 0 0
45921 - 0 0 0 0 0 0 0 0 0 0 0 0
45922 - 0 0 0 0 0 0 0 0 0 0 0 0
45923 - 0 0 0 0 0 0 0 0 0 0 0 0
45924 - 10 10 10 26 26 26 62 62 62 66 66 66
45925 - 2 2 6 2 2 6 2 2 6 6 6 6
45926 - 70 70 70 170 170 170 206 206 206 234 234 234
45927 -246 246 246 250 250 250 250 250 250 238 238 238
45928 -226 226 226 231 231 231 238 238 238 250 250 250
45929 -250 250 250 250 250 250 246 246 246 231 231 231
45930 -214 214 214 206 206 206 202 202 202 202 202 202
45931 -198 198 198 202 202 202 182 182 182 18 18 18
45932 - 2 2 6 2 2 6 2 2 6 2 2 6
45933 - 2 2 6 2 2 6 2 2 6 2 2 6
45934 - 2 2 6 62 62 62 66 66 66 30 30 30
45935 - 10 10 10 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 0 0 0 0 0 0 0 0 0
45940 - 0 0 0 0 0 0 0 0 0 0 0 0
45941 - 0 0 0 0 0 0 0 0 0 0 0 0
45942 - 0 0 0 0 0 0 0 0 0 0 0 0
45943 - 0 0 0 0 0 0 0 0 0 0 0 0
45944 - 14 14 14 42 42 42 82 82 82 18 18 18
45945 - 2 2 6 2 2 6 2 2 6 10 10 10
45946 - 94 94 94 182 182 182 218 218 218 242 242 242
45947 -250 250 250 253 253 253 253 253 253 250 250 250
45948 -234 234 234 253 253 253 253 253 253 253 253 253
45949 -253 253 253 253 253 253 253 253 253 246 246 246
45950 -238 238 238 226 226 226 210 210 210 202 202 202
45951 -195 195 195 195 195 195 210 210 210 158 158 158
45952 - 6 6 6 14 14 14 50 50 50 14 14 14
45953 - 2 2 6 2 2 6 2 2 6 2 2 6
45954 - 2 2 6 6 6 6 86 86 86 46 46 46
45955 - 18 18 18 6 6 6 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 0 0 0 0 0 0 0 0 0
45960 - 0 0 0 0 0 0 0 0 0 0 0 0
45961 - 0 0 0 0 0 0 0 0 0 0 0 0
45962 - 0 0 0 0 0 0 0 0 0 0 0 0
45963 - 0 0 0 0 0 0 0 0 0 6 6 6
45964 - 22 22 22 54 54 54 70 70 70 2 2 6
45965 - 2 2 6 10 10 10 2 2 6 22 22 22
45966 -166 166 166 231 231 231 250 250 250 253 253 253
45967 -253 253 253 253 253 253 253 253 253 250 250 250
45968 -242 242 242 253 253 253 253 253 253 253 253 253
45969 -253 253 253 253 253 253 253 253 253 253 253 253
45970 -253 253 253 253 253 253 253 253 253 246 246 246
45971 -231 231 231 206 206 206 198 198 198 226 226 226
45972 - 94 94 94 2 2 6 6 6 6 38 38 38
45973 - 30 30 30 2 2 6 2 2 6 2 2 6
45974 - 2 2 6 2 2 6 62 62 62 66 66 66
45975 - 26 26 26 10 10 10 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 0 0 0 0 0 0 0 0 0 0 0 0
45980 - 0 0 0 0 0 0 0 0 0 0 0 0
45981 - 0 0 0 0 0 0 0 0 0 0 0 0
45982 - 0 0 0 0 0 0 0 0 0 0 0 0
45983 - 0 0 0 0 0 0 0 0 0 10 10 10
45984 - 30 30 30 74 74 74 50 50 50 2 2 6
45985 - 26 26 26 26 26 26 2 2 6 106 106 106
45986 -238 238 238 253 253 253 253 253 253 253 253 253
45987 -253 253 253 253 253 253 253 253 253 253 253 253
45988 -253 253 253 253 253 253 253 253 253 253 253 253
45989 -253 253 253 253 253 253 253 253 253 253 253 253
45990 -253 253 253 253 253 253 253 253 253 253 253 253
45991 -253 253 253 246 246 246 218 218 218 202 202 202
45992 -210 210 210 14 14 14 2 2 6 2 2 6
45993 - 30 30 30 22 22 22 2 2 6 2 2 6
45994 - 2 2 6 2 2 6 18 18 18 86 86 86
45995 - 42 42 42 14 14 14 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 0 0 0 0 0 0 0 0 0 0 0 0
46000 - 0 0 0 0 0 0 0 0 0 0 0 0
46001 - 0 0 0 0 0 0 0 0 0 0 0 0
46002 - 0 0 0 0 0 0 0 0 0 0 0 0
46003 - 0 0 0 0 0 0 0 0 0 14 14 14
46004 - 42 42 42 90 90 90 22 22 22 2 2 6
46005 - 42 42 42 2 2 6 18 18 18 218 218 218
46006 -253 253 253 253 253 253 253 253 253 253 253 253
46007 -253 253 253 253 253 253 253 253 253 253 253 253
46008 -253 253 253 253 253 253 253 253 253 253 253 253
46009 -253 253 253 253 253 253 253 253 253 253 253 253
46010 -253 253 253 253 253 253 253 253 253 253 253 253
46011 -253 253 253 253 253 253 250 250 250 221 221 221
46012 -218 218 218 101 101 101 2 2 6 14 14 14
46013 - 18 18 18 38 38 38 10 10 10 2 2 6
46014 - 2 2 6 2 2 6 2 2 6 78 78 78
46015 - 58 58 58 22 22 22 6 6 6 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 0 0 0
46019 - 0 0 0 0 0 0 0 0 0 0 0 0
46020 - 0 0 0 0 0 0 0 0 0 0 0 0
46021 - 0 0 0 0 0 0 0 0 0 0 0 0
46022 - 0 0 0 0 0 0 0 0 0 0 0 0
46023 - 0 0 0 0 0 0 6 6 6 18 18 18
46024 - 54 54 54 82 82 82 2 2 6 26 26 26
46025 - 22 22 22 2 2 6 123 123 123 253 253 253
46026 -253 253 253 253 253 253 253 253 253 253 253 253
46027 -253 253 253 253 253 253 253 253 253 253 253 253
46028 -253 253 253 253 253 253 253 253 253 253 253 253
46029 -253 253 253 253 253 253 253 253 253 253 253 253
46030 -253 253 253 253 253 253 253 253 253 253 253 253
46031 -253 253 253 253 253 253 253 253 253 250 250 250
46032 -238 238 238 198 198 198 6 6 6 38 38 38
46033 - 58 58 58 26 26 26 38 38 38 2 2 6
46034 - 2 2 6 2 2 6 2 2 6 46 46 46
46035 - 78 78 78 30 30 30 10 10 10 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 0 0 0 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 0 0 0
46039 - 0 0 0 0 0 0 0 0 0 0 0 0
46040 - 0 0 0 0 0 0 0 0 0 0 0 0
46041 - 0 0 0 0 0 0 0 0 0 0 0 0
46042 - 0 0 0 0 0 0 0 0 0 0 0 0
46043 - 0 0 0 0 0 0 10 10 10 30 30 30
46044 - 74 74 74 58 58 58 2 2 6 42 42 42
46045 - 2 2 6 22 22 22 231 231 231 253 253 253
46046 -253 253 253 253 253 253 253 253 253 253 253 253
46047 -253 253 253 253 253 253 253 253 253 250 250 250
46048 -253 253 253 253 253 253 253 253 253 253 253 253
46049 -253 253 253 253 253 253 253 253 253 253 253 253
46050 -253 253 253 253 253 253 253 253 253 253 253 253
46051 -253 253 253 253 253 253 253 253 253 253 253 253
46052 -253 253 253 246 246 246 46 46 46 38 38 38
46053 - 42 42 42 14 14 14 38 38 38 14 14 14
46054 - 2 2 6 2 2 6 2 2 6 6 6 6
46055 - 86 86 86 46 46 46 14 14 14 0 0 0
46056 - 0 0 0 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 0 0 0 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 0 0 0
46059 - 0 0 0 0 0 0 0 0 0 0 0 0
46060 - 0 0 0 0 0 0 0 0 0 0 0 0
46061 - 0 0 0 0 0 0 0 0 0 0 0 0
46062 - 0 0 0 0 0 0 0 0 0 0 0 0
46063 - 0 0 0 6 6 6 14 14 14 42 42 42
46064 - 90 90 90 18 18 18 18 18 18 26 26 26
46065 - 2 2 6 116 116 116 253 253 253 253 253 253
46066 -253 253 253 253 253 253 253 253 253 253 253 253
46067 -253 253 253 253 253 253 250 250 250 238 238 238
46068 -253 253 253 253 253 253 253 253 253 253 253 253
46069 -253 253 253 253 253 253 253 253 253 253 253 253
46070 -253 253 253 253 253 253 253 253 253 253 253 253
46071 -253 253 253 253 253 253 253 253 253 253 253 253
46072 -253 253 253 253 253 253 94 94 94 6 6 6
46073 - 2 2 6 2 2 6 10 10 10 34 34 34
46074 - 2 2 6 2 2 6 2 2 6 2 2 6
46075 - 74 74 74 58 58 58 22 22 22 6 6 6
46076 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 0 0 0 0 0 0
46078 - 0 0 0 0 0 0 0 0 0 0 0 0
46079 - 0 0 0 0 0 0 0 0 0 0 0 0
46080 - 0 0 0 0 0 0 0 0 0 0 0 0
46081 - 0 0 0 0 0 0 0 0 0 0 0 0
46082 - 0 0 0 0 0 0 0 0 0 0 0 0
46083 - 0 0 0 10 10 10 26 26 26 66 66 66
46084 - 82 82 82 2 2 6 38 38 38 6 6 6
46085 - 14 14 14 210 210 210 253 253 253 253 253 253
46086 -253 253 253 253 253 253 253 253 253 253 253 253
46087 -253 253 253 253 253 253 246 246 246 242 242 242
46088 -253 253 253 253 253 253 253 253 253 253 253 253
46089 -253 253 253 253 253 253 253 253 253 253 253 253
46090 -253 253 253 253 253 253 253 253 253 253 253 253
46091 -253 253 253 253 253 253 253 253 253 253 253 253
46092 -253 253 253 253 253 253 144 144 144 2 2 6
46093 - 2 2 6 2 2 6 2 2 6 46 46 46
46094 - 2 2 6 2 2 6 2 2 6 2 2 6
46095 - 42 42 42 74 74 74 30 30 30 10 10 10
46096 - 0 0 0 0 0 0 0 0 0 0 0 0
46097 - 0 0 0 0 0 0 0 0 0 0 0 0
46098 - 0 0 0 0 0 0 0 0 0 0 0 0
46099 - 0 0 0 0 0 0 0 0 0 0 0 0
46100 - 0 0 0 0 0 0 0 0 0 0 0 0
46101 - 0 0 0 0 0 0 0 0 0 0 0 0
46102 - 0 0 0 0 0 0 0 0 0 0 0 0
46103 - 6 6 6 14 14 14 42 42 42 90 90 90
46104 - 26 26 26 6 6 6 42 42 42 2 2 6
46105 - 74 74 74 250 250 250 253 253 253 253 253 253
46106 -253 253 253 253 253 253 253 253 253 253 253 253
46107 -253 253 253 253 253 253 242 242 242 242 242 242
46108 -253 253 253 253 253 253 253 253 253 253 253 253
46109 -253 253 253 253 253 253 253 253 253 253 253 253
46110 -253 253 253 253 253 253 253 253 253 253 253 253
46111 -253 253 253 253 253 253 253 253 253 253 253 253
46112 -253 253 253 253 253 253 182 182 182 2 2 6
46113 - 2 2 6 2 2 6 2 2 6 46 46 46
46114 - 2 2 6 2 2 6 2 2 6 2 2 6
46115 - 10 10 10 86 86 86 38 38 38 10 10 10
46116 - 0 0 0 0 0 0 0 0 0 0 0 0
46117 - 0 0 0 0 0 0 0 0 0 0 0 0
46118 - 0 0 0 0 0 0 0 0 0 0 0 0
46119 - 0 0 0 0 0 0 0 0 0 0 0 0
46120 - 0 0 0 0 0 0 0 0 0 0 0 0
46121 - 0 0 0 0 0 0 0 0 0 0 0 0
46122 - 0 0 0 0 0 0 0 0 0 0 0 0
46123 - 10 10 10 26 26 26 66 66 66 82 82 82
46124 - 2 2 6 22 22 22 18 18 18 2 2 6
46125 -149 149 149 253 253 253 253 253 253 253 253 253
46126 -253 253 253 253 253 253 253 253 253 253 253 253
46127 -253 253 253 253 253 253 234 234 234 242 242 242
46128 -253 253 253 253 253 253 253 253 253 253 253 253
46129 -253 253 253 253 253 253 253 253 253 253 253 253
46130 -253 253 253 253 253 253 253 253 253 253 253 253
46131 -253 253 253 253 253 253 253 253 253 253 253 253
46132 -253 253 253 253 253 253 206 206 206 2 2 6
46133 - 2 2 6 2 2 6 2 2 6 38 38 38
46134 - 2 2 6 2 2 6 2 2 6 2 2 6
46135 - 6 6 6 86 86 86 46 46 46 14 14 14
46136 - 0 0 0 0 0 0 0 0 0 0 0 0
46137 - 0 0 0 0 0 0 0 0 0 0 0 0
46138 - 0 0 0 0 0 0 0 0 0 0 0 0
46139 - 0 0 0 0 0 0 0 0 0 0 0 0
46140 - 0 0 0 0 0 0 0 0 0 0 0 0
46141 - 0 0 0 0 0 0 0 0 0 0 0 0
46142 - 0 0 0 0 0 0 0 0 0 6 6 6
46143 - 18 18 18 46 46 46 86 86 86 18 18 18
46144 - 2 2 6 34 34 34 10 10 10 6 6 6
46145 -210 210 210 253 253 253 253 253 253 253 253 253
46146 -253 253 253 253 253 253 253 253 253 253 253 253
46147 -253 253 253 253 253 253 234 234 234 242 242 242
46148 -253 253 253 253 253 253 253 253 253 253 253 253
46149 -253 253 253 253 253 253 253 253 253 253 253 253
46150 -253 253 253 253 253 253 253 253 253 253 253 253
46151 -253 253 253 253 253 253 253 253 253 253 253 253
46152 -253 253 253 253 253 253 221 221 221 6 6 6
46153 - 2 2 6 2 2 6 6 6 6 30 30 30
46154 - 2 2 6 2 2 6 2 2 6 2 2 6
46155 - 2 2 6 82 82 82 54 54 54 18 18 18
46156 - 6 6 6 0 0 0 0 0 0 0 0 0
46157 - 0 0 0 0 0 0 0 0 0 0 0 0
46158 - 0 0 0 0 0 0 0 0 0 0 0 0
46159 - 0 0 0 0 0 0 0 0 0 0 0 0
46160 - 0 0 0 0 0 0 0 0 0 0 0 0
46161 - 0 0 0 0 0 0 0 0 0 0 0 0
46162 - 0 0 0 0 0 0 0 0 0 10 10 10
46163 - 26 26 26 66 66 66 62 62 62 2 2 6
46164 - 2 2 6 38 38 38 10 10 10 26 26 26
46165 -238 238 238 253 253 253 253 253 253 253 253 253
46166 -253 253 253 253 253 253 253 253 253 253 253 253
46167 -253 253 253 253 253 253 231 231 231 238 238 238
46168 -253 253 253 253 253 253 253 253 253 253 253 253
46169 -253 253 253 253 253 253 253 253 253 253 253 253
46170 -253 253 253 253 253 253 253 253 253 253 253 253
46171 -253 253 253 253 253 253 253 253 253 253 253 253
46172 -253 253 253 253 253 253 231 231 231 6 6 6
46173 - 2 2 6 2 2 6 10 10 10 30 30 30
46174 - 2 2 6 2 2 6 2 2 6 2 2 6
46175 - 2 2 6 66 66 66 58 58 58 22 22 22
46176 - 6 6 6 0 0 0 0 0 0 0 0 0
46177 - 0 0 0 0 0 0 0 0 0 0 0 0
46178 - 0 0 0 0 0 0 0 0 0 0 0 0
46179 - 0 0 0 0 0 0 0 0 0 0 0 0
46180 - 0 0 0 0 0 0 0 0 0 0 0 0
46181 - 0 0 0 0 0 0 0 0 0 0 0 0
46182 - 0 0 0 0 0 0 0 0 0 10 10 10
46183 - 38 38 38 78 78 78 6 6 6 2 2 6
46184 - 2 2 6 46 46 46 14 14 14 42 42 42
46185 -246 246 246 253 253 253 253 253 253 253 253 253
46186 -253 253 253 253 253 253 253 253 253 253 253 253
46187 -253 253 253 253 253 253 231 231 231 242 242 242
46188 -253 253 253 253 253 253 253 253 253 253 253 253
46189 -253 253 253 253 253 253 253 253 253 253 253 253
46190 -253 253 253 253 253 253 253 253 253 253 253 253
46191 -253 253 253 253 253 253 253 253 253 253 253 253
46192 -253 253 253 253 253 253 234 234 234 10 10 10
46193 - 2 2 6 2 2 6 22 22 22 14 14 14
46194 - 2 2 6 2 2 6 2 2 6 2 2 6
46195 - 2 2 6 66 66 66 62 62 62 22 22 22
46196 - 6 6 6 0 0 0 0 0 0 0 0 0
46197 - 0 0 0 0 0 0 0 0 0 0 0 0
46198 - 0 0 0 0 0 0 0 0 0 0 0 0
46199 - 0 0 0 0 0 0 0 0 0 0 0 0
46200 - 0 0 0 0 0 0 0 0 0 0 0 0
46201 - 0 0 0 0 0 0 0 0 0 0 0 0
46202 - 0 0 0 0 0 0 6 6 6 18 18 18
46203 - 50 50 50 74 74 74 2 2 6 2 2 6
46204 - 14 14 14 70 70 70 34 34 34 62 62 62
46205 -250 250 250 253 253 253 253 253 253 253 253 253
46206 -253 253 253 253 253 253 253 253 253 253 253 253
46207 -253 253 253 253 253 253 231 231 231 246 246 246
46208 -253 253 253 253 253 253 253 253 253 253 253 253
46209 -253 253 253 253 253 253 253 253 253 253 253 253
46210 -253 253 253 253 253 253 253 253 253 253 253 253
46211 -253 253 253 253 253 253 253 253 253 253 253 253
46212 -253 253 253 253 253 253 234 234 234 14 14 14
46213 - 2 2 6 2 2 6 30 30 30 2 2 6
46214 - 2 2 6 2 2 6 2 2 6 2 2 6
46215 - 2 2 6 66 66 66 62 62 62 22 22 22
46216 - 6 6 6 0 0 0 0 0 0 0 0 0
46217 - 0 0 0 0 0 0 0 0 0 0 0 0
46218 - 0 0 0 0 0 0 0 0 0 0 0 0
46219 - 0 0 0 0 0 0 0 0 0 0 0 0
46220 - 0 0 0 0 0 0 0 0 0 0 0 0
46221 - 0 0 0 0 0 0 0 0 0 0 0 0
46222 - 0 0 0 0 0 0 6 6 6 18 18 18
46223 - 54 54 54 62 62 62 2 2 6 2 2 6
46224 - 2 2 6 30 30 30 46 46 46 70 70 70
46225 -250 250 250 253 253 253 253 253 253 253 253 253
46226 -253 253 253 253 253 253 253 253 253 253 253 253
46227 -253 253 253 253 253 253 231 231 231 246 246 246
46228 -253 253 253 253 253 253 253 253 253 253 253 253
46229 -253 253 253 253 253 253 253 253 253 253 253 253
46230 -253 253 253 253 253 253 253 253 253 253 253 253
46231 -253 253 253 253 253 253 253 253 253 253 253 253
46232 -253 253 253 253 253 253 226 226 226 10 10 10
46233 - 2 2 6 6 6 6 30 30 30 2 2 6
46234 - 2 2 6 2 2 6 2 2 6 2 2 6
46235 - 2 2 6 66 66 66 58 58 58 22 22 22
46236 - 6 6 6 0 0 0 0 0 0 0 0 0
46237 - 0 0 0 0 0 0 0 0 0 0 0 0
46238 - 0 0 0 0 0 0 0 0 0 0 0 0
46239 - 0 0 0 0 0 0 0 0 0 0 0 0
46240 - 0 0 0 0 0 0 0 0 0 0 0 0
46241 - 0 0 0 0 0 0 0 0 0 0 0 0
46242 - 0 0 0 0 0 0 6 6 6 22 22 22
46243 - 58 58 58 62 62 62 2 2 6 2 2 6
46244 - 2 2 6 2 2 6 30 30 30 78 78 78
46245 -250 250 250 253 253 253 253 253 253 253 253 253
46246 -253 253 253 253 253 253 253 253 253 253 253 253
46247 -253 253 253 253 253 253 231 231 231 246 246 246
46248 -253 253 253 253 253 253 253 253 253 253 253 253
46249 -253 253 253 253 253 253 253 253 253 253 253 253
46250 -253 253 253 253 253 253 253 253 253 253 253 253
46251 -253 253 253 253 253 253 253 253 253 253 253 253
46252 -253 253 253 253 253 253 206 206 206 2 2 6
46253 - 22 22 22 34 34 34 18 14 6 22 22 22
46254 - 26 26 26 18 18 18 6 6 6 2 2 6
46255 - 2 2 6 82 82 82 54 54 54 18 18 18
46256 - 6 6 6 0 0 0 0 0 0 0 0 0
46257 - 0 0 0 0 0 0 0 0 0 0 0 0
46258 - 0 0 0 0 0 0 0 0 0 0 0 0
46259 - 0 0 0 0 0 0 0 0 0 0 0 0
46260 - 0 0 0 0 0 0 0 0 0 0 0 0
46261 - 0 0 0 0 0 0 0 0 0 0 0 0
46262 - 0 0 0 0 0 0 6 6 6 26 26 26
46263 - 62 62 62 106 106 106 74 54 14 185 133 11
46264 -210 162 10 121 92 8 6 6 6 62 62 62
46265 -238 238 238 253 253 253 253 253 253 253 253 253
46266 -253 253 253 253 253 253 253 253 253 253 253 253
46267 -253 253 253 253 253 253 231 231 231 246 246 246
46268 -253 253 253 253 253 253 253 253 253 253 253 253
46269 -253 253 253 253 253 253 253 253 253 253 253 253
46270 -253 253 253 253 253 253 253 253 253 253 253 253
46271 -253 253 253 253 253 253 253 253 253 253 253 253
46272 -253 253 253 253 253 253 158 158 158 18 18 18
46273 - 14 14 14 2 2 6 2 2 6 2 2 6
46274 - 6 6 6 18 18 18 66 66 66 38 38 38
46275 - 6 6 6 94 94 94 50 50 50 18 18 18
46276 - 6 6 6 0 0 0 0 0 0 0 0 0
46277 - 0 0 0 0 0 0 0 0 0 0 0 0
46278 - 0 0 0 0 0 0 0 0 0 0 0 0
46279 - 0 0 0 0 0 0 0 0 0 0 0 0
46280 - 0 0 0 0 0 0 0 0 0 0 0 0
46281 - 0 0 0 0 0 0 0 0 0 6 6 6
46282 - 10 10 10 10 10 10 18 18 18 38 38 38
46283 - 78 78 78 142 134 106 216 158 10 242 186 14
46284 -246 190 14 246 190 14 156 118 10 10 10 10
46285 - 90 90 90 238 238 238 253 253 253 253 253 253
46286 -253 253 253 253 253 253 253 253 253 253 253 253
46287 -253 253 253 253 253 253 231 231 231 250 250 250
46288 -253 253 253 253 253 253 253 253 253 253 253 253
46289 -253 253 253 253 253 253 253 253 253 253 253 253
46290 -253 253 253 253 253 253 253 253 253 253 253 253
46291 -253 253 253 253 253 253 253 253 253 246 230 190
46292 -238 204 91 238 204 91 181 142 44 37 26 9
46293 - 2 2 6 2 2 6 2 2 6 2 2 6
46294 - 2 2 6 2 2 6 38 38 38 46 46 46
46295 - 26 26 26 106 106 106 54 54 54 18 18 18
46296 - 6 6 6 0 0 0 0 0 0 0 0 0
46297 - 0 0 0 0 0 0 0 0 0 0 0 0
46298 - 0 0 0 0 0 0 0 0 0 0 0 0
46299 - 0 0 0 0 0 0 0 0 0 0 0 0
46300 - 0 0 0 0 0 0 0 0 0 0 0 0
46301 - 0 0 0 6 6 6 14 14 14 22 22 22
46302 - 30 30 30 38 38 38 50 50 50 70 70 70
46303 -106 106 106 190 142 34 226 170 11 242 186 14
46304 -246 190 14 246 190 14 246 190 14 154 114 10
46305 - 6 6 6 74 74 74 226 226 226 253 253 253
46306 -253 253 253 253 253 253 253 253 253 253 253 253
46307 -253 253 253 253 253 253 231 231 231 250 250 250
46308 -253 253 253 253 253 253 253 253 253 253 253 253
46309 -253 253 253 253 253 253 253 253 253 253 253 253
46310 -253 253 253 253 253 253 253 253 253 253 253 253
46311 -253 253 253 253 253 253 253 253 253 228 184 62
46312 -241 196 14 241 208 19 232 195 16 38 30 10
46313 - 2 2 6 2 2 6 2 2 6 2 2 6
46314 - 2 2 6 6 6 6 30 30 30 26 26 26
46315 -203 166 17 154 142 90 66 66 66 26 26 26
46316 - 6 6 6 0 0 0 0 0 0 0 0 0
46317 - 0 0 0 0 0 0 0 0 0 0 0 0
46318 - 0 0 0 0 0 0 0 0 0 0 0 0
46319 - 0 0 0 0 0 0 0 0 0 0 0 0
46320 - 0 0 0 0 0 0 0 0 0 0 0 0
46321 - 6 6 6 18 18 18 38 38 38 58 58 58
46322 - 78 78 78 86 86 86 101 101 101 123 123 123
46323 -175 146 61 210 150 10 234 174 13 246 186 14
46324 -246 190 14 246 190 14 246 190 14 238 190 10
46325 -102 78 10 2 2 6 46 46 46 198 198 198
46326 -253 253 253 253 253 253 253 253 253 253 253 253
46327 -253 253 253 253 253 253 234 234 234 242 242 242
46328 -253 253 253 253 253 253 253 253 253 253 253 253
46329 -253 253 253 253 253 253 253 253 253 253 253 253
46330 -253 253 253 253 253 253 253 253 253 253 253 253
46331 -253 253 253 253 253 253 253 253 253 224 178 62
46332 -242 186 14 241 196 14 210 166 10 22 18 6
46333 - 2 2 6 2 2 6 2 2 6 2 2 6
46334 - 2 2 6 2 2 6 6 6 6 121 92 8
46335 -238 202 15 232 195 16 82 82 82 34 34 34
46336 - 10 10 10 0 0 0 0 0 0 0 0 0
46337 - 0 0 0 0 0 0 0 0 0 0 0 0
46338 - 0 0 0 0 0 0 0 0 0 0 0 0
46339 - 0 0 0 0 0 0 0 0 0 0 0 0
46340 - 0 0 0 0 0 0 0 0 0 0 0 0
46341 - 14 14 14 38 38 38 70 70 70 154 122 46
46342 -190 142 34 200 144 11 197 138 11 197 138 11
46343 -213 154 11 226 170 11 242 186 14 246 190 14
46344 -246 190 14 246 190 14 246 190 14 246 190 14
46345 -225 175 15 46 32 6 2 2 6 22 22 22
46346 -158 158 158 250 250 250 253 253 253 253 253 253
46347 -253 253 253 253 253 253 253 253 253 253 253 253
46348 -253 253 253 253 253 253 253 253 253 253 253 253
46349 -253 253 253 253 253 253 253 253 253 253 253 253
46350 -253 253 253 253 253 253 253 253 253 253 253 253
46351 -253 253 253 250 250 250 242 242 242 224 178 62
46352 -239 182 13 236 186 11 213 154 11 46 32 6
46353 - 2 2 6 2 2 6 2 2 6 2 2 6
46354 - 2 2 6 2 2 6 61 42 6 225 175 15
46355 -238 190 10 236 186 11 112 100 78 42 42 42
46356 - 14 14 14 0 0 0 0 0 0 0 0 0
46357 - 0 0 0 0 0 0 0 0 0 0 0 0
46358 - 0 0 0 0 0 0 0 0 0 0 0 0
46359 - 0 0 0 0 0 0 0 0 0 0 0 0
46360 - 0 0 0 0 0 0 0 0 0 6 6 6
46361 - 22 22 22 54 54 54 154 122 46 213 154 11
46362 -226 170 11 230 174 11 226 170 11 226 170 11
46363 -236 178 12 242 186 14 246 190 14 246 190 14
46364 -246 190 14 246 190 14 246 190 14 246 190 14
46365 -241 196 14 184 144 12 10 10 10 2 2 6
46366 - 6 6 6 116 116 116 242 242 242 253 253 253
46367 -253 253 253 253 253 253 253 253 253 253 253 253
46368 -253 253 253 253 253 253 253 253 253 253 253 253
46369 -253 253 253 253 253 253 253 253 253 253 253 253
46370 -253 253 253 253 253 253 253 253 253 253 253 253
46371 -253 253 253 231 231 231 198 198 198 214 170 54
46372 -236 178 12 236 178 12 210 150 10 137 92 6
46373 - 18 14 6 2 2 6 2 2 6 2 2 6
46374 - 6 6 6 70 47 6 200 144 11 236 178 12
46375 -239 182 13 239 182 13 124 112 88 58 58 58
46376 - 22 22 22 6 6 6 0 0 0 0 0 0
46377 - 0 0 0 0 0 0 0 0 0 0 0 0
46378 - 0 0 0 0 0 0 0 0 0 0 0 0
46379 - 0 0 0 0 0 0 0 0 0 0 0 0
46380 - 0 0 0 0 0 0 0 0 0 10 10 10
46381 - 30 30 30 70 70 70 180 133 36 226 170 11
46382 -239 182 13 242 186 14 242 186 14 246 186 14
46383 -246 190 14 246 190 14 246 190 14 246 190 14
46384 -246 190 14 246 190 14 246 190 14 246 190 14
46385 -246 190 14 232 195 16 98 70 6 2 2 6
46386 - 2 2 6 2 2 6 66 66 66 221 221 221
46387 -253 253 253 253 253 253 253 253 253 253 253 253
46388 -253 253 253 253 253 253 253 253 253 253 253 253
46389 -253 253 253 253 253 253 253 253 253 253 253 253
46390 -253 253 253 253 253 253 253 253 253 253 253 253
46391 -253 253 253 206 206 206 198 198 198 214 166 58
46392 -230 174 11 230 174 11 216 158 10 192 133 9
46393 -163 110 8 116 81 8 102 78 10 116 81 8
46394 -167 114 7 197 138 11 226 170 11 239 182 13
46395 -242 186 14 242 186 14 162 146 94 78 78 78
46396 - 34 34 34 14 14 14 6 6 6 0 0 0
46397 - 0 0 0 0 0 0 0 0 0 0 0 0
46398 - 0 0 0 0 0 0 0 0 0 0 0 0
46399 - 0 0 0 0 0 0 0 0 0 0 0 0
46400 - 0 0 0 0 0 0 0 0 0 6 6 6
46401 - 30 30 30 78 78 78 190 142 34 226 170 11
46402 -239 182 13 246 190 14 246 190 14 246 190 14
46403 -246 190 14 246 190 14 246 190 14 246 190 14
46404 -246 190 14 246 190 14 246 190 14 246 190 14
46405 -246 190 14 241 196 14 203 166 17 22 18 6
46406 - 2 2 6 2 2 6 2 2 6 38 38 38
46407 -218 218 218 253 253 253 253 253 253 253 253 253
46408 -253 253 253 253 253 253 253 253 253 253 253 253
46409 -253 253 253 253 253 253 253 253 253 253 253 253
46410 -253 253 253 253 253 253 253 253 253 253 253 253
46411 -250 250 250 206 206 206 198 198 198 202 162 69
46412 -226 170 11 236 178 12 224 166 10 210 150 10
46413 -200 144 11 197 138 11 192 133 9 197 138 11
46414 -210 150 10 226 170 11 242 186 14 246 190 14
46415 -246 190 14 246 186 14 225 175 15 124 112 88
46416 - 62 62 62 30 30 30 14 14 14 6 6 6
46417 - 0 0 0 0 0 0 0 0 0 0 0 0
46418 - 0 0 0 0 0 0 0 0 0 0 0 0
46419 - 0 0 0 0 0 0 0 0 0 0 0 0
46420 - 0 0 0 0 0 0 0 0 0 10 10 10
46421 - 30 30 30 78 78 78 174 135 50 224 166 10
46422 -239 182 13 246 190 14 246 190 14 246 190 14
46423 -246 190 14 246 190 14 246 190 14 246 190 14
46424 -246 190 14 246 190 14 246 190 14 246 190 14
46425 -246 190 14 246 190 14 241 196 14 139 102 15
46426 - 2 2 6 2 2 6 2 2 6 2 2 6
46427 - 78 78 78 250 250 250 253 253 253 253 253 253
46428 -253 253 253 253 253 253 253 253 253 253 253 253
46429 -253 253 253 253 253 253 253 253 253 253 253 253
46430 -253 253 253 253 253 253 253 253 253 253 253 253
46431 -250 250 250 214 214 214 198 198 198 190 150 46
46432 -219 162 10 236 178 12 234 174 13 224 166 10
46433 -216 158 10 213 154 11 213 154 11 216 158 10
46434 -226 170 11 239 182 13 246 190 14 246 190 14
46435 -246 190 14 246 190 14 242 186 14 206 162 42
46436 -101 101 101 58 58 58 30 30 30 14 14 14
46437 - 6 6 6 0 0 0 0 0 0 0 0 0
46438 - 0 0 0 0 0 0 0 0 0 0 0 0
46439 - 0 0 0 0 0 0 0 0 0 0 0 0
46440 - 0 0 0 0 0 0 0 0 0 10 10 10
46441 - 30 30 30 74 74 74 174 135 50 216 158 10
46442 -236 178 12 246 190 14 246 190 14 246 190 14
46443 -246 190 14 246 190 14 246 190 14 246 190 14
46444 -246 190 14 246 190 14 246 190 14 246 190 14
46445 -246 190 14 246 190 14 241 196 14 226 184 13
46446 - 61 42 6 2 2 6 2 2 6 2 2 6
46447 - 22 22 22 238 238 238 253 253 253 253 253 253
46448 -253 253 253 253 253 253 253 253 253 253 253 253
46449 -253 253 253 253 253 253 253 253 253 253 253 253
46450 -253 253 253 253 253 253 253 253 253 253 253 253
46451 -253 253 253 226 226 226 187 187 187 180 133 36
46452 -216 158 10 236 178 12 239 182 13 236 178 12
46453 -230 174 11 226 170 11 226 170 11 230 174 11
46454 -236 178 12 242 186 14 246 190 14 246 190 14
46455 -246 190 14 246 190 14 246 186 14 239 182 13
46456 -206 162 42 106 106 106 66 66 66 34 34 34
46457 - 14 14 14 6 6 6 0 0 0 0 0 0
46458 - 0 0 0 0 0 0 0 0 0 0 0 0
46459 - 0 0 0 0 0 0 0 0 0 0 0 0
46460 - 0 0 0 0 0 0 0 0 0 6 6 6
46461 - 26 26 26 70 70 70 163 133 67 213 154 11
46462 -236 178 12 246 190 14 246 190 14 246 190 14
46463 -246 190 14 246 190 14 246 190 14 246 190 14
46464 -246 190 14 246 190 14 246 190 14 246 190 14
46465 -246 190 14 246 190 14 246 190 14 241 196 14
46466 -190 146 13 18 14 6 2 2 6 2 2 6
46467 - 46 46 46 246 246 246 253 253 253 253 253 253
46468 -253 253 253 253 253 253 253 253 253 253 253 253
46469 -253 253 253 253 253 253 253 253 253 253 253 253
46470 -253 253 253 253 253 253 253 253 253 253 253 253
46471 -253 253 253 221 221 221 86 86 86 156 107 11
46472 -216 158 10 236 178 12 242 186 14 246 186 14
46473 -242 186 14 239 182 13 239 182 13 242 186 14
46474 -242 186 14 246 186 14 246 190 14 246 190 14
46475 -246 190 14 246 190 14 246 190 14 246 190 14
46476 -242 186 14 225 175 15 142 122 72 66 66 66
46477 - 30 30 30 10 10 10 0 0 0 0 0 0
46478 - 0 0 0 0 0 0 0 0 0 0 0 0
46479 - 0 0 0 0 0 0 0 0 0 0 0 0
46480 - 0 0 0 0 0 0 0 0 0 6 6 6
46481 - 26 26 26 70 70 70 163 133 67 210 150 10
46482 -236 178 12 246 190 14 246 190 14 246 190 14
46483 -246 190 14 246 190 14 246 190 14 246 190 14
46484 -246 190 14 246 190 14 246 190 14 246 190 14
46485 -246 190 14 246 190 14 246 190 14 246 190 14
46486 -232 195 16 121 92 8 34 34 34 106 106 106
46487 -221 221 221 253 253 253 253 253 253 253 253 253
46488 -253 253 253 253 253 253 253 253 253 253 253 253
46489 -253 253 253 253 253 253 253 253 253 253 253 253
46490 -253 253 253 253 253 253 253 253 253 253 253 253
46491 -242 242 242 82 82 82 18 14 6 163 110 8
46492 -216 158 10 236 178 12 242 186 14 246 190 14
46493 -246 190 14 246 190 14 246 190 14 246 190 14
46494 -246 190 14 246 190 14 246 190 14 246 190 14
46495 -246 190 14 246 190 14 246 190 14 246 190 14
46496 -246 190 14 246 190 14 242 186 14 163 133 67
46497 - 46 46 46 18 18 18 6 6 6 0 0 0
46498 - 0 0 0 0 0 0 0 0 0 0 0 0
46499 - 0 0 0 0 0 0 0 0 0 0 0 0
46500 - 0 0 0 0 0 0 0 0 0 10 10 10
46501 - 30 30 30 78 78 78 163 133 67 210 150 10
46502 -236 178 12 246 186 14 246 190 14 246 190 14
46503 -246 190 14 246 190 14 246 190 14 246 190 14
46504 -246 190 14 246 190 14 246 190 14 246 190 14
46505 -246 190 14 246 190 14 246 190 14 246 190 14
46506 -241 196 14 215 174 15 190 178 144 253 253 253
46507 -253 253 253 253 253 253 253 253 253 253 253 253
46508 -253 253 253 253 253 253 253 253 253 253 253 253
46509 -253 253 253 253 253 253 253 253 253 253 253 253
46510 -253 253 253 253 253 253 253 253 253 218 218 218
46511 - 58 58 58 2 2 6 22 18 6 167 114 7
46512 -216 158 10 236 178 12 246 186 14 246 190 14
46513 -246 190 14 246 190 14 246 190 14 246 190 14
46514 -246 190 14 246 190 14 246 190 14 246 190 14
46515 -246 190 14 246 190 14 246 190 14 246 190 14
46516 -246 190 14 246 186 14 242 186 14 190 150 46
46517 - 54 54 54 22 22 22 6 6 6 0 0 0
46518 - 0 0 0 0 0 0 0 0 0 0 0 0
46519 - 0 0 0 0 0 0 0 0 0 0 0 0
46520 - 0 0 0 0 0 0 0 0 0 14 14 14
46521 - 38 38 38 86 86 86 180 133 36 213 154 11
46522 -236 178 12 246 186 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 246 190 14 246 190 14
46525 -246 190 14 246 190 14 246 190 14 246 190 14
46526 -246 190 14 232 195 16 190 146 13 214 214 214
46527 -253 253 253 253 253 253 253 253 253 253 253 253
46528 -253 253 253 253 253 253 253 253 253 253 253 253
46529 -253 253 253 253 253 253 253 253 253 253 253 253
46530 -253 253 253 250 250 250 170 170 170 26 26 26
46531 - 2 2 6 2 2 6 37 26 9 163 110 8
46532 -219 162 10 239 182 13 246 186 14 246 190 14
46533 -246 190 14 246 190 14 246 190 14 246 190 14
46534 -246 190 14 246 190 14 246 190 14 246 190 14
46535 -246 190 14 246 190 14 246 190 14 246 190 14
46536 -246 186 14 236 178 12 224 166 10 142 122 72
46537 - 46 46 46 18 18 18 6 6 6 0 0 0
46538 - 0 0 0 0 0 0 0 0 0 0 0 0
46539 - 0 0 0 0 0 0 0 0 0 0 0 0
46540 - 0 0 0 0 0 0 6 6 6 18 18 18
46541 - 50 50 50 109 106 95 192 133 9 224 166 10
46542 -242 186 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 190 14 246 190 14 246 190 14
46545 -246 190 14 246 190 14 246 190 14 246 190 14
46546 -242 186 14 226 184 13 210 162 10 142 110 46
46547 -226 226 226 253 253 253 253 253 253 253 253 253
46548 -253 253 253 253 253 253 253 253 253 253 253 253
46549 -253 253 253 253 253 253 253 253 253 253 253 253
46550 -198 198 198 66 66 66 2 2 6 2 2 6
46551 - 2 2 6 2 2 6 50 34 6 156 107 11
46552 -219 162 10 239 182 13 246 186 14 246 190 14
46553 -246 190 14 246 190 14 246 190 14 246 190 14
46554 -246 190 14 246 190 14 246 190 14 246 190 14
46555 -246 190 14 246 190 14 246 190 14 242 186 14
46556 -234 174 13 213 154 11 154 122 46 66 66 66
46557 - 30 30 30 10 10 10 0 0 0 0 0 0
46558 - 0 0 0 0 0 0 0 0 0 0 0 0
46559 - 0 0 0 0 0 0 0 0 0 0 0 0
46560 - 0 0 0 0 0 0 6 6 6 22 22 22
46561 - 58 58 58 154 121 60 206 145 10 234 174 13
46562 -242 186 14 246 186 14 246 190 14 246 190 14
46563 -246 190 14 246 190 14 246 190 14 246 190 14
46564 -246 190 14 246 190 14 246 190 14 246 190 14
46565 -246 190 14 246 190 14 246 190 14 246 190 14
46566 -246 186 14 236 178 12 210 162 10 163 110 8
46567 - 61 42 6 138 138 138 218 218 218 250 250 250
46568 -253 253 253 253 253 253 253 253 253 250 250 250
46569 -242 242 242 210 210 210 144 144 144 66 66 66
46570 - 6 6 6 2 2 6 2 2 6 2 2 6
46571 - 2 2 6 2 2 6 61 42 6 163 110 8
46572 -216 158 10 236 178 12 246 190 14 246 190 14
46573 -246 190 14 246 190 14 246 190 14 246 190 14
46574 -246 190 14 246 190 14 246 190 14 246 190 14
46575 -246 190 14 239 182 13 230 174 11 216 158 10
46576 -190 142 34 124 112 88 70 70 70 38 38 38
46577 - 18 18 18 6 6 6 0 0 0 0 0 0
46578 - 0 0 0 0 0 0 0 0 0 0 0 0
46579 - 0 0 0 0 0 0 0 0 0 0 0 0
46580 - 0 0 0 0 0 0 6 6 6 22 22 22
46581 - 62 62 62 168 124 44 206 145 10 224 166 10
46582 -236 178 12 239 182 13 242 186 14 242 186 14
46583 -246 186 14 246 190 14 246 190 14 246 190 14
46584 -246 190 14 246 190 14 246 190 14 246 190 14
46585 -246 190 14 246 190 14 246 190 14 246 190 14
46586 -246 190 14 236 178 12 216 158 10 175 118 6
46587 - 80 54 7 2 2 6 6 6 6 30 30 30
46588 - 54 54 54 62 62 62 50 50 50 38 38 38
46589 - 14 14 14 2 2 6 2 2 6 2 2 6
46590 - 2 2 6 2 2 6 2 2 6 2 2 6
46591 - 2 2 6 6 6 6 80 54 7 167 114 7
46592 -213 154 11 236 178 12 246 190 14 246 190 14
46593 -246 190 14 246 190 14 246 190 14 246 190 14
46594 -246 190 14 242 186 14 239 182 13 239 182 13
46595 -230 174 11 210 150 10 174 135 50 124 112 88
46596 - 82 82 82 54 54 54 34 34 34 18 18 18
46597 - 6 6 6 0 0 0 0 0 0 0 0 0
46598 - 0 0 0 0 0 0 0 0 0 0 0 0
46599 - 0 0 0 0 0 0 0 0 0 0 0 0
46600 - 0 0 0 0 0 0 6 6 6 18 18 18
46601 - 50 50 50 158 118 36 192 133 9 200 144 11
46602 -216 158 10 219 162 10 224 166 10 226 170 11
46603 -230 174 11 236 178 12 239 182 13 239 182 13
46604 -242 186 14 246 186 14 246 190 14 246 190 14
46605 -246 190 14 246 190 14 246 190 14 246 190 14
46606 -246 186 14 230 174 11 210 150 10 163 110 8
46607 -104 69 6 10 10 10 2 2 6 2 2 6
46608 - 2 2 6 2 2 6 2 2 6 2 2 6
46609 - 2 2 6 2 2 6 2 2 6 2 2 6
46610 - 2 2 6 2 2 6 2 2 6 2 2 6
46611 - 2 2 6 6 6 6 91 60 6 167 114 7
46612 -206 145 10 230 174 11 242 186 14 246 190 14
46613 -246 190 14 246 190 14 246 186 14 242 186 14
46614 -239 182 13 230 174 11 224 166 10 213 154 11
46615 -180 133 36 124 112 88 86 86 86 58 58 58
46616 - 38 38 38 22 22 22 10 10 10 6 6 6
46617 - 0 0 0 0 0 0 0 0 0 0 0 0
46618 - 0 0 0 0 0 0 0 0 0 0 0 0
46619 - 0 0 0 0 0 0 0 0 0 0 0 0
46620 - 0 0 0 0 0 0 0 0 0 14 14 14
46621 - 34 34 34 70 70 70 138 110 50 158 118 36
46622 -167 114 7 180 123 7 192 133 9 197 138 11
46623 -200 144 11 206 145 10 213 154 11 219 162 10
46624 -224 166 10 230 174 11 239 182 13 242 186 14
46625 -246 186 14 246 186 14 246 186 14 246 186 14
46626 -239 182 13 216 158 10 185 133 11 152 99 6
46627 -104 69 6 18 14 6 2 2 6 2 2 6
46628 - 2 2 6 2 2 6 2 2 6 2 2 6
46629 - 2 2 6 2 2 6 2 2 6 2 2 6
46630 - 2 2 6 2 2 6 2 2 6 2 2 6
46631 - 2 2 6 6 6 6 80 54 7 152 99 6
46632 -192 133 9 219 162 10 236 178 12 239 182 13
46633 -246 186 14 242 186 14 239 182 13 236 178 12
46634 -224 166 10 206 145 10 192 133 9 154 121 60
46635 - 94 94 94 62 62 62 42 42 42 22 22 22
46636 - 14 14 14 6 6 6 0 0 0 0 0 0
46637 - 0 0 0 0 0 0 0 0 0 0 0 0
46638 - 0 0 0 0 0 0 0 0 0 0 0 0
46639 - 0 0 0 0 0 0 0 0 0 0 0 0
46640 - 0 0 0 0 0 0 0 0 0 6 6 6
46641 - 18 18 18 34 34 34 58 58 58 78 78 78
46642 -101 98 89 124 112 88 142 110 46 156 107 11
46643 -163 110 8 167 114 7 175 118 6 180 123 7
46644 -185 133 11 197 138 11 210 150 10 219 162 10
46645 -226 170 11 236 178 12 236 178 12 234 174 13
46646 -219 162 10 197 138 11 163 110 8 130 83 6
46647 - 91 60 6 10 10 10 2 2 6 2 2 6
46648 - 18 18 18 38 38 38 38 38 38 38 38 38
46649 - 38 38 38 38 38 38 38 38 38 38 38 38
46650 - 38 38 38 38 38 38 26 26 26 2 2 6
46651 - 2 2 6 6 6 6 70 47 6 137 92 6
46652 -175 118 6 200 144 11 219 162 10 230 174 11
46653 -234 174 13 230 174 11 219 162 10 210 150 10
46654 -192 133 9 163 110 8 124 112 88 82 82 82
46655 - 50 50 50 30 30 30 14 14 14 6 6 6
46656 - 0 0 0 0 0 0 0 0 0 0 0 0
46657 - 0 0 0 0 0 0 0 0 0 0 0 0
46658 - 0 0 0 0 0 0 0 0 0 0 0 0
46659 - 0 0 0 0 0 0 0 0 0 0 0 0
46660 - 0 0 0 0 0 0 0 0 0 0 0 0
46661 - 6 6 6 14 14 14 22 22 22 34 34 34
46662 - 42 42 42 58 58 58 74 74 74 86 86 86
46663 -101 98 89 122 102 70 130 98 46 121 87 25
46664 -137 92 6 152 99 6 163 110 8 180 123 7
46665 -185 133 11 197 138 11 206 145 10 200 144 11
46666 -180 123 7 156 107 11 130 83 6 104 69 6
46667 - 50 34 6 54 54 54 110 110 110 101 98 89
46668 - 86 86 86 82 82 82 78 78 78 78 78 78
46669 - 78 78 78 78 78 78 78 78 78 78 78 78
46670 - 78 78 78 82 82 82 86 86 86 94 94 94
46671 -106 106 106 101 101 101 86 66 34 124 80 6
46672 -156 107 11 180 123 7 192 133 9 200 144 11
46673 -206 145 10 200 144 11 192 133 9 175 118 6
46674 -139 102 15 109 106 95 70 70 70 42 42 42
46675 - 22 22 22 10 10 10 0 0 0 0 0 0
46676 - 0 0 0 0 0 0 0 0 0 0 0 0
46677 - 0 0 0 0 0 0 0 0 0 0 0 0
46678 - 0 0 0 0 0 0 0 0 0 0 0 0
46679 - 0 0 0 0 0 0 0 0 0 0 0 0
46680 - 0 0 0 0 0 0 0 0 0 0 0 0
46681 - 0 0 0 0 0 0 6 6 6 10 10 10
46682 - 14 14 14 22 22 22 30 30 30 38 38 38
46683 - 50 50 50 62 62 62 74 74 74 90 90 90
46684 -101 98 89 112 100 78 121 87 25 124 80 6
46685 -137 92 6 152 99 6 152 99 6 152 99 6
46686 -138 86 6 124 80 6 98 70 6 86 66 30
46687 -101 98 89 82 82 82 58 58 58 46 46 46
46688 - 38 38 38 34 34 34 34 34 34 34 34 34
46689 - 34 34 34 34 34 34 34 34 34 34 34 34
46690 - 34 34 34 34 34 34 38 38 38 42 42 42
46691 - 54 54 54 82 82 82 94 86 76 91 60 6
46692 -134 86 6 156 107 11 167 114 7 175 118 6
46693 -175 118 6 167 114 7 152 99 6 121 87 25
46694 -101 98 89 62 62 62 34 34 34 18 18 18
46695 - 6 6 6 0 0 0 0 0 0 0 0 0
46696 - 0 0 0 0 0 0 0 0 0 0 0 0
46697 - 0 0 0 0 0 0 0 0 0 0 0 0
46698 - 0 0 0 0 0 0 0 0 0 0 0 0
46699 - 0 0 0 0 0 0 0 0 0 0 0 0
46700 - 0 0 0 0 0 0 0 0 0 0 0 0
46701 - 0 0 0 0 0 0 0 0 0 0 0 0
46702 - 0 0 0 6 6 6 6 6 6 10 10 10
46703 - 18 18 18 22 22 22 30 30 30 42 42 42
46704 - 50 50 50 66 66 66 86 86 86 101 98 89
46705 -106 86 58 98 70 6 104 69 6 104 69 6
46706 -104 69 6 91 60 6 82 62 34 90 90 90
46707 - 62 62 62 38 38 38 22 22 22 14 14 14
46708 - 10 10 10 10 10 10 10 10 10 10 10 10
46709 - 10 10 10 10 10 10 6 6 6 10 10 10
46710 - 10 10 10 10 10 10 10 10 10 14 14 14
46711 - 22 22 22 42 42 42 70 70 70 89 81 66
46712 - 80 54 7 104 69 6 124 80 6 137 92 6
46713 -134 86 6 116 81 8 100 82 52 86 86 86
46714 - 58 58 58 30 30 30 14 14 14 6 6 6
46715 - 0 0 0 0 0 0 0 0 0 0 0 0
46716 - 0 0 0 0 0 0 0 0 0 0 0 0
46717 - 0 0 0 0 0 0 0 0 0 0 0 0
46718 - 0 0 0 0 0 0 0 0 0 0 0 0
46719 - 0 0 0 0 0 0 0 0 0 0 0 0
46720 - 0 0 0 0 0 0 0 0 0 0 0 0
46721 - 0 0 0 0 0 0 0 0 0 0 0 0
46722 - 0 0 0 0 0 0 0 0 0 0 0 0
46723 - 0 0 0 6 6 6 10 10 10 14 14 14
46724 - 18 18 18 26 26 26 38 38 38 54 54 54
46725 - 70 70 70 86 86 86 94 86 76 89 81 66
46726 - 89 81 66 86 86 86 74 74 74 50 50 50
46727 - 30 30 30 14 14 14 6 6 6 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 0 0 0 0 0 0 0 0 0
46731 - 6 6 6 18 18 18 34 34 34 58 58 58
46732 - 82 82 82 89 81 66 89 81 66 89 81 66
46733 - 94 86 66 94 86 76 74 74 74 50 50 50
46734 - 26 26 26 14 14 14 6 6 6 0 0 0
46735 - 0 0 0 0 0 0 0 0 0 0 0 0
46736 - 0 0 0 0 0 0 0 0 0 0 0 0
46737 - 0 0 0 0 0 0 0 0 0 0 0 0
46738 - 0 0 0 0 0 0 0 0 0 0 0 0
46739 - 0 0 0 0 0 0 0 0 0 0 0 0
46740 - 0 0 0 0 0 0 0 0 0 0 0 0
46741 - 0 0 0 0 0 0 0 0 0 0 0 0
46742 - 0 0 0 0 0 0 0 0 0 0 0 0
46743 - 0 0 0 0 0 0 0 0 0 0 0 0
46744 - 6 6 6 6 6 6 14 14 14 18 18 18
46745 - 30 30 30 38 38 38 46 46 46 54 54 54
46746 - 50 50 50 42 42 42 30 30 30 18 18 18
46747 - 10 10 10 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 14 14 14 26 26 26
46752 - 38 38 38 50 50 50 58 58 58 58 58 58
46753 - 54 54 54 42 42 42 30 30 30 18 18 18
46754 - 10 10 10 0 0 0 0 0 0 0 0 0
46755 - 0 0 0 0 0 0 0 0 0 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 - 0 0 0 0 0 0 0 0 0 0 0 0
46760 - 0 0 0 0 0 0 0 0 0 0 0 0
46761 - 0 0 0 0 0 0 0 0 0 0 0 0
46762 - 0 0 0 0 0 0 0 0 0 0 0 0
46763 - 0 0 0 0 0 0 0 0 0 0 0 0
46764 - 0 0 0 0 0 0 0 0 0 6 6 6
46765 - 6 6 6 10 10 10 14 14 14 18 18 18
46766 - 18 18 18 14 14 14 10 10 10 6 6 6
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 6 6 6
46772 - 14 14 14 18 18 18 22 22 22 22 22 22
46773 - 18 18 18 14 14 14 10 10 10 6 6 6
46774 - 0 0 0 0 0 0 0 0 0 0 0 0
46775 - 0 0 0 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 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46792 +4 4 4 4 4 4
46793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46794 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46802 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46804 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46805 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46806 +4 4 4 4 4 4
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 3 3 3 0 0 0 0 0 0
46868 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 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 1 1 1 0 0 0
46873 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46874 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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 2 2 2 0 0 0 3 4 3 26 28 28
46882 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46883 +5 5 5 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 3 3 3 0 0 0 1 1 1 6 6 6
46887 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46888 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46889 +1 1 1 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 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46896 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46897 +0 0 0 3 3 3 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 0 0 0 4 4 4 41 54 63 125 124 125
46901 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46902 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46903 +2 2 2 2 1 0 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 5 5 5 5 5 5 2 2 2 0 0 0
46909 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46910 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46911 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 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 5 5 5 5 5 5
46914 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46915 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46916 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46917 +37 51 59 2 0 0 1 1 1 4 5 5 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 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46923 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46924 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46925 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46926 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46927 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46928 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46929 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46930 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46931 +64 123 161 14 17 19 0 0 0 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 5 5 5
46936 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46937 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46938 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46939 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46940 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46941 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46942 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46943 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46944 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46945 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 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 5 5 5 3 3 3
46950 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46951 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46952 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46953 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46954 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46955 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46956 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46957 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46958 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46959 +31 91 132 3 6 7 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 2 2 2 0 0 0 4 0 0
46964 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46965 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46966 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46967 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46968 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46969 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46970 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46971 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46972 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46973 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 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 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46978 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46979 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46980 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46981 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46982 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46983 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46984 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46985 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46986 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46987 +1 1 2 4 3 3 4 4 4 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 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46992 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46993 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46994 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46995 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46996 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46997 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46998 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46999 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
47000 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
47001 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 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 3 3 3 0 0 0
47005 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
47006 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
47007 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
47008 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
47009 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
47010 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
47011 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
47012 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
47013 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
47014 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
47015 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
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 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
47019 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
47020 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
47021 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47022 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
47023 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
47024 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
47025 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
47026 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
47027 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
47028 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
47029 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
47030 +0 0 0 4 4 4
47031 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
47032 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
47033 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
47034 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
47035 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
47036 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
47037 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
47038 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
47039 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
47040 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
47041 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
47042 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
47043 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
47044 +2 0 0 0 0 0
47045 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
47046 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
47047 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
47048 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
47049 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
47050 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
47051 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
47052 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
47053 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
47054 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
47055 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
47056 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
47057 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
47058 +37 38 37 0 0 0
47059 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47060 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
47061 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
47062 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
47063 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
47064 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
47065 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
47066 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
47067 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
47068 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
47069 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
47070 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
47071 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
47072 +85 115 134 4 0 0
47073 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
47074 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
47075 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
47076 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
47077 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
47078 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
47079 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
47080 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
47081 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
47082 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
47083 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
47084 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
47085 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
47086 +60 73 81 4 0 0
47087 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
47088 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
47089 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
47090 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
47091 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
47092 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
47093 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
47094 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
47095 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
47096 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
47097 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
47098 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
47099 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
47100 +16 19 21 4 0 0
47101 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
47102 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
47103 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
47104 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
47105 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
47106 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
47107 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
47108 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
47109 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
47110 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
47111 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
47112 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
47113 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
47114 +4 0 0 4 3 3
47115 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
47116 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
47117 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
47118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
47119 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
47120 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
47121 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
47122 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
47123 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47124 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47125 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47126 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47127 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47128 +3 2 2 4 4 4
47129 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47130 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47131 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47132 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47133 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47134 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47135 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47136 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47137 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47138 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47139 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47140 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47141 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47142 +4 4 4 4 4 4
47143 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47144 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47145 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47146 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47147 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47148 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47149 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47150 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47151 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47152 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47153 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47154 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47155 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47156 +4 4 4 4 4 4
47157 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47158 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47159 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47160 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47161 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47162 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47163 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47164 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47165 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47166 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47167 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47168 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47169 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47170 +5 5 5 5 5 5
47171 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47172 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47173 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47174 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47175 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47176 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47177 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47178 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47179 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47180 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47181 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47182 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47183 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47184 +5 5 5 4 4 4
47185 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47186 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47187 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47188 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47189 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47190 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47191 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47192 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47193 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47194 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47195 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47196 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47197 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4
47199 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47200 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47201 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47202 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47203 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47204 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47205 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47206 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47207 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47208 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47209 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47210 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47211 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47212 +4 4 4 4 4 4
47213 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47214 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47215 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47216 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47217 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47218 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47219 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47220 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47221 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47222 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47223 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47224 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47225 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4
47227 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47228 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47229 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47230 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47231 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 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 136 185 209 90 154 193 26 108 161 22 40 52
47235 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47236 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47237 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47238 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47239 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4
47241 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47242 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47243 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47244 +90 154 193 64 123 161 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 90 154 193
47246 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47247 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47248 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47249 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47250 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47251 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47252 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47253 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4
47255 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47256 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47257 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47258 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47259 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47260 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47261 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47262 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47263 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47264 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47265 +6 6 6 4 0 0 6 6 6 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 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47270 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47271 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47272 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47273 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47274 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47275 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47276 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47277 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47278 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47279 +4 0 0 3 2 2 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 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47284 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47285 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47286 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47287 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47288 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47289 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47290 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47291 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47292 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47293 +4 0 0 4 3 3 5 5 5 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 60 73 81 167 166 167 174 174 174 163 162 163
47298 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47299 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47300 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47301 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47302 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47303 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47304 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47305 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47306 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47307 +4 0 0 4 3 3 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 167 166 167 174 174 174 166 165 166
47312 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47313 +5 5 5 4 3 3 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 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47316 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47317 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47318 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47319 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47320 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47321 +4 0 0 3 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 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47326 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47327 +5 5 5 4 4 4 1 1 2 6 10 14 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 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47331 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47332 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47333 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47334 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47335 +0 0 0 3 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 174 174 174 177 184 187 174 174 174
47340 +174 174 174 190 197 201 157 156 157 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 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47343 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47344 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47345 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47346 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47347 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47348 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47349 +0 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 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47354 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47355 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47356 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47357 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47358 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47359 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47360 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47361 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
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 177 184 187 193 200 203 174 174 174
47368 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47369 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47370 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47371 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47372 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47373 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47374 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47375 +4 4 4 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 190 197 201 174 174 174
47382 +177 184 187 193 200 203 163 162 163 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 10 87 144
47384 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47385 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47386 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47387 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47388 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47389 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
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 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47396 +190 197 201 193 200 203 165 164 165 37 38 37 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 16 89 141 18 97 151 18 97 151 10 87 144
47399 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47400 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47401 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47402 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 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 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47410 +190 197 201 193 200 203 165 164 165 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 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47413 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47414 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47415 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47416 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47417 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
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 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47424 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47425 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47426 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47427 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47428 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47429 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47430 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 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 220 221 221 174 174 174
47438 +190 197 201 205 212 215 167 166 167 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 10 87 144 22 40 52 1 1 2
47441 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47442 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47443 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47444 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47445 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
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 220 221 221 190 197 201 174 174 174
47452 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47453 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47454 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47455 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47456 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47457 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47458 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
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 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47467 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47468 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47469 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47470 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47471 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47472 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
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 26 28 28 4 0 0 4 3 3
47481 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47482 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47483 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47484 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47485 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47486 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47487 +4 4 4 5 5 5 4 4 4 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 190 197 201 41 54 63 4 0 0 2 2 2
47495 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47496 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47497 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47498 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47499 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47500 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47501 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
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 193 200 203 174 174 174
47508 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47509 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47510 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47511 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47512 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47513 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47514 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47515 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47516 +131 129 131 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 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47523 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47524 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47525 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47526 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47527 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47528 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47529 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47530 +125 124 125 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 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47536 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47537 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47538 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47539 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47540 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47541 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47542 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47543 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47544 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
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 26 28 28 156 155 156 220 221 221 220 221 221
47550 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47551 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47552 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47553 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47554 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47555 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47556 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47557 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47558 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47559 +0 0 0 4 4 4 4 4 4 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 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47564 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47565 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47566 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47567 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47568 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47569 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47570 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47571 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47572 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47573 +4 3 3 5 5 5 4 4 4 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 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47578 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47579 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47580 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47581 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47582 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47583 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47584 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47585 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47586 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47587 +5 5 5 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 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47592 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47593 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47594 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47595 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47596 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47597 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47598 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47599 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47600 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47601 +4 4 4 4 4 4 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 6 6 6 6 6 6 6 6 6
47606 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47607 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47608 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47609 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47610 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47611 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47612 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47613 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47614 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47615 +4 4 4 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 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47620 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47621 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47622 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47623 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47624 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47625 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47626 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47627 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47628 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
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 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47634 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47635 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47636 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47637 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47638 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47639 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47640 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47641 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47642 +4 3 3 5 5 5 4 4 4 4 4 4 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 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47648 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47649 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47650 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47651 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47652 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47653 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47654 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47655 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47656 +4 4 4 4 4 4 4 4 4 4 4 4 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 5 5 5 4 3 3 6 6 6 4 0 0
47662 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47663 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47664 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47665 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47666 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47667 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47668 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47669 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47670 +4 4 4 4 4 4 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 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47676 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47677 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47678 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47679 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47680 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47681 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47682 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47683 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
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 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47690 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47691 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47692 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47693 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47694 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47695 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47696 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47697 +4 4 4 4 4 4 4 4 4 4 4 4 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 4 4 4 4 4 4 5 5 5 4 3 3
47704 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47705 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47706 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47707 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47708 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47709 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47710 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47711 +4 4 4 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 4 4 4 4 4 4 4 4 4 5 5 5
47718 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47719 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47720 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47721 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47722 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47723 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47724 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
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 4 4 4 4 4 4
47732 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47733 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47734 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47735 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47736 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47737 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47738 +6 6 6 6 6 6 4 3 3 5 5 5 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 4 4 4
47746 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47747 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47748 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47749 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47750 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47751 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47752 +5 5 5 5 5 5 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47761 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47762 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47763 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47764 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47765 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47766 +4 3 3 5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
47775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47776 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47777 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47778 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47779 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47780 +4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47790 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47791 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47792 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47793 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47794 +4 4 4 4 4 4 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 4 4 4
47804 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47805 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47806 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47807 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
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 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47819 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47820 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47821 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
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 4 4 4 4 4 4 4 4 4 5 5 5
47833 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47834 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47835 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4
47847 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47848 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47849 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 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 4 4 4
47861 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47862 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47863 +5 5 5 4 4 4 4 4 4 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 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
47876 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47877 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47878 +4 4 4 4 4 4 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 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47890 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47891 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47892 +4 4 4 4 4 4 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 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47900 index fe92eed..106e085 100644
47901 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47902 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47903 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47904 struct mb862xxfb_par *par = info->par;
47905
47906 if (info->var.bits_per_pixel == 32) {
47907 - info->fbops->fb_fillrect = cfb_fillrect;
47908 - info->fbops->fb_copyarea = cfb_copyarea;
47909 - info->fbops->fb_imageblit = cfb_imageblit;
47910 + pax_open_kernel();
47911 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47912 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47913 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47914 + pax_close_kernel();
47915 } else {
47916 outreg(disp, GC_L0EM, 3);
47917 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47918 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47919 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47920 + pax_open_kernel();
47921 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47922 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47923 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47924 + pax_close_kernel();
47925 }
47926 outreg(draw, GDC_REG_DRAW_BASE, 0);
47927 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47928 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47929 index ff22871..b129bed 100644
47930 --- a/drivers/video/nvidia/nvidia.c
47931 +++ b/drivers/video/nvidia/nvidia.c
47932 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47933 info->fix.line_length = (info->var.xres_virtual *
47934 info->var.bits_per_pixel) >> 3;
47935 if (info->var.accel_flags) {
47936 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47937 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47938 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47939 - info->fbops->fb_sync = nvidiafb_sync;
47940 + pax_open_kernel();
47941 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47942 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47943 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47944 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47945 + pax_close_kernel();
47946 info->pixmap.scan_align = 4;
47947 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47948 info->flags |= FBINFO_READS_FAST;
47949 NVResetGraphics(info);
47950 } else {
47951 - info->fbops->fb_imageblit = cfb_imageblit;
47952 - info->fbops->fb_fillrect = cfb_fillrect;
47953 - info->fbops->fb_copyarea = cfb_copyarea;
47954 - info->fbops->fb_sync = NULL;
47955 + pax_open_kernel();
47956 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47957 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47958 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47959 + *(void **)&info->fbops->fb_sync = NULL;
47960 + pax_close_kernel();
47961 info->pixmap.scan_align = 1;
47962 info->flags |= FBINFO_HWACCEL_DISABLED;
47963 info->flags &= ~FBINFO_READS_FAST;
47964 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47965 info->pixmap.size = 8 * 1024;
47966 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47967
47968 - if (!hwcur)
47969 - info->fbops->fb_cursor = NULL;
47970 + if (!hwcur) {
47971 + pax_open_kernel();
47972 + *(void **)&info->fbops->fb_cursor = NULL;
47973 + pax_close_kernel();
47974 + }
47975
47976 info->var.accel_flags = (!noaccel);
47977
47978 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47979 index 76d9053..dec2bfd 100644
47980 --- a/drivers/video/s1d13xxxfb.c
47981 +++ b/drivers/video/s1d13xxxfb.c
47982 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47983
47984 switch(prod_id) {
47985 case S1D13506_PROD_ID: /* activate acceleration */
47986 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47987 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47988 + pax_open_kernel();
47989 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47990 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47991 + pax_close_kernel();
47992 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47993 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47994 break;
47995 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47996 index 97bd662..39fab85 100644
47997 --- a/drivers/video/smscufx.c
47998 +++ b/drivers/video/smscufx.c
47999 @@ -1171,7 +1171,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
48000 fb_deferred_io_cleanup(info);
48001 kfree(info->fbdefio);
48002 info->fbdefio = NULL;
48003 - info->fbops->fb_mmap = ufx_ops_mmap;
48004 + pax_open_kernel();
48005 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
48006 + pax_close_kernel();
48007 }
48008
48009 pr_debug("released /dev/fb%d user=%d count=%d",
48010 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
48011 index 86d449e..8e04dc5 100644
48012 --- a/drivers/video/udlfb.c
48013 +++ b/drivers/video/udlfb.c
48014 @@ -619,11 +619,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
48015 dlfb_urb_completion(urb);
48016
48017 error:
48018 - atomic_add(bytes_sent, &dev->bytes_sent);
48019 - atomic_add(bytes_identical, &dev->bytes_identical);
48020 - atomic_add(width*height*2, &dev->bytes_rendered);
48021 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48022 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48023 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
48024 end_cycles = get_cycles();
48025 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48026 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48027 >> 10)), /* Kcycles */
48028 &dev->cpu_kcycles_used);
48029
48030 @@ -744,11 +744,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
48031 dlfb_urb_completion(urb);
48032
48033 error:
48034 - atomic_add(bytes_sent, &dev->bytes_sent);
48035 - atomic_add(bytes_identical, &dev->bytes_identical);
48036 - atomic_add(bytes_rendered, &dev->bytes_rendered);
48037 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
48038 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
48039 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
48040 end_cycles = get_cycles();
48041 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
48042 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
48043 >> 10)), /* Kcycles */
48044 &dev->cpu_kcycles_used);
48045 }
48046 @@ -989,7 +989,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
48047 fb_deferred_io_cleanup(info);
48048 kfree(info->fbdefio);
48049 info->fbdefio = NULL;
48050 - info->fbops->fb_mmap = dlfb_ops_mmap;
48051 + pax_open_kernel();
48052 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
48053 + pax_close_kernel();
48054 }
48055
48056 pr_warn("released /dev/fb%d user=%d count=%d\n",
48057 @@ -1372,7 +1374,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
48058 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48059 struct dlfb_data *dev = fb_info->par;
48060 return snprintf(buf, PAGE_SIZE, "%u\n",
48061 - atomic_read(&dev->bytes_rendered));
48062 + atomic_read_unchecked(&dev->bytes_rendered));
48063 }
48064
48065 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48066 @@ -1380,7 +1382,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
48067 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48068 struct dlfb_data *dev = fb_info->par;
48069 return snprintf(buf, PAGE_SIZE, "%u\n",
48070 - atomic_read(&dev->bytes_identical));
48071 + atomic_read_unchecked(&dev->bytes_identical));
48072 }
48073
48074 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48075 @@ -1388,7 +1390,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
48076 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48077 struct dlfb_data *dev = fb_info->par;
48078 return snprintf(buf, PAGE_SIZE, "%u\n",
48079 - atomic_read(&dev->bytes_sent));
48080 + atomic_read_unchecked(&dev->bytes_sent));
48081 }
48082
48083 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48084 @@ -1396,7 +1398,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
48085 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48086 struct dlfb_data *dev = fb_info->par;
48087 return snprintf(buf, PAGE_SIZE, "%u\n",
48088 - atomic_read(&dev->cpu_kcycles_used));
48089 + atomic_read_unchecked(&dev->cpu_kcycles_used));
48090 }
48091
48092 static ssize_t edid_show(
48093 @@ -1456,10 +1458,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
48094 struct fb_info *fb_info = dev_get_drvdata(fbdev);
48095 struct dlfb_data *dev = fb_info->par;
48096
48097 - atomic_set(&dev->bytes_rendered, 0);
48098 - atomic_set(&dev->bytes_identical, 0);
48099 - atomic_set(&dev->bytes_sent, 0);
48100 - atomic_set(&dev->cpu_kcycles_used, 0);
48101 + atomic_set_unchecked(&dev->bytes_rendered, 0);
48102 + atomic_set_unchecked(&dev->bytes_identical, 0);
48103 + atomic_set_unchecked(&dev->bytes_sent, 0);
48104 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
48105
48106 return count;
48107 }
48108 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
48109 index b75db01..ad2f34a 100644
48110 --- a/drivers/video/uvesafb.c
48111 +++ b/drivers/video/uvesafb.c
48112 @@ -19,6 +19,7 @@
48113 #include <linux/io.h>
48114 #include <linux/mutex.h>
48115 #include <linux/slab.h>
48116 +#include <linux/moduleloader.h>
48117 #include <video/edid.h>
48118 #include <video/uvesafb.h>
48119 #ifdef CONFIG_X86
48120 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48121 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48122 par->pmi_setpal = par->ypan = 0;
48123 } else {
48124 +
48125 +#ifdef CONFIG_PAX_KERNEXEC
48126 +#ifdef CONFIG_MODULES
48127 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48128 +#endif
48129 + if (!par->pmi_code) {
48130 + par->pmi_setpal = par->ypan = 0;
48131 + return 0;
48132 + }
48133 +#endif
48134 +
48135 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48136 + task->t.regs.edi);
48137 +
48138 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48139 + pax_open_kernel();
48140 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48141 + pax_close_kernel();
48142 +
48143 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48144 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48145 +#else
48146 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48147 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48148 +#endif
48149 +
48150 printk(KERN_INFO "uvesafb: protected mode interface info at "
48151 "%04x:%04x\n",
48152 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48153 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48154 par->ypan = ypan;
48155
48156 if (par->pmi_setpal || par->ypan) {
48157 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48158 if (__supported_pte_mask & _PAGE_NX) {
48159 par->pmi_setpal = par->ypan = 0;
48160 printk(KERN_WARNING "uvesafb: NX protection is actively."
48161 "We have better not to use the PMI.\n");
48162 - } else {
48163 + } else
48164 +#endif
48165 uvesafb_vbe_getpmi(task, par);
48166 - }
48167 }
48168 #else
48169 /* The protected mode interface is not available on non-x86. */
48170 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48171 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48172
48173 /* Disable blanking if the user requested so. */
48174 - if (!blank)
48175 - info->fbops->fb_blank = NULL;
48176 + if (!blank) {
48177 + pax_open_kernel();
48178 + *(void **)&info->fbops->fb_blank = NULL;
48179 + pax_close_kernel();
48180 + }
48181
48182 /*
48183 * Find out how much IO memory is required for the mode with
48184 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48185 info->flags = FBINFO_FLAG_DEFAULT |
48186 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48187
48188 - if (!par->ypan)
48189 - info->fbops->fb_pan_display = NULL;
48190 + if (!par->ypan) {
48191 + pax_open_kernel();
48192 + *(void **)&info->fbops->fb_pan_display = NULL;
48193 + pax_close_kernel();
48194 + }
48195 }
48196
48197 static void uvesafb_init_mtrr(struct fb_info *info)
48198 @@ -1836,6 +1866,11 @@ out:
48199 if (par->vbe_modes)
48200 kfree(par->vbe_modes);
48201
48202 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48203 + if (par->pmi_code)
48204 + module_free_exec(NULL, par->pmi_code);
48205 +#endif
48206 +
48207 framebuffer_release(info);
48208 return err;
48209 }
48210 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48211 kfree(par->vbe_state_orig);
48212 if (par->vbe_state_saved)
48213 kfree(par->vbe_state_saved);
48214 +
48215 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48216 + if (par->pmi_code)
48217 + module_free_exec(NULL, par->pmi_code);
48218 +#endif
48219 +
48220 }
48221
48222 framebuffer_release(info);
48223 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48224 index 501b340..d80aa17 100644
48225 --- a/drivers/video/vesafb.c
48226 +++ b/drivers/video/vesafb.c
48227 @@ -9,6 +9,7 @@
48228 */
48229
48230 #include <linux/module.h>
48231 +#include <linux/moduleloader.h>
48232 #include <linux/kernel.h>
48233 #include <linux/errno.h>
48234 #include <linux/string.h>
48235 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48236 static int vram_total __initdata; /* Set total amount of memory */
48237 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48238 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48239 -static void (*pmi_start)(void) __read_mostly;
48240 -static void (*pmi_pal) (void) __read_mostly;
48241 +static void (*pmi_start)(void) __read_only;
48242 +static void (*pmi_pal) (void) __read_only;
48243 static int depth __read_mostly;
48244 static int vga_compat __read_mostly;
48245 /* --------------------------------------------------------------------- */
48246 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48247 unsigned int size_vmode;
48248 unsigned int size_remap;
48249 unsigned int size_total;
48250 + void *pmi_code = NULL;
48251
48252 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48253 return -ENODEV;
48254 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48255 size_remap = size_total;
48256 vesafb_fix.smem_len = size_remap;
48257
48258 -#ifndef __i386__
48259 - screen_info.vesapm_seg = 0;
48260 -#endif
48261 -
48262 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48263 printk(KERN_WARNING
48264 "vesafb: cannot reserve video memory at 0x%lx\n",
48265 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48266 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48267 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48268
48269 +#ifdef __i386__
48270 +
48271 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48272 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48273 + if (!pmi_code)
48274 +#elif !defined(CONFIG_PAX_KERNEXEC)
48275 + if (0)
48276 +#endif
48277 +
48278 +#endif
48279 + screen_info.vesapm_seg = 0;
48280 +
48281 if (screen_info.vesapm_seg) {
48282 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48283 - screen_info.vesapm_seg,screen_info.vesapm_off);
48284 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48285 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48286 }
48287
48288 if (screen_info.vesapm_seg < 0xc000)
48289 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48290
48291 if (ypan || pmi_setpal) {
48292 unsigned short *pmi_base;
48293 +
48294 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48295 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48296 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48297 +
48298 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48299 + pax_open_kernel();
48300 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48301 +#else
48302 + pmi_code = pmi_base;
48303 +#endif
48304 +
48305 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48306 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48307 +
48308 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48309 + pmi_start = ktva_ktla(pmi_start);
48310 + pmi_pal = ktva_ktla(pmi_pal);
48311 + pax_close_kernel();
48312 +#endif
48313 +
48314 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48315 if (pmi_base[3]) {
48316 printk(KERN_INFO "vesafb: pmi: ports = ");
48317 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48318 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48319 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48320
48321 - if (!ypan)
48322 - info->fbops->fb_pan_display = NULL;
48323 + if (!ypan) {
48324 + pax_open_kernel();
48325 + *(void **)&info->fbops->fb_pan_display = NULL;
48326 + pax_close_kernel();
48327 + }
48328
48329 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48330 err = -ENOMEM;
48331 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48332 info->node, info->fix.id);
48333 return 0;
48334 err:
48335 +
48336 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48337 + module_free_exec(NULL, pmi_code);
48338 +#endif
48339 +
48340 if (info->screen_base)
48341 iounmap(info->screen_base);
48342 framebuffer_release(info);
48343 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48344 index 88714ae..16c2e11 100644
48345 --- a/drivers/video/via/via_clock.h
48346 +++ b/drivers/video/via/via_clock.h
48347 @@ -56,7 +56,7 @@ struct via_clock {
48348
48349 void (*set_engine_pll_state)(u8 state);
48350 void (*set_engine_pll)(struct via_pll_config config);
48351 -};
48352 +} __no_const;
48353
48354
48355 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48356 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48357 index fef20db..d28b1ab 100644
48358 --- a/drivers/xen/xenfs/xenstored.c
48359 +++ b/drivers/xen/xenfs/xenstored.c
48360 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48361 static int xsd_kva_open(struct inode *inode, struct file *file)
48362 {
48363 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48364 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48365 + NULL);
48366 +#else
48367 xen_store_interface);
48368 +#endif
48369 +
48370 if (!file->private_data)
48371 return -ENOMEM;
48372 return 0;
48373 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48374 index 890bed5..17ae73e 100644
48375 --- a/fs/9p/vfs_inode.c
48376 +++ b/fs/9p/vfs_inode.c
48377 @@ -1329,7 +1329,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48378 void
48379 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48380 {
48381 - char *s = nd_get_link(nd);
48382 + const char *s = nd_get_link(nd);
48383
48384 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48385 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48386 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48387 index 0efd152..b5802ad 100644
48388 --- a/fs/Kconfig.binfmt
48389 +++ b/fs/Kconfig.binfmt
48390 @@ -89,7 +89,7 @@ config HAVE_AOUT
48391
48392 config BINFMT_AOUT
48393 tristate "Kernel support for a.out and ECOFF binaries"
48394 - depends on HAVE_AOUT
48395 + depends on HAVE_AOUT && BROKEN
48396 ---help---
48397 A.out (Assembler.OUTput) is a set of formats for libraries and
48398 executables used in the earliest versions of UNIX. Linux used
48399 diff --git a/fs/aio.c b/fs/aio.c
48400 index 71f613c..9d01f1f 100644
48401 --- a/fs/aio.c
48402 +++ b/fs/aio.c
48403 @@ -111,7 +111,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48404 size += sizeof(struct io_event) * nr_events;
48405 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48406
48407 - if (nr_pages < 0)
48408 + if (nr_pages <= 0)
48409 return -EINVAL;
48410
48411 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48412 @@ -1373,18 +1373,19 @@ static ssize_t aio_fsync(struct kiocb *iocb)
48413 static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48414 {
48415 ssize_t ret;
48416 + struct iovec iovstack;
48417
48418 #ifdef CONFIG_COMPAT
48419 if (compat)
48420 ret = compat_rw_copy_check_uvector(type,
48421 (struct compat_iovec __user *)kiocb->ki_buf,
48422 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48423 + kiocb->ki_nbytes, 1, &iovstack,
48424 &kiocb->ki_iovec);
48425 else
48426 #endif
48427 ret = rw_copy_check_uvector(type,
48428 (struct iovec __user *)kiocb->ki_buf,
48429 - kiocb->ki_nbytes, 1, &kiocb->ki_inline_vec,
48430 + kiocb->ki_nbytes, 1, &iovstack,
48431 &kiocb->ki_iovec);
48432 if (ret < 0)
48433 goto out;
48434 @@ -1393,6 +1394,10 @@ static ssize_t aio_setup_vectored_rw(int type, struct kiocb *kiocb, bool compat)
48435 if (ret < 0)
48436 goto out;
48437
48438 + if (kiocb->ki_iovec == &iovstack) {
48439 + kiocb->ki_inline_vec = iovstack;
48440 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48441 + }
48442 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48443 kiocb->ki_cur_seg = 0;
48444 /* ki_nbytes/left now reflect bytes instead of segs */
48445 diff --git a/fs/attr.c b/fs/attr.c
48446 index 1449adb..a2038c2 100644
48447 --- a/fs/attr.c
48448 +++ b/fs/attr.c
48449 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48450 unsigned long limit;
48451
48452 limit = rlimit(RLIMIT_FSIZE);
48453 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48454 if (limit != RLIM_INFINITY && offset > limit)
48455 goto out_sig;
48456 if (offset > inode->i_sb->s_maxbytes)
48457 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48458 index 03bc1d3..6205356 100644
48459 --- a/fs/autofs4/waitq.c
48460 +++ b/fs/autofs4/waitq.c
48461 @@ -61,7 +61,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48462 {
48463 unsigned long sigpipe, flags;
48464 mm_segment_t fs;
48465 - const char *data = (const char *)addr;
48466 + const char __user *data = (const char __force_user *)addr;
48467 ssize_t wr = 0;
48468
48469 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48470 @@ -348,6 +348,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48471 return 1;
48472 }
48473
48474 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48475 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48476 +#endif
48477 +
48478 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48479 enum autofs_notify notify)
48480 {
48481 @@ -381,7 +385,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48482
48483 /* If this is a direct mount request create a dummy name */
48484 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48485 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48486 + /* this name does get written to userland via autofs4_write() */
48487 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48488 +#else
48489 qstr.len = sprintf(name, "%p", dentry);
48490 +#endif
48491 else {
48492 qstr.len = autofs4_getpath(sbi, dentry, &name);
48493 if (!qstr.len) {
48494 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48495 index 2722387..c8dd2a7 100644
48496 --- a/fs/befs/endian.h
48497 +++ b/fs/befs/endian.h
48498 @@ -11,7 +11,7 @@
48499
48500 #include <asm/byteorder.h>
48501
48502 -static inline u64
48503 +static inline u64 __intentional_overflow(-1)
48504 fs64_to_cpu(const struct super_block *sb, fs64 n)
48505 {
48506 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48507 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48508 return (__force fs64)cpu_to_be64(n);
48509 }
48510
48511 -static inline u32
48512 +static inline u32 __intentional_overflow(-1)
48513 fs32_to_cpu(const struct super_block *sb, fs32 n)
48514 {
48515 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48516 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48517 index 2b3bda8..6a2d4be 100644
48518 --- a/fs/befs/linuxvfs.c
48519 +++ b/fs/befs/linuxvfs.c
48520 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48521 {
48522 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48523 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48524 - char *link = nd_get_link(nd);
48525 + const char *link = nd_get_link(nd);
48526 if (!IS_ERR(link))
48527 kfree(link);
48528 }
48529 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48530 index 6043567..16a9239 100644
48531 --- a/fs/binfmt_aout.c
48532 +++ b/fs/binfmt_aout.c
48533 @@ -16,6 +16,7 @@
48534 #include <linux/string.h>
48535 #include <linux/fs.h>
48536 #include <linux/file.h>
48537 +#include <linux/security.h>
48538 #include <linux/stat.h>
48539 #include <linux/fcntl.h>
48540 #include <linux/ptrace.h>
48541 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48542 #endif
48543 # define START_STACK(u) ((void __user *)u.start_stack)
48544
48545 + memset(&dump, 0, sizeof(dump));
48546 +
48547 fs = get_fs();
48548 set_fs(KERNEL_DS);
48549 has_dumped = 1;
48550 @@ -70,10 +73,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48551
48552 /* If the size of the dump file exceeds the rlimit, then see what would happen
48553 if we wrote the stack, but not the data area. */
48554 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48555 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48556 dump.u_dsize = 0;
48557
48558 /* Make sure we have enough room to write the stack and data areas. */
48559 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48560 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48561 dump.u_ssize = 0;
48562
48563 @@ -234,6 +239,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48564 rlim = rlimit(RLIMIT_DATA);
48565 if (rlim >= RLIM_INFINITY)
48566 rlim = ~0;
48567 +
48568 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48569 if (ex.a_data + ex.a_bss > rlim)
48570 return -ENOMEM;
48571
48572 @@ -268,6 +275,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48573
48574 install_exec_creds(bprm);
48575
48576 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48577 + current->mm->pax_flags = 0UL;
48578 +#endif
48579 +
48580 +#ifdef CONFIG_PAX_PAGEEXEC
48581 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48582 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48583 +
48584 +#ifdef CONFIG_PAX_EMUTRAMP
48585 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48586 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48587 +#endif
48588 +
48589 +#ifdef CONFIG_PAX_MPROTECT
48590 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48591 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48592 +#endif
48593 +
48594 + }
48595 +#endif
48596 +
48597 if (N_MAGIC(ex) == OMAGIC) {
48598 unsigned long text_addr, map_size;
48599 loff_t pos;
48600 @@ -333,7 +361,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48601 }
48602
48603 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48604 - PROT_READ | PROT_WRITE | PROT_EXEC,
48605 + PROT_READ | PROT_WRITE,
48606 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48607 fd_offset + ex.a_text);
48608 if (error != N_DATADDR(ex)) {
48609 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48610 index 0c42cdb..b62581e9 100644
48611 --- a/fs/binfmt_elf.c
48612 +++ b/fs/binfmt_elf.c
48613 @@ -33,6 +33,7 @@
48614 #include <linux/elf.h>
48615 #include <linux/utsname.h>
48616 #include <linux/coredump.h>
48617 +#include <linux/xattr.h>
48618 #include <asm/uaccess.h>
48619 #include <asm/param.h>
48620 #include <asm/page.h>
48621 @@ -59,6 +60,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48622 #define elf_core_dump NULL
48623 #endif
48624
48625 +#ifdef CONFIG_PAX_MPROTECT
48626 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48627 +#endif
48628 +
48629 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48630 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48631 #else
48632 @@ -78,6 +83,11 @@ static struct linux_binfmt elf_format = {
48633 .load_binary = load_elf_binary,
48634 .load_shlib = load_elf_library,
48635 .core_dump = elf_core_dump,
48636 +
48637 +#ifdef CONFIG_PAX_MPROTECT
48638 + .handle_mprotect= elf_handle_mprotect,
48639 +#endif
48640 +
48641 .min_coredump = ELF_EXEC_PAGESIZE,
48642 };
48643
48644 @@ -85,6 +95,8 @@ static struct linux_binfmt elf_format = {
48645
48646 static int set_brk(unsigned long start, unsigned long end)
48647 {
48648 + unsigned long e = end;
48649 +
48650 start = ELF_PAGEALIGN(start);
48651 end = ELF_PAGEALIGN(end);
48652 if (end > start) {
48653 @@ -93,7 +105,7 @@ static int set_brk(unsigned long start, unsigned long end)
48654 if (BAD_ADDR(addr))
48655 return addr;
48656 }
48657 - current->mm->start_brk = current->mm->brk = end;
48658 + current->mm->start_brk = current->mm->brk = e;
48659 return 0;
48660 }
48661
48662 @@ -154,12 +166,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48663 elf_addr_t __user *u_rand_bytes;
48664 const char *k_platform = ELF_PLATFORM;
48665 const char *k_base_platform = ELF_BASE_PLATFORM;
48666 - unsigned char k_rand_bytes[16];
48667 + u32 k_rand_bytes[4];
48668 int items;
48669 elf_addr_t *elf_info;
48670 int ei_index = 0;
48671 const struct cred *cred = current_cred();
48672 struct vm_area_struct *vma;
48673 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48674
48675 /*
48676 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48677 @@ -201,8 +214,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48678 * Generate 16 random bytes for userspace PRNG seeding.
48679 */
48680 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48681 - u_rand_bytes = (elf_addr_t __user *)
48682 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48683 + srandom32(k_rand_bytes[0] ^ random32());
48684 + srandom32(k_rand_bytes[1] ^ random32());
48685 + srandom32(k_rand_bytes[2] ^ random32());
48686 + srandom32(k_rand_bytes[3] ^ random32());
48687 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48688 + u_rand_bytes = (elf_addr_t __user *) p;
48689 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48690 return -EFAULT;
48691
48692 @@ -314,9 +331,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48693 return -EFAULT;
48694 current->mm->env_end = p;
48695
48696 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48697 +
48698 /* Put the elf_info on the stack in the right place. */
48699 sp = (elf_addr_t __user *)envp + 1;
48700 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48701 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48702 return -EFAULT;
48703 return 0;
48704 }
48705 @@ -380,15 +399,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48706 an ELF header */
48707
48708 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48709 - struct file *interpreter, unsigned long *interp_map_addr,
48710 - unsigned long no_base)
48711 + struct file *interpreter, unsigned long no_base)
48712 {
48713 struct elf_phdr *elf_phdata;
48714 struct elf_phdr *eppnt;
48715 - unsigned long load_addr = 0;
48716 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48717 int load_addr_set = 0;
48718 unsigned long last_bss = 0, elf_bss = 0;
48719 - unsigned long error = ~0UL;
48720 + unsigned long error = -EINVAL;
48721 unsigned long total_size;
48722 int retval, i, size;
48723
48724 @@ -434,6 +452,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48725 goto out_close;
48726 }
48727
48728 +#ifdef CONFIG_PAX_SEGMEXEC
48729 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48730 + pax_task_size = SEGMEXEC_TASK_SIZE;
48731 +#endif
48732 +
48733 eppnt = elf_phdata;
48734 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48735 if (eppnt->p_type == PT_LOAD) {
48736 @@ -457,8 +480,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48737 map_addr = elf_map(interpreter, load_addr + vaddr,
48738 eppnt, elf_prot, elf_type, total_size);
48739 total_size = 0;
48740 - if (!*interp_map_addr)
48741 - *interp_map_addr = map_addr;
48742 error = map_addr;
48743 if (BAD_ADDR(map_addr))
48744 goto out_close;
48745 @@ -477,8 +498,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48746 k = load_addr + eppnt->p_vaddr;
48747 if (BAD_ADDR(k) ||
48748 eppnt->p_filesz > eppnt->p_memsz ||
48749 - eppnt->p_memsz > TASK_SIZE ||
48750 - TASK_SIZE - eppnt->p_memsz < k) {
48751 + eppnt->p_memsz > pax_task_size ||
48752 + pax_task_size - eppnt->p_memsz < k) {
48753 error = -ENOMEM;
48754 goto out_close;
48755 }
48756 @@ -530,6 +551,315 @@ out:
48757 return error;
48758 }
48759
48760 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48761 +#ifdef CONFIG_PAX_SOFTMODE
48762 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48763 +{
48764 + unsigned long pax_flags = 0UL;
48765 +
48766 +#ifdef CONFIG_PAX_PAGEEXEC
48767 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48768 + pax_flags |= MF_PAX_PAGEEXEC;
48769 +#endif
48770 +
48771 +#ifdef CONFIG_PAX_SEGMEXEC
48772 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48773 + pax_flags |= MF_PAX_SEGMEXEC;
48774 +#endif
48775 +
48776 +#ifdef CONFIG_PAX_EMUTRAMP
48777 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48778 + pax_flags |= MF_PAX_EMUTRAMP;
48779 +#endif
48780 +
48781 +#ifdef CONFIG_PAX_MPROTECT
48782 + if (elf_phdata->p_flags & PF_MPROTECT)
48783 + pax_flags |= MF_PAX_MPROTECT;
48784 +#endif
48785 +
48786 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48787 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48788 + pax_flags |= MF_PAX_RANDMMAP;
48789 +#endif
48790 +
48791 + return pax_flags;
48792 +}
48793 +#endif
48794 +
48795 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48796 +{
48797 + unsigned long pax_flags = 0UL;
48798 +
48799 +#ifdef CONFIG_PAX_PAGEEXEC
48800 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48801 + pax_flags |= MF_PAX_PAGEEXEC;
48802 +#endif
48803 +
48804 +#ifdef CONFIG_PAX_SEGMEXEC
48805 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48806 + pax_flags |= MF_PAX_SEGMEXEC;
48807 +#endif
48808 +
48809 +#ifdef CONFIG_PAX_EMUTRAMP
48810 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48811 + pax_flags |= MF_PAX_EMUTRAMP;
48812 +#endif
48813 +
48814 +#ifdef CONFIG_PAX_MPROTECT
48815 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48816 + pax_flags |= MF_PAX_MPROTECT;
48817 +#endif
48818 +
48819 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48820 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48821 + pax_flags |= MF_PAX_RANDMMAP;
48822 +#endif
48823 +
48824 + return pax_flags;
48825 +}
48826 +#endif
48827 +
48828 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48829 +#ifdef CONFIG_PAX_SOFTMODE
48830 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48831 +{
48832 + unsigned long pax_flags = 0UL;
48833 +
48834 +#ifdef CONFIG_PAX_PAGEEXEC
48835 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48836 + pax_flags |= MF_PAX_PAGEEXEC;
48837 +#endif
48838 +
48839 +#ifdef CONFIG_PAX_SEGMEXEC
48840 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48841 + pax_flags |= MF_PAX_SEGMEXEC;
48842 +#endif
48843 +
48844 +#ifdef CONFIG_PAX_EMUTRAMP
48845 + if (pax_flags_softmode & MF_PAX_EMUTRAMP)
48846 + pax_flags |= MF_PAX_EMUTRAMP;
48847 +#endif
48848 +
48849 +#ifdef CONFIG_PAX_MPROTECT
48850 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48851 + pax_flags |= MF_PAX_MPROTECT;
48852 +#endif
48853 +
48854 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48855 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48856 + pax_flags |= MF_PAX_RANDMMAP;
48857 +#endif
48858 +
48859 + return pax_flags;
48860 +}
48861 +#endif
48862 +
48863 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48864 +{
48865 + unsigned long pax_flags = 0UL;
48866 +
48867 +#ifdef CONFIG_PAX_PAGEEXEC
48868 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48869 + pax_flags |= MF_PAX_PAGEEXEC;
48870 +#endif
48871 +
48872 +#ifdef CONFIG_PAX_SEGMEXEC
48873 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48874 + pax_flags |= MF_PAX_SEGMEXEC;
48875 +#endif
48876 +
48877 +#ifdef CONFIG_PAX_EMUTRAMP
48878 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48879 + pax_flags |= MF_PAX_EMUTRAMP;
48880 +#endif
48881 +
48882 +#ifdef CONFIG_PAX_MPROTECT
48883 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48884 + pax_flags |= MF_PAX_MPROTECT;
48885 +#endif
48886 +
48887 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48888 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48889 + pax_flags |= MF_PAX_RANDMMAP;
48890 +#endif
48891 +
48892 + return pax_flags;
48893 +}
48894 +#endif
48895 +
48896 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48897 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48898 +{
48899 + unsigned long pax_flags = 0UL;
48900 +
48901 +#ifdef CONFIG_PAX_EI_PAX
48902 +
48903 +#ifdef CONFIG_PAX_PAGEEXEC
48904 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48905 + pax_flags |= MF_PAX_PAGEEXEC;
48906 +#endif
48907 +
48908 +#ifdef CONFIG_PAX_SEGMEXEC
48909 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48910 + pax_flags |= MF_PAX_SEGMEXEC;
48911 +#endif
48912 +
48913 +#ifdef CONFIG_PAX_EMUTRAMP
48914 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48915 + pax_flags |= MF_PAX_EMUTRAMP;
48916 +#endif
48917 +
48918 +#ifdef CONFIG_PAX_MPROTECT
48919 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48920 + pax_flags |= MF_PAX_MPROTECT;
48921 +#endif
48922 +
48923 +#ifdef CONFIG_PAX_ASLR
48924 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48925 + pax_flags |= MF_PAX_RANDMMAP;
48926 +#endif
48927 +
48928 +#else
48929 +
48930 +#ifdef CONFIG_PAX_PAGEEXEC
48931 + pax_flags |= MF_PAX_PAGEEXEC;
48932 +#endif
48933 +
48934 +#ifdef CONFIG_PAX_SEGMEXEC
48935 + pax_flags |= MF_PAX_SEGMEXEC;
48936 +#endif
48937 +
48938 +#ifdef CONFIG_PAX_MPROTECT
48939 + pax_flags |= MF_PAX_MPROTECT;
48940 +#endif
48941 +
48942 +#ifdef CONFIG_PAX_RANDMMAP
48943 + if (randomize_va_space)
48944 + pax_flags |= MF_PAX_RANDMMAP;
48945 +#endif
48946 +
48947 +#endif
48948 +
48949 + return pax_flags;
48950 +}
48951 +
48952 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48953 +{
48954 +
48955 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48956 + unsigned long i;
48957 +
48958 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48959 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48960 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48961 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48962 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48963 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48964 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48965 + return ~0UL;
48966 +
48967 +#ifdef CONFIG_PAX_SOFTMODE
48968 + if (pax_softmode)
48969 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48970 + else
48971 +#endif
48972 +
48973 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48974 + break;
48975 + }
48976 +#endif
48977 +
48978 + return ~0UL;
48979 +}
48980 +
48981 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48982 +{
48983 +
48984 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48985 + ssize_t xattr_size, i;
48986 + unsigned char xattr_value[5];
48987 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48988 +
48989 + xattr_size = vfs_getxattr(file->f_path.dentry, XATTR_NAME_PAX_FLAGS, xattr_value, sizeof xattr_value);
48990 + if (xattr_size <= 0 || xattr_size > 5)
48991 + return ~0UL;
48992 +
48993 + for (i = 0; i < xattr_size; i++)
48994 + switch (xattr_value[i]) {
48995 + default:
48996 + return ~0UL;
48997 +
48998 +#define parse_flag(option1, option2, flag) \
48999 + case option1: \
49000 + if (pax_flags_hardmode & MF_PAX_##flag) \
49001 + return ~0UL; \
49002 + pax_flags_hardmode |= MF_PAX_##flag; \
49003 + break; \
49004 + case option2: \
49005 + if (pax_flags_softmode & MF_PAX_##flag) \
49006 + return ~0UL; \
49007 + pax_flags_softmode |= MF_PAX_##flag; \
49008 + break;
49009 +
49010 + parse_flag('p', 'P', PAGEEXEC);
49011 + parse_flag('e', 'E', EMUTRAMP);
49012 + parse_flag('m', 'M', MPROTECT);
49013 + parse_flag('r', 'R', RANDMMAP);
49014 + parse_flag('s', 'S', SEGMEXEC);
49015 +
49016 +#undef parse_flag
49017 + }
49018 +
49019 + if (pax_flags_hardmode & pax_flags_softmode)
49020 + return ~0UL;
49021 +
49022 +#ifdef CONFIG_PAX_SOFTMODE
49023 + if (pax_softmode)
49024 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
49025 + else
49026 +#endif
49027 +
49028 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
49029 +#else
49030 + return ~0UL;
49031 +#endif
49032 +
49033 +}
49034 +
49035 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
49036 +{
49037 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
49038 +
49039 + pax_flags = pax_parse_ei_pax(elf_ex);
49040 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
49041 + xattr_pax_flags = pax_parse_xattr_pax(file);
49042 +
49043 + if (pt_pax_flags == ~0UL)
49044 + pt_pax_flags = xattr_pax_flags;
49045 + else if (xattr_pax_flags == ~0UL)
49046 + xattr_pax_flags = pt_pax_flags;
49047 + if (pt_pax_flags != xattr_pax_flags)
49048 + return -EINVAL;
49049 + if (pt_pax_flags != ~0UL)
49050 + pax_flags = pt_pax_flags;
49051 +
49052 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
49053 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49054 + if ((__supported_pte_mask & _PAGE_NX))
49055 + pax_flags &= ~MF_PAX_SEGMEXEC;
49056 + else
49057 + pax_flags &= ~MF_PAX_PAGEEXEC;
49058 + }
49059 +#endif
49060 +
49061 + if (0 > pax_check_flags(&pax_flags))
49062 + return -EINVAL;
49063 +
49064 + current->mm->pax_flags = pax_flags;
49065 + return 0;
49066 +}
49067 +#endif
49068 +
49069 /*
49070 * These are the functions used to load ELF style executables and shared
49071 * libraries. There is no binary dependent code anywhere else.
49072 @@ -546,6 +876,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
49073 {
49074 unsigned int random_variable = 0;
49075
49076 +#ifdef CONFIG_PAX_RANDUSTACK
49077 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
49078 + return stack_top - current->mm->delta_stack;
49079 +#endif
49080 +
49081 if ((current->flags & PF_RANDOMIZE) &&
49082 !(current->personality & ADDR_NO_RANDOMIZE)) {
49083 random_variable = get_random_int() & STACK_RND_MASK;
49084 @@ -564,7 +899,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
49085 unsigned long load_addr = 0, load_bias = 0;
49086 int load_addr_set = 0;
49087 char * elf_interpreter = NULL;
49088 - unsigned long error;
49089 + unsigned long error = 0;
49090 struct elf_phdr *elf_ppnt, *elf_phdata;
49091 unsigned long elf_bss, elf_brk;
49092 int retval, i;
49093 @@ -574,12 +909,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
49094 unsigned long start_code, end_code, start_data, end_data;
49095 unsigned long reloc_func_desc __maybe_unused = 0;
49096 int executable_stack = EXSTACK_DEFAULT;
49097 - unsigned long def_flags = 0;
49098 struct pt_regs *regs = current_pt_regs();
49099 struct {
49100 struct elfhdr elf_ex;
49101 struct elfhdr interp_elf_ex;
49102 } *loc;
49103 + unsigned long pax_task_size = TASK_SIZE;
49104
49105 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49106 if (!loc) {
49107 @@ -715,11 +1050,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49108 goto out_free_dentry;
49109
49110 /* OK, This is the point of no return */
49111 - current->mm->def_flags = def_flags;
49112 +
49113 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49114 + current->mm->pax_flags = 0UL;
49115 +#endif
49116 +
49117 +#ifdef CONFIG_PAX_DLRESOLVE
49118 + current->mm->call_dl_resolve = 0UL;
49119 +#endif
49120 +
49121 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49122 + current->mm->call_syscall = 0UL;
49123 +#endif
49124 +
49125 +#ifdef CONFIG_PAX_ASLR
49126 + current->mm->delta_mmap = 0UL;
49127 + current->mm->delta_stack = 0UL;
49128 +#endif
49129 +
49130 + current->mm->def_flags = 0;
49131 +
49132 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49133 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49134 + send_sig(SIGKILL, current, 0);
49135 + goto out_free_dentry;
49136 + }
49137 +#endif
49138 +
49139 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49140 + pax_set_initial_flags(bprm);
49141 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49142 + if (pax_set_initial_flags_func)
49143 + (pax_set_initial_flags_func)(bprm);
49144 +#endif
49145 +
49146 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49147 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49148 + current->mm->context.user_cs_limit = PAGE_SIZE;
49149 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49150 + }
49151 +#endif
49152 +
49153 +#ifdef CONFIG_PAX_SEGMEXEC
49154 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49155 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49156 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49157 + pax_task_size = SEGMEXEC_TASK_SIZE;
49158 + current->mm->def_flags |= VM_NOHUGEPAGE;
49159 + }
49160 +#endif
49161 +
49162 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49163 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49164 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49165 + put_cpu();
49166 + }
49167 +#endif
49168
49169 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49170 may depend on the personality. */
49171 SET_PERSONALITY(loc->elf_ex);
49172 +
49173 +#ifdef CONFIG_PAX_ASLR
49174 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49175 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49176 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49177 + }
49178 +#endif
49179 +
49180 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49181 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49182 + executable_stack = EXSTACK_DISABLE_X;
49183 + current->personality &= ~READ_IMPLIES_EXEC;
49184 + } else
49185 +#endif
49186 +
49187 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49188 current->personality |= READ_IMPLIES_EXEC;
49189
49190 @@ -810,6 +1215,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49191 #else
49192 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49193 #endif
49194 +
49195 +#ifdef CONFIG_PAX_RANDMMAP
49196 + /* PaX: randomize base address at the default exe base if requested */
49197 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49198 +#ifdef CONFIG_SPARC64
49199 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49200 +#else
49201 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49202 +#endif
49203 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49204 + elf_flags |= MAP_FIXED;
49205 + }
49206 +#endif
49207 +
49208 }
49209
49210 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49211 @@ -842,9 +1261,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49212 * allowed task size. Note that p_filesz must always be
49213 * <= p_memsz so it is only necessary to check p_memsz.
49214 */
49215 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49216 - elf_ppnt->p_memsz > TASK_SIZE ||
49217 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49218 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49219 + elf_ppnt->p_memsz > pax_task_size ||
49220 + pax_task_size - elf_ppnt->p_memsz < k) {
49221 /* set_brk can never work. Avoid overflows. */
49222 send_sig(SIGKILL, current, 0);
49223 retval = -EINVAL;
49224 @@ -883,17 +1302,44 @@ static int load_elf_binary(struct linux_binprm *bprm)
49225 goto out_free_dentry;
49226 }
49227 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49228 - send_sig(SIGSEGV, current, 0);
49229 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49230 - goto out_free_dentry;
49231 + /*
49232 + * This bss-zeroing can fail if the ELF
49233 + * file specifies odd protections. So
49234 + * we don't check the return value
49235 + */
49236 }
49237
49238 +#ifdef CONFIG_PAX_RANDMMAP
49239 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49240 + unsigned long start, size, flags, vm_flags;
49241 +
49242 + start = ELF_PAGEALIGN(elf_brk);
49243 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49244 + flags = MAP_FIXED | MAP_PRIVATE;
49245 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49246 +
49247 + down_write(&current->mm->mmap_sem);
49248 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49249 + retval = -ENOMEM;
49250 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49251 +// if (current->personality & ADDR_NO_RANDOMIZE)
49252 +// vm_flags |= VM_READ | VM_MAYREAD;
49253 + start = mmap_region(NULL, start, PAGE_ALIGN(size), flags, vm_flags, 0);
49254 + retval = IS_ERR_VALUE(start) ? start : 0;
49255 + }
49256 + up_write(&current->mm->mmap_sem);
49257 + if (retval == 0)
49258 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49259 + if (retval < 0) {
49260 + send_sig(SIGKILL, current, 0);
49261 + goto out_free_dentry;
49262 + }
49263 + }
49264 +#endif
49265 +
49266 if (elf_interpreter) {
49267 - unsigned long interp_map_addr = 0;
49268 -
49269 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49270 interpreter,
49271 - &interp_map_addr,
49272 load_bias);
49273 if (!IS_ERR((void *)elf_entry)) {
49274 /*
49275 @@ -1115,7 +1561,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49276 * Decide what to dump of a segment, part, all or none.
49277 */
49278 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49279 - unsigned long mm_flags)
49280 + unsigned long mm_flags, long signr)
49281 {
49282 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49283
49284 @@ -1152,7 +1598,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49285 if (vma->vm_file == NULL)
49286 return 0;
49287
49288 - if (FILTER(MAPPED_PRIVATE))
49289 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49290 goto whole;
49291
49292 /*
49293 @@ -1374,9 +1820,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49294 {
49295 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49296 int i = 0;
49297 - do
49298 + do {
49299 i += 2;
49300 - while (auxv[i - 2] != AT_NULL);
49301 + } while (auxv[i - 2] != AT_NULL);
49302 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49303 }
49304
49305 @@ -2006,14 +2452,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49306 }
49307
49308 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49309 - unsigned long mm_flags)
49310 + struct coredump_params *cprm)
49311 {
49312 struct vm_area_struct *vma;
49313 size_t size = 0;
49314
49315 for (vma = first_vma(current, gate_vma); vma != NULL;
49316 vma = next_vma(vma, gate_vma))
49317 - size += vma_dump_size(vma, mm_flags);
49318 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49319 return size;
49320 }
49321
49322 @@ -2107,7 +2553,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49323
49324 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49325
49326 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49327 + offset += elf_core_vma_data_size(gate_vma, cprm);
49328 offset += elf_core_extra_data_size();
49329 e_shoff = offset;
49330
49331 @@ -2121,10 +2567,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49332 offset = dataoff;
49333
49334 size += sizeof(*elf);
49335 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49336 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49337 goto end_coredump;
49338
49339 size += sizeof(*phdr4note);
49340 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49341 if (size > cprm->limit
49342 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49343 goto end_coredump;
49344 @@ -2138,7 +2586,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49345 phdr.p_offset = offset;
49346 phdr.p_vaddr = vma->vm_start;
49347 phdr.p_paddr = 0;
49348 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49349 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49350 phdr.p_memsz = vma->vm_end - vma->vm_start;
49351 offset += phdr.p_filesz;
49352 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49353 @@ -2149,6 +2597,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49354 phdr.p_align = ELF_EXEC_PAGESIZE;
49355
49356 size += sizeof(phdr);
49357 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49358 if (size > cprm->limit
49359 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49360 goto end_coredump;
49361 @@ -2173,7 +2622,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49362 unsigned long addr;
49363 unsigned long end;
49364
49365 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49366 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49367
49368 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49369 struct page *page;
49370 @@ -2182,6 +2631,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49371 page = get_dump_page(addr);
49372 if (page) {
49373 void *kaddr = kmap(page);
49374 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49375 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49376 !dump_write(cprm->file, kaddr,
49377 PAGE_SIZE);
49378 @@ -2199,6 +2649,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49379
49380 if (e_phnum == PN_XNUM) {
49381 size += sizeof(*shdr4extnum);
49382 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49383 if (size > cprm->limit
49384 || !dump_write(cprm->file, shdr4extnum,
49385 sizeof(*shdr4extnum)))
49386 @@ -2219,6 +2670,97 @@ out:
49387
49388 #endif /* CONFIG_ELF_CORE */
49389
49390 +#ifdef CONFIG_PAX_MPROTECT
49391 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49392 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49393 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49394 + *
49395 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49396 + * basis because we want to allow the common case and not the special ones.
49397 + */
49398 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49399 +{
49400 + struct elfhdr elf_h;
49401 + struct elf_phdr elf_p;
49402 + unsigned long i;
49403 + unsigned long oldflags;
49404 + bool is_textrel_rw, is_textrel_rx, is_relro;
49405 +
49406 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49407 + return;
49408 +
49409 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49410 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49411 +
49412 +#ifdef CONFIG_PAX_ELFRELOCS
49413 + /* possible TEXTREL */
49414 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49415 + 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);
49416 +#else
49417 + is_textrel_rw = false;
49418 + is_textrel_rx = false;
49419 +#endif
49420 +
49421 + /* possible RELRO */
49422 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49423 +
49424 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49425 + return;
49426 +
49427 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49428 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49429 +
49430 +#ifdef CONFIG_PAX_ETEXECRELOCS
49431 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49432 +#else
49433 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49434 +#endif
49435 +
49436 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49437 + !elf_check_arch(&elf_h) ||
49438 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49439 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49440 + return;
49441 +
49442 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49443 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49444 + return;
49445 + switch (elf_p.p_type) {
49446 + case PT_DYNAMIC:
49447 + if (!is_textrel_rw && !is_textrel_rx)
49448 + continue;
49449 + i = 0UL;
49450 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49451 + elf_dyn dyn;
49452 +
49453 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49454 + return;
49455 + if (dyn.d_tag == DT_NULL)
49456 + return;
49457 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49458 + gr_log_textrel(vma);
49459 + if (is_textrel_rw)
49460 + vma->vm_flags |= VM_MAYWRITE;
49461 + else
49462 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49463 + vma->vm_flags &= ~VM_MAYWRITE;
49464 + return;
49465 + }
49466 + i++;
49467 + }
49468 + return;
49469 +
49470 + case PT_GNU_RELRO:
49471 + if (!is_relro)
49472 + continue;
49473 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49474 + vma->vm_flags &= ~VM_MAYWRITE;
49475 + return;
49476 + }
49477 + }
49478 +}
49479 +#endif
49480 +
49481 static int __init init_elf_binfmt(void)
49482 {
49483 register_binfmt(&elf_format);
49484 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49485 index b563719..3868998 100644
49486 --- a/fs/binfmt_flat.c
49487 +++ b/fs/binfmt_flat.c
49488 @@ -562,7 +562,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49489 realdatastart = (unsigned long) -ENOMEM;
49490 printk("Unable to allocate RAM for process data, errno %d\n",
49491 (int)-realdatastart);
49492 + down_write(&current->mm->mmap_sem);
49493 vm_munmap(textpos, text_len);
49494 + up_write(&current->mm->mmap_sem);
49495 ret = realdatastart;
49496 goto err;
49497 }
49498 @@ -586,8 +588,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49499 }
49500 if (IS_ERR_VALUE(result)) {
49501 printk("Unable to read data+bss, errno %d\n", (int)-result);
49502 + down_write(&current->mm->mmap_sem);
49503 vm_munmap(textpos, text_len);
49504 vm_munmap(realdatastart, len);
49505 + up_write(&current->mm->mmap_sem);
49506 ret = result;
49507 goto err;
49508 }
49509 @@ -654,8 +658,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49510 }
49511 if (IS_ERR_VALUE(result)) {
49512 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49513 + down_write(&current->mm->mmap_sem);
49514 vm_munmap(textpos, text_len + data_len + extra +
49515 MAX_SHARED_LIBS * sizeof(unsigned long));
49516 + up_write(&current->mm->mmap_sem);
49517 ret = result;
49518 goto err;
49519 }
49520 diff --git a/fs/bio.c b/fs/bio.c
49521 index b96fc6c..431d628 100644
49522 --- a/fs/bio.c
49523 +++ b/fs/bio.c
49524 @@ -818,7 +818,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49525 /*
49526 * Overflow, abort
49527 */
49528 - if (end < start)
49529 + if (end < start || end - start > INT_MAX - nr_pages)
49530 return ERR_PTR(-EINVAL);
49531
49532 nr_pages += end - start;
49533 @@ -952,7 +952,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49534 /*
49535 * Overflow, abort
49536 */
49537 - if (end < start)
49538 + if (end < start || end - start > INT_MAX - nr_pages)
49539 return ERR_PTR(-EINVAL);
49540
49541 nr_pages += end - start;
49542 @@ -1214,7 +1214,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49543 const int read = bio_data_dir(bio) == READ;
49544 struct bio_map_data *bmd = bio->bi_private;
49545 int i;
49546 - char *p = bmd->sgvecs[0].iov_base;
49547 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49548
49549 __bio_for_each_segment(bvec, bio, i, 0) {
49550 char *addr = page_address(bvec->bv_page);
49551 diff --git a/fs/block_dev.c b/fs/block_dev.c
49552 index 883dc49..f27794a 100644
49553 --- a/fs/block_dev.c
49554 +++ b/fs/block_dev.c
49555 @@ -652,7 +652,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49556 else if (bdev->bd_contains == bdev)
49557 return true; /* is a whole device which isn't held */
49558
49559 - else if (whole->bd_holder == bd_may_claim)
49560 + else if (whole->bd_holder == (void *)bd_may_claim)
49561 return true; /* is a partition of a device that is being partitioned */
49562 else if (whole->bd_holder != NULL)
49563 return false; /* is a partition of a held device */
49564 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49565 index ce1c169..1ef484f 100644
49566 --- a/fs/btrfs/ctree.c
49567 +++ b/fs/btrfs/ctree.c
49568 @@ -1036,9 +1036,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49569 free_extent_buffer(buf);
49570 add_root_to_dirty_list(root);
49571 } else {
49572 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49573 - parent_start = parent->start;
49574 - else
49575 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49576 + if (parent)
49577 + parent_start = parent->start;
49578 + else
49579 + parent_start = 0;
49580 + } else
49581 parent_start = 0;
49582
49583 WARN_ON(trans->transid != btrfs_header_generation(parent));
49584 diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
49585 index 7c4e6cc..27bd5c2 100644
49586 --- a/fs/btrfs/inode.c
49587 +++ b/fs/btrfs/inode.c
49588 @@ -7314,7 +7314,7 @@ fail:
49589 return -ENOMEM;
49590 }
49591
49592 -static int btrfs_getattr(struct vfsmount *mnt,
49593 +int btrfs_getattr(struct vfsmount *mnt,
49594 struct dentry *dentry, struct kstat *stat)
49595 {
49596 struct inode *inode = dentry->d_inode;
49597 @@ -7328,6 +7328,14 @@ static int btrfs_getattr(struct vfsmount *mnt,
49598 return 0;
49599 }
49600
49601 +EXPORT_SYMBOL(btrfs_getattr);
49602 +
49603 +dev_t get_btrfs_dev_from_inode(struct inode *inode)
49604 +{
49605 + return BTRFS_I(inode)->root->anon_dev;
49606 +}
49607 +EXPORT_SYMBOL(get_btrfs_dev_from_inode);
49608 +
49609 /*
49610 * If a file is moved, it will inherit the cow and compression flags of the new
49611 * directory.
49612 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49613 index 338f259..b657640 100644
49614 --- a/fs/btrfs/ioctl.c
49615 +++ b/fs/btrfs/ioctl.c
49616 @@ -3033,9 +3033,12 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49617 for (i = 0; i < num_types; i++) {
49618 struct btrfs_space_info *tmp;
49619
49620 + /* Don't copy in more than we allocated */
49621 if (!slot_count)
49622 break;
49623
49624 + slot_count--;
49625 +
49626 info = NULL;
49627 rcu_read_lock();
49628 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49629 @@ -3057,10 +3060,7 @@ long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49630 memcpy(dest, &space, sizeof(space));
49631 dest++;
49632 space_args.total_spaces++;
49633 - slot_count--;
49634 }
49635 - if (!slot_count)
49636 - break;
49637 }
49638 up_read(&info->groups_sem);
49639 }
49640 diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
49641 index 300e09a..9fe4539 100644
49642 --- a/fs/btrfs/relocation.c
49643 +++ b/fs/btrfs/relocation.c
49644 @@ -1269,7 +1269,7 @@ static int __update_reloc_root(struct btrfs_root *root, int del)
49645 }
49646 spin_unlock(&rc->reloc_root_tree.lock);
49647
49648 - BUG_ON((struct btrfs_root *)node->data != root);
49649 + BUG_ON(!node || (struct btrfs_root *)node->data != root);
49650
49651 if (!del) {
49652 spin_lock(&rc->reloc_root_tree.lock);
49653 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49654 index d8982e9..29a85fa 100644
49655 --- a/fs/btrfs/super.c
49656 +++ b/fs/btrfs/super.c
49657 @@ -267,7 +267,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49658 function, line, errstr);
49659 return;
49660 }
49661 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49662 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49663 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49664 }
49665 /*
49666 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49667 index 622f469..e8d2d55 100644
49668 --- a/fs/cachefiles/bind.c
49669 +++ b/fs/cachefiles/bind.c
49670 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49671 args);
49672
49673 /* start by checking things over */
49674 - ASSERT(cache->fstop_percent >= 0 &&
49675 - cache->fstop_percent < cache->fcull_percent &&
49676 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49677 cache->fcull_percent < cache->frun_percent &&
49678 cache->frun_percent < 100);
49679
49680 - ASSERT(cache->bstop_percent >= 0 &&
49681 - cache->bstop_percent < cache->bcull_percent &&
49682 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49683 cache->bcull_percent < cache->brun_percent &&
49684 cache->brun_percent < 100);
49685
49686 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49687 index 0a1467b..6a53245 100644
49688 --- a/fs/cachefiles/daemon.c
49689 +++ b/fs/cachefiles/daemon.c
49690 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49691 if (n > buflen)
49692 return -EMSGSIZE;
49693
49694 - if (copy_to_user(_buffer, buffer, n) != 0)
49695 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49696 return -EFAULT;
49697
49698 return n;
49699 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49700 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49701 return -EIO;
49702
49703 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49704 + if (datalen > PAGE_SIZE - 1)
49705 return -EOPNOTSUPP;
49706
49707 /* drag the command string into the kernel so we can parse it */
49708 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49709 if (args[0] != '%' || args[1] != '\0')
49710 return -EINVAL;
49711
49712 - if (fstop < 0 || fstop >= cache->fcull_percent)
49713 + if (fstop >= cache->fcull_percent)
49714 return cachefiles_daemon_range_error(cache, args);
49715
49716 cache->fstop_percent = fstop;
49717 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49718 if (args[0] != '%' || args[1] != '\0')
49719 return -EINVAL;
49720
49721 - if (bstop < 0 || bstop >= cache->bcull_percent)
49722 + if (bstop >= cache->bcull_percent)
49723 return cachefiles_daemon_range_error(cache, args);
49724
49725 cache->bstop_percent = bstop;
49726 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49727 index 4938251..7e01445 100644
49728 --- a/fs/cachefiles/internal.h
49729 +++ b/fs/cachefiles/internal.h
49730 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49731 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49732 struct rb_root active_nodes; /* active nodes (can't be culled) */
49733 rwlock_t active_lock; /* lock for active_nodes */
49734 - atomic_t gravecounter; /* graveyard uniquifier */
49735 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49736 unsigned frun_percent; /* when to stop culling (% files) */
49737 unsigned fcull_percent; /* when to start culling (% files) */
49738 unsigned fstop_percent; /* when to stop allocating (% files) */
49739 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49740 * proc.c
49741 */
49742 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49743 -extern atomic_t cachefiles_lookup_histogram[HZ];
49744 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49745 -extern atomic_t cachefiles_create_histogram[HZ];
49746 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49747 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49748 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49749
49750 extern int __init cachefiles_proc_init(void);
49751 extern void cachefiles_proc_cleanup(void);
49752 static inline
49753 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49754 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49755 {
49756 unsigned long jif = jiffies - start_jif;
49757 if (jif >= HZ)
49758 jif = HZ - 1;
49759 - atomic_inc(&histogram[jif]);
49760 + atomic_inc_unchecked(&histogram[jif]);
49761 }
49762
49763 #else
49764 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49765 index 8c01c5fc..15f982e 100644
49766 --- a/fs/cachefiles/namei.c
49767 +++ b/fs/cachefiles/namei.c
49768 @@ -317,7 +317,7 @@ try_again:
49769 /* first step is to make up a grave dentry in the graveyard */
49770 sprintf(nbuffer, "%08x%08x",
49771 (uint32_t) get_seconds(),
49772 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49773 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49774
49775 /* do the multiway lock magic */
49776 trap = lock_rename(cache->graveyard, dir);
49777 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49778 index eccd339..4c1d995 100644
49779 --- a/fs/cachefiles/proc.c
49780 +++ b/fs/cachefiles/proc.c
49781 @@ -14,9 +14,9 @@
49782 #include <linux/seq_file.h>
49783 #include "internal.h"
49784
49785 -atomic_t cachefiles_lookup_histogram[HZ];
49786 -atomic_t cachefiles_mkdir_histogram[HZ];
49787 -atomic_t cachefiles_create_histogram[HZ];
49788 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49789 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49790 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49791
49792 /*
49793 * display the latency histogram
49794 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49795 return 0;
49796 default:
49797 index = (unsigned long) v - 3;
49798 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49799 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49800 - z = atomic_read(&cachefiles_create_histogram[index]);
49801 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49802 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49803 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49804 if (x == 0 && y == 0 && z == 0)
49805 return 0;
49806
49807 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49808 index 4809922..aab2c39 100644
49809 --- a/fs/cachefiles/rdwr.c
49810 +++ b/fs/cachefiles/rdwr.c
49811 @@ -965,7 +965,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49812 old_fs = get_fs();
49813 set_fs(KERNEL_DS);
49814 ret = file->f_op->write(
49815 - file, (const void __user *) data, len, &pos);
49816 + file, (const void __force_user *) data, len, &pos);
49817 set_fs(old_fs);
49818 kunmap(page);
49819 if (ret != len)
49820 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49821 index 8c1aabe..bbf856a 100644
49822 --- a/fs/ceph/dir.c
49823 +++ b/fs/ceph/dir.c
49824 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49825 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49826 struct ceph_mds_client *mdsc = fsc->mdsc;
49827 unsigned frag = fpos_frag(filp->f_pos);
49828 - int off = fpos_off(filp->f_pos);
49829 + unsigned int off = fpos_off(filp->f_pos);
49830 int err;
49831 u32 ftype;
49832 struct ceph_mds_reply_info_parsed *rinfo;
49833 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49834 index d9ea6ed..1e6c8ac 100644
49835 --- a/fs/cifs/cifs_debug.c
49836 +++ b/fs/cifs/cifs_debug.c
49837 @@ -267,8 +267,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49838
49839 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49840 #ifdef CONFIG_CIFS_STATS2
49841 - atomic_set(&totBufAllocCount, 0);
49842 - atomic_set(&totSmBufAllocCount, 0);
49843 + atomic_set_unchecked(&totBufAllocCount, 0);
49844 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49845 #endif /* CONFIG_CIFS_STATS2 */
49846 spin_lock(&cifs_tcp_ses_lock);
49847 list_for_each(tmp1, &cifs_tcp_ses_list) {
49848 @@ -281,7 +281,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49849 tcon = list_entry(tmp3,
49850 struct cifs_tcon,
49851 tcon_list);
49852 - atomic_set(&tcon->num_smbs_sent, 0);
49853 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49854 if (server->ops->clear_stats)
49855 server->ops->clear_stats(tcon);
49856 }
49857 @@ -313,8 +313,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49858 smBufAllocCount.counter, cifs_min_small);
49859 #ifdef CONFIG_CIFS_STATS2
49860 seq_printf(m, "Total Large %d Small %d Allocations\n",
49861 - atomic_read(&totBufAllocCount),
49862 - atomic_read(&totSmBufAllocCount));
49863 + atomic_read_unchecked(&totBufAllocCount),
49864 + atomic_read_unchecked(&totSmBufAllocCount));
49865 #endif /* CONFIG_CIFS_STATS2 */
49866
49867 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49868 @@ -343,7 +343,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49869 if (tcon->need_reconnect)
49870 seq_puts(m, "\tDISCONNECTED ");
49871 seq_printf(m, "\nSMBs: %d",
49872 - atomic_read(&tcon->num_smbs_sent));
49873 + atomic_read_unchecked(&tcon->num_smbs_sent));
49874 if (server->ops->print_stats)
49875 server->ops->print_stats(m, tcon);
49876 }
49877 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49878 index b9db388..9a73d6d 100644
49879 --- a/fs/cifs/cifsfs.c
49880 +++ b/fs/cifs/cifsfs.c
49881 @@ -1026,7 +1026,7 @@ cifs_init_request_bufs(void)
49882 /* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
49883 cifs_req_cachep = kmem_cache_create("cifs_request",
49884 CIFSMaxBufSize + max_hdr_size, 0,
49885 - SLAB_HWCACHE_ALIGN, NULL);
49886 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49887 if (cifs_req_cachep == NULL)
49888 return -ENOMEM;
49889
49890 @@ -1053,7 +1053,7 @@ cifs_init_request_bufs(void)
49891 efficient to alloc 1 per page off the slab compared to 17K (5page)
49892 alloc of large cifs buffers even when page debugging is on */
49893 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49894 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49895 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49896 NULL);
49897 if (cifs_sm_req_cachep == NULL) {
49898 mempool_destroy(cifs_req_poolp);
49899 @@ -1138,8 +1138,8 @@ init_cifs(void)
49900 atomic_set(&bufAllocCount, 0);
49901 atomic_set(&smBufAllocCount, 0);
49902 #ifdef CONFIG_CIFS_STATS2
49903 - atomic_set(&totBufAllocCount, 0);
49904 - atomic_set(&totSmBufAllocCount, 0);
49905 + atomic_set_unchecked(&totBufAllocCount, 0);
49906 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49907 #endif /* CONFIG_CIFS_STATS2 */
49908
49909 atomic_set(&midCount, 0);
49910 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49911 index e6899ce..d6b2920 100644
49912 --- a/fs/cifs/cifsglob.h
49913 +++ b/fs/cifs/cifsglob.h
49914 @@ -751,35 +751,35 @@ struct cifs_tcon {
49915 __u16 Flags; /* optional support bits */
49916 enum statusEnum tidStatus;
49917 #ifdef CONFIG_CIFS_STATS
49918 - atomic_t num_smbs_sent;
49919 + atomic_unchecked_t num_smbs_sent;
49920 union {
49921 struct {
49922 - atomic_t num_writes;
49923 - atomic_t num_reads;
49924 - atomic_t num_flushes;
49925 - atomic_t num_oplock_brks;
49926 - atomic_t num_opens;
49927 - atomic_t num_closes;
49928 - atomic_t num_deletes;
49929 - atomic_t num_mkdirs;
49930 - atomic_t num_posixopens;
49931 - atomic_t num_posixmkdirs;
49932 - atomic_t num_rmdirs;
49933 - atomic_t num_renames;
49934 - atomic_t num_t2renames;
49935 - atomic_t num_ffirst;
49936 - atomic_t num_fnext;
49937 - atomic_t num_fclose;
49938 - atomic_t num_hardlinks;
49939 - atomic_t num_symlinks;
49940 - atomic_t num_locks;
49941 - atomic_t num_acl_get;
49942 - atomic_t num_acl_set;
49943 + atomic_unchecked_t num_writes;
49944 + atomic_unchecked_t num_reads;
49945 + atomic_unchecked_t num_flushes;
49946 + atomic_unchecked_t num_oplock_brks;
49947 + atomic_unchecked_t num_opens;
49948 + atomic_unchecked_t num_closes;
49949 + atomic_unchecked_t num_deletes;
49950 + atomic_unchecked_t num_mkdirs;
49951 + atomic_unchecked_t num_posixopens;
49952 + atomic_unchecked_t num_posixmkdirs;
49953 + atomic_unchecked_t num_rmdirs;
49954 + atomic_unchecked_t num_renames;
49955 + atomic_unchecked_t num_t2renames;
49956 + atomic_unchecked_t num_ffirst;
49957 + atomic_unchecked_t num_fnext;
49958 + atomic_unchecked_t num_fclose;
49959 + atomic_unchecked_t num_hardlinks;
49960 + atomic_unchecked_t num_symlinks;
49961 + atomic_unchecked_t num_locks;
49962 + atomic_unchecked_t num_acl_get;
49963 + atomic_unchecked_t num_acl_set;
49964 } cifs_stats;
49965 #ifdef CONFIG_CIFS_SMB2
49966 struct {
49967 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49968 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49969 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49970 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49971 } smb2_stats;
49972 #endif /* CONFIG_CIFS_SMB2 */
49973 } stats;
49974 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49975 }
49976
49977 #ifdef CONFIG_CIFS_STATS
49978 -#define cifs_stats_inc atomic_inc
49979 +#define cifs_stats_inc atomic_inc_unchecked
49980
49981 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49982 unsigned int bytes)
49983 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49984 /* Various Debug counters */
49985 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49986 #ifdef CONFIG_CIFS_STATS2
49987 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49988 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49989 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49990 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49991 #endif
49992 GLOBAL_EXTERN atomic_t smBufAllocCount;
49993 GLOBAL_EXTERN atomic_t midCount;
49994 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49995 index 51dc2fb..1e12a33 100644
49996 --- a/fs/cifs/link.c
49997 +++ b/fs/cifs/link.c
49998 @@ -616,7 +616,7 @@ symlink_exit:
49999
50000 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
50001 {
50002 - char *p = nd_get_link(nd);
50003 + const char *p = nd_get_link(nd);
50004 if (!IS_ERR(p))
50005 kfree(p);
50006 }
50007 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
50008 index 3a00c0d..42d901c 100644
50009 --- a/fs/cifs/misc.c
50010 +++ b/fs/cifs/misc.c
50011 @@ -169,7 +169,7 @@ cifs_buf_get(void)
50012 memset(ret_buf, 0, buf_size + 3);
50013 atomic_inc(&bufAllocCount);
50014 #ifdef CONFIG_CIFS_STATS2
50015 - atomic_inc(&totBufAllocCount);
50016 + atomic_inc_unchecked(&totBufAllocCount);
50017 #endif /* CONFIG_CIFS_STATS2 */
50018 }
50019
50020 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
50021 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
50022 atomic_inc(&smBufAllocCount);
50023 #ifdef CONFIG_CIFS_STATS2
50024 - atomic_inc(&totSmBufAllocCount);
50025 + atomic_inc_unchecked(&totSmBufAllocCount);
50026 #endif /* CONFIG_CIFS_STATS2 */
50027
50028 }
50029 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
50030 index 47bc5a8..10decbe 100644
50031 --- a/fs/cifs/smb1ops.c
50032 +++ b/fs/cifs/smb1ops.c
50033 @@ -586,27 +586,27 @@ static void
50034 cifs_clear_stats(struct cifs_tcon *tcon)
50035 {
50036 #ifdef CONFIG_CIFS_STATS
50037 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
50038 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
50039 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
50040 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50041 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
50042 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
50043 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50044 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
50045 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
50046 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
50047 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
50048 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
50049 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
50050 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
50051 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
50052 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
50053 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
50054 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
50055 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
50056 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
50057 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
50058 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
50059 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
50060 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
50061 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
50062 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
50063 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
50064 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
50065 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
50066 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
50067 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
50068 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
50069 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
50070 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
50071 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
50072 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
50073 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
50074 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
50075 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
50076 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
50077 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
50078 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
50079 #endif
50080 }
50081
50082 @@ -615,36 +615,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50083 {
50084 #ifdef CONFIG_CIFS_STATS
50085 seq_printf(m, " Oplocks breaks: %d",
50086 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
50087 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
50088 seq_printf(m, "\nReads: %d Bytes: %llu",
50089 - atomic_read(&tcon->stats.cifs_stats.num_reads),
50090 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
50091 (long long)(tcon->bytes_read));
50092 seq_printf(m, "\nWrites: %d Bytes: %llu",
50093 - atomic_read(&tcon->stats.cifs_stats.num_writes),
50094 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
50095 (long long)(tcon->bytes_written));
50096 seq_printf(m, "\nFlushes: %d",
50097 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
50098 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
50099 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
50100 - atomic_read(&tcon->stats.cifs_stats.num_locks),
50101 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
50102 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
50103 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
50104 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
50105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
50106 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
50107 - atomic_read(&tcon->stats.cifs_stats.num_opens),
50108 - atomic_read(&tcon->stats.cifs_stats.num_closes),
50109 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
50110 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
50111 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
50112 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
50113 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
50114 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
50115 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
50116 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
50117 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
50118 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
50119 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
50120 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
50121 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
50122 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
50123 seq_printf(m, "\nRenames: %d T2 Renames %d",
50124 - atomic_read(&tcon->stats.cifs_stats.num_renames),
50125 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
50126 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
50127 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
50128 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50129 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50130 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50131 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50132 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50133 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50134 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50135 #endif
50136 }
50137
50138 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50139 index bceffe7..cd1ae59 100644
50140 --- a/fs/cifs/smb2ops.c
50141 +++ b/fs/cifs/smb2ops.c
50142 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50143 #ifdef CONFIG_CIFS_STATS
50144 int i;
50145 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50146 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50147 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50148 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50149 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50150 }
50151 #endif
50152 }
50153 @@ -284,66 +284,66 @@ static void
50154 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50155 {
50156 #ifdef CONFIG_CIFS_STATS
50157 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50158 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50159 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50160 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50161 seq_printf(m, "\nNegotiates: %d sent %d failed",
50162 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50163 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50164 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50165 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50166 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50167 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50168 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50169 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50170 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50171 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50172 seq_printf(m, "\nLogoffs: %d sent %d failed",
50173 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50174 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50175 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50176 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50177 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50178 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50179 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50180 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50181 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50182 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50183 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50184 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50185 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50186 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50187 seq_printf(m, "\nCreates: %d sent %d failed",
50188 - atomic_read(&sent[SMB2_CREATE_HE]),
50189 - atomic_read(&failed[SMB2_CREATE_HE]));
50190 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50191 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50192 seq_printf(m, "\nCloses: %d sent %d failed",
50193 - atomic_read(&sent[SMB2_CLOSE_HE]),
50194 - atomic_read(&failed[SMB2_CLOSE_HE]));
50195 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50196 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50197 seq_printf(m, "\nFlushes: %d sent %d failed",
50198 - atomic_read(&sent[SMB2_FLUSH_HE]),
50199 - atomic_read(&failed[SMB2_FLUSH_HE]));
50200 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50201 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50202 seq_printf(m, "\nReads: %d sent %d failed",
50203 - atomic_read(&sent[SMB2_READ_HE]),
50204 - atomic_read(&failed[SMB2_READ_HE]));
50205 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50206 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50207 seq_printf(m, "\nWrites: %d sent %d failed",
50208 - atomic_read(&sent[SMB2_WRITE_HE]),
50209 - atomic_read(&failed[SMB2_WRITE_HE]));
50210 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50211 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50212 seq_printf(m, "\nLocks: %d sent %d failed",
50213 - atomic_read(&sent[SMB2_LOCK_HE]),
50214 - atomic_read(&failed[SMB2_LOCK_HE]));
50215 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50216 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50217 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50218 - atomic_read(&sent[SMB2_IOCTL_HE]),
50219 - atomic_read(&failed[SMB2_IOCTL_HE]));
50220 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50221 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50222 seq_printf(m, "\nCancels: %d sent %d failed",
50223 - atomic_read(&sent[SMB2_CANCEL_HE]),
50224 - atomic_read(&failed[SMB2_CANCEL_HE]));
50225 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50226 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50227 seq_printf(m, "\nEchos: %d sent %d failed",
50228 - atomic_read(&sent[SMB2_ECHO_HE]),
50229 - atomic_read(&failed[SMB2_ECHO_HE]));
50230 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50231 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50232 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50233 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50234 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50235 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50236 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50237 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50238 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50239 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50240 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50241 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50242 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50243 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50244 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50245 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50246 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50247 seq_printf(m, "\nSetInfos: %d sent %d failed",
50248 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50249 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50250 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50251 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50252 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50253 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50254 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50255 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50256 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50257 #endif
50258 }
50259
50260 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50261 index 41d9d07..dbb4772 100644
50262 --- a/fs/cifs/smb2pdu.c
50263 +++ b/fs/cifs/smb2pdu.c
50264 @@ -1761,8 +1761,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50265 default:
50266 cERROR(1, "info level %u isn't supported",
50267 srch_inf->info_level);
50268 - rc = -EINVAL;
50269 - goto qdir_exit;
50270 + return -EINVAL;
50271 }
50272
50273 req->FileIndex = cpu_to_le32(index);
50274 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50275 index 958ae0e..505c9d0 100644
50276 --- a/fs/coda/cache.c
50277 +++ b/fs/coda/cache.c
50278 @@ -24,7 +24,7 @@
50279 #include "coda_linux.h"
50280 #include "coda_cache.h"
50281
50282 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50283 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50284
50285 /* replace or extend an acl cache hit */
50286 void coda_cache_enter(struct inode *inode, int mask)
50287 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50288 struct coda_inode_info *cii = ITOC(inode);
50289
50290 spin_lock(&cii->c_lock);
50291 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50292 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50293 if (cii->c_uid != current_fsuid()) {
50294 cii->c_uid = current_fsuid();
50295 cii->c_cached_perm = mask;
50296 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50297 {
50298 struct coda_inode_info *cii = ITOC(inode);
50299 spin_lock(&cii->c_lock);
50300 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50301 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50302 spin_unlock(&cii->c_lock);
50303 }
50304
50305 /* remove all acl caches */
50306 void coda_cache_clear_all(struct super_block *sb)
50307 {
50308 - atomic_inc(&permission_epoch);
50309 + atomic_inc_unchecked(&permission_epoch);
50310 }
50311
50312
50313 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50314 spin_lock(&cii->c_lock);
50315 hit = (mask & cii->c_cached_perm) == mask &&
50316 cii->c_uid == current_fsuid() &&
50317 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50318 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50319 spin_unlock(&cii->c_lock);
50320
50321 return hit;
50322 diff --git a/fs/compat.c b/fs/compat.c
50323 index a06dcbc..dacb6d3 100644
50324 --- a/fs/compat.c
50325 +++ b/fs/compat.c
50326 @@ -54,7 +54,7 @@
50327 #include <asm/ioctls.h>
50328 #include "internal.h"
50329
50330 -int compat_log = 1;
50331 +int compat_log = 0;
50332
50333 int compat_printk(const char *fmt, ...)
50334 {
50335 @@ -490,7 +490,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50336
50337 set_fs(KERNEL_DS);
50338 /* The __user pointer cast is valid because of the set_fs() */
50339 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50340 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50341 set_fs(oldfs);
50342 /* truncating is ok because it's a user address */
50343 if (!ret)
50344 @@ -548,7 +548,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50345 goto out;
50346
50347 ret = -EINVAL;
50348 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50349 + if (nr_segs > UIO_MAXIOV)
50350 goto out;
50351 if (nr_segs > fast_segs) {
50352 ret = -ENOMEM;
50353 @@ -835,6 +835,7 @@ struct compat_old_linux_dirent {
50354
50355 struct compat_readdir_callback {
50356 struct compat_old_linux_dirent __user *dirent;
50357 + struct file * file;
50358 int result;
50359 };
50360
50361 @@ -852,6 +853,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50362 buf->result = -EOVERFLOW;
50363 return -EOVERFLOW;
50364 }
50365 +
50366 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50367 + return 0;
50368 +
50369 buf->result++;
50370 dirent = buf->dirent;
50371 if (!access_ok(VERIFY_WRITE, dirent,
50372 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50373
50374 buf.result = 0;
50375 buf.dirent = dirent;
50376 + buf.file = f.file;
50377
50378 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50379 if (buf.result)
50380 @@ -901,6 +907,7 @@ struct compat_linux_dirent {
50381 struct compat_getdents_callback {
50382 struct compat_linux_dirent __user *current_dir;
50383 struct compat_linux_dirent __user *previous;
50384 + struct file * file;
50385 int count;
50386 int error;
50387 };
50388 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50389 buf->error = -EOVERFLOW;
50390 return -EOVERFLOW;
50391 }
50392 +
50393 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50394 + return 0;
50395 +
50396 dirent = buf->previous;
50397 if (dirent) {
50398 if (__put_user(offset, &dirent->d_off))
50399 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50400 buf.previous = NULL;
50401 buf.count = count;
50402 buf.error = 0;
50403 + buf.file = f.file;
50404
50405 error = vfs_readdir(f.file, compat_filldir, &buf);
50406 if (error >= 0)
50407 @@ -987,6 +999,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50408 struct compat_getdents_callback64 {
50409 struct linux_dirent64 __user *current_dir;
50410 struct linux_dirent64 __user *previous;
50411 + struct file * file;
50412 int count;
50413 int error;
50414 };
50415 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50416 buf->error = -EINVAL; /* only used if we fail.. */
50417 if (reclen > buf->count)
50418 return -EINVAL;
50419 +
50420 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50421 + return 0;
50422 +
50423 dirent = buf->previous;
50424
50425 if (dirent) {
50426 @@ -1052,13 +1069,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50427 buf.previous = NULL;
50428 buf.count = count;
50429 buf.error = 0;
50430 + buf.file = f.file;
50431
50432 error = vfs_readdir(f.file, compat_filldir64, &buf);
50433 if (error >= 0)
50434 error = buf.error;
50435 lastdirent = buf.previous;
50436 if (lastdirent) {
50437 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50438 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50439 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50440 error = -EFAULT;
50441 else
50442 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50443 index a81147e..20bf2b5 100644
50444 --- a/fs/compat_binfmt_elf.c
50445 +++ b/fs/compat_binfmt_elf.c
50446 @@ -30,11 +30,13 @@
50447 #undef elf_phdr
50448 #undef elf_shdr
50449 #undef elf_note
50450 +#undef elf_dyn
50451 #undef elf_addr_t
50452 #define elfhdr elf32_hdr
50453 #define elf_phdr elf32_phdr
50454 #define elf_shdr elf32_shdr
50455 #define elf_note elf32_note
50456 +#define elf_dyn Elf32_Dyn
50457 #define elf_addr_t Elf32_Addr
50458
50459 /*
50460 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50461 index e2f57a0..3c78771 100644
50462 --- a/fs/compat_ioctl.c
50463 +++ b/fs/compat_ioctl.c
50464 @@ -623,7 +623,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50465 return -EFAULT;
50466 if (__get_user(udata, &ss32->iomem_base))
50467 return -EFAULT;
50468 - ss.iomem_base = compat_ptr(udata);
50469 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50470 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50471 __get_user(ss.port_high, &ss32->port_high))
50472 return -EFAULT;
50473 @@ -798,7 +798,7 @@ static int compat_ioctl_preallocate(struct file *file,
50474 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50475 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50476 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50477 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50478 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50479 return -EFAULT;
50480
50481 return ioctl_preallocate(file, p);
50482 @@ -1620,8 +1620,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50483 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50484 {
50485 unsigned int a, b;
50486 - a = *(unsigned int *)p;
50487 - b = *(unsigned int *)q;
50488 + a = *(const unsigned int *)p;
50489 + b = *(const unsigned int *)q;
50490 if (a > b)
50491 return 1;
50492 if (a < b)
50493 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50494 index 712b10f..c33c4ca 100644
50495 --- a/fs/configfs/dir.c
50496 +++ b/fs/configfs/dir.c
50497 @@ -1037,10 +1037,11 @@ static int configfs_dump(struct configfs_dirent *sd, int level)
50498 static int configfs_depend_prep(struct dentry *origin,
50499 struct config_item *target)
50500 {
50501 - struct configfs_dirent *child_sd, *sd = origin->d_fsdata;
50502 + struct configfs_dirent *child_sd, *sd;
50503 int ret = 0;
50504
50505 - BUG_ON(!origin || !sd);
50506 + BUG_ON(!origin || !origin->d_fsdata);
50507 + sd = origin->d_fsdata;
50508
50509 if (sd->s_element == target) /* Boo-yah */
50510 goto out;
50511 @@ -1564,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50512 }
50513 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50514 struct configfs_dirent *next;
50515 - const char * name;
50516 + const unsigned char * name;
50517 + char d_name[sizeof(next->s_dentry->d_iname)];
50518 int len;
50519 struct inode *inode = NULL;
50520
50521 @@ -1574,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50522 continue;
50523
50524 name = configfs_get_name(next);
50525 - len = strlen(name);
50526 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50527 + len = next->s_dentry->d_name.len;
50528 + memcpy(d_name, name, len);
50529 + name = d_name;
50530 + } else
50531 + len = strlen(name);
50532
50533 /*
50534 * We'll have a dentry and an inode for
50535 diff --git a/fs/coredump.c b/fs/coredump.c
50536 index 1774932..5812106 100644
50537 --- a/fs/coredump.c
50538 +++ b/fs/coredump.c
50539 @@ -52,7 +52,7 @@ struct core_name {
50540 char *corename;
50541 int used, size;
50542 };
50543 -static atomic_t call_count = ATOMIC_INIT(1);
50544 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50545
50546 /* The maximal length of core_pattern is also specified in sysctl.c */
50547
50548 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50549 {
50550 char *old_corename = cn->corename;
50551
50552 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50553 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50554 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50555
50556 if (!cn->corename) {
50557 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50558 int pid_in_pattern = 0;
50559 int err = 0;
50560
50561 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50562 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50563 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50564 cn->used = 0;
50565
50566 @@ -414,17 +414,17 @@ static void wait_for_dump_helpers(struct file *file)
50567 pipe = file->f_path.dentry->d_inode->i_pipe;
50568
50569 pipe_lock(pipe);
50570 - pipe->readers++;
50571 - pipe->writers--;
50572 + atomic_inc(&pipe->readers);
50573 + atomic_dec(&pipe->writers);
50574
50575 - while ((pipe->readers > 1) && (!signal_pending(current))) {
50576 + while ((atomic_read(&pipe->readers) > 1) && (!signal_pending(current))) {
50577 wake_up_interruptible_sync(&pipe->wait);
50578 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50579 pipe_wait(pipe);
50580 }
50581
50582 - pipe->readers--;
50583 - pipe->writers++;
50584 + atomic_dec(&pipe->readers);
50585 + atomic_inc(&pipe->writers);
50586 pipe_unlock(pipe);
50587
50588 }
50589 @@ -471,7 +471,8 @@ void do_coredump(siginfo_t *siginfo)
50590 int ispipe;
50591 struct files_struct *displaced;
50592 bool need_nonrelative = false;
50593 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50594 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50595 + long signr = siginfo->si_signo;
50596 struct coredump_params cprm = {
50597 .siginfo = siginfo,
50598 .regs = signal_pt_regs(),
50599 @@ -484,7 +485,10 @@ void do_coredump(siginfo_t *siginfo)
50600 .mm_flags = mm->flags,
50601 };
50602
50603 - audit_core_dumps(siginfo->si_signo);
50604 + audit_core_dumps(signr);
50605 +
50606 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50607 + gr_handle_brute_attach(cprm.mm_flags);
50608
50609 binfmt = mm->binfmt;
50610 if (!binfmt || !binfmt->core_dump)
50611 @@ -508,7 +512,7 @@ void do_coredump(siginfo_t *siginfo)
50612 need_nonrelative = true;
50613 }
50614
50615 - retval = coredump_wait(siginfo->si_signo, &core_state);
50616 + retval = coredump_wait(signr, &core_state);
50617 if (retval < 0)
50618 goto fail_creds;
50619
50620 @@ -556,7 +560,7 @@ void do_coredump(siginfo_t *siginfo)
50621 }
50622 cprm.limit = RLIM_INFINITY;
50623
50624 - dump_count = atomic_inc_return(&core_dump_count);
50625 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50626 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50627 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50628 task_tgid_vnr(current), current->comm);
50629 @@ -583,6 +587,8 @@ void do_coredump(siginfo_t *siginfo)
50630 } else {
50631 struct inode *inode;
50632
50633 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50634 +
50635 if (cprm.limit < binfmt->min_coredump)
50636 goto fail_unlock;
50637
50638 @@ -640,7 +646,7 @@ close_fail:
50639 filp_close(cprm.file, NULL);
50640 fail_dropcount:
50641 if (ispipe)
50642 - atomic_dec(&core_dump_count);
50643 + atomic_dec_unchecked(&core_dump_count);
50644 fail_unlock:
50645 kfree(cn.corename);
50646 fail_corename:
50647 @@ -659,7 +665,7 @@ fail:
50648 */
50649 int dump_write(struct file *file, const void *addr, int nr)
50650 {
50651 - return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50652 + return access_ok(VERIFY_READ, addr, nr) && file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50653 }
50654 EXPORT_SYMBOL(dump_write);
50655
50656 diff --git a/fs/dcache.c b/fs/dcache.c
50657 index c3bbf85..5b71101 100644
50658 --- a/fs/dcache.c
50659 +++ b/fs/dcache.c
50660 @@ -3139,7 +3139,7 @@ void __init vfs_caches_init(unsigned long mempages)
50661 mempages -= reserve;
50662
50663 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50664 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50665 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50666
50667 dcache_init();
50668 inode_init();
50669 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50670 index a5f12b7..4ee8a6f 100644
50671 --- a/fs/debugfs/inode.c
50672 +++ b/fs/debugfs/inode.c
50673 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50674 */
50675 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50676 {
50677 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50678 + return __create_file(name, S_IFDIR | S_IRWXU,
50679 +#else
50680 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50681 +#endif
50682 parent, NULL, NULL);
50683 }
50684 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50685 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50686 index cc7709e..7e7211f 100644
50687 --- a/fs/ecryptfs/inode.c
50688 +++ b/fs/ecryptfs/inode.c
50689 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50690 old_fs = get_fs();
50691 set_fs(get_ds());
50692 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50693 - (char __user *)lower_buf,
50694 + (char __force_user *)lower_buf,
50695 PATH_MAX);
50696 set_fs(old_fs);
50697 if (rc < 0)
50698 @@ -706,7 +706,7 @@ out:
50699 static void
50700 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50701 {
50702 - char *buf = nd_get_link(nd);
50703 + const char *buf = nd_get_link(nd);
50704 if (!IS_ERR(buf)) {
50705 /* Free the char* */
50706 kfree(buf);
50707 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50708 index 412e6ed..d8263e8 100644
50709 --- a/fs/ecryptfs/miscdev.c
50710 +++ b/fs/ecryptfs/miscdev.c
50711 @@ -80,13 +80,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50712 int rc;
50713
50714 mutex_lock(&ecryptfs_daemon_hash_mux);
50715 - rc = try_module_get(THIS_MODULE);
50716 - if (rc == 0) {
50717 - rc = -EIO;
50718 - printk(KERN_ERR "%s: Error attempting to increment module use "
50719 - "count; rc = [%d]\n", __func__, rc);
50720 - goto out_unlock_daemon_list;
50721 - }
50722 rc = ecryptfs_find_daemon_by_euid(&daemon);
50723 if (!rc) {
50724 rc = -EINVAL;
50725 @@ -96,7 +89,7 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50726 if (rc) {
50727 printk(KERN_ERR "%s: Error attempting to spawn daemon; "
50728 "rc = [%d]\n", __func__, rc);
50729 - goto out_module_put_unlock_daemon_list;
50730 + goto out_unlock_daemon_list;
50731 }
50732 mutex_lock(&daemon->mux);
50733 if (daemon->flags & ECRYPTFS_DAEMON_MISCDEV_OPEN) {
50734 @@ -108,9 +101,6 @@ ecryptfs_miscdev_open(struct inode *inode, struct file *file)
50735 atomic_inc(&ecryptfs_num_miscdev_opens);
50736 out_unlock_daemon:
50737 mutex_unlock(&daemon->mux);
50738 -out_module_put_unlock_daemon_list:
50739 - if (rc)
50740 - module_put(THIS_MODULE);
50741 out_unlock_daemon_list:
50742 mutex_unlock(&ecryptfs_daemon_hash_mux);
50743 return rc;
50744 @@ -147,7 +137,6 @@ ecryptfs_miscdev_release(struct inode *inode, struct file *file)
50745 "bug.\n", __func__, rc);
50746 BUG();
50747 }
50748 - module_put(THIS_MODULE);
50749 return rc;
50750 }
50751
50752 @@ -315,7 +304,7 @@ check_list:
50753 goto out_unlock_msg_ctx;
50754 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50755 if (msg_ctx->msg) {
50756 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50757 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50758 goto out_unlock_msg_ctx;
50759 i += packet_length_size;
50760 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50761 @@ -471,6 +460,7 @@ out_free:
50762
50763
50764 static const struct file_operations ecryptfs_miscdev_fops = {
50765 + .owner = THIS_MODULE,
50766 .open = ecryptfs_miscdev_open,
50767 .poll = ecryptfs_miscdev_poll,
50768 .read = ecryptfs_miscdev_read,
50769 diff --git a/fs/ecryptfs/read_write.c b/fs/ecryptfs/read_write.c
50770 index b2a34a1..162fa69 100644
50771 --- a/fs/ecryptfs/read_write.c
50772 +++ b/fs/ecryptfs/read_write.c
50773 @@ -48,7 +48,7 @@ int ecryptfs_write_lower(struct inode *ecryptfs_inode, char *data,
50774 return -EIO;
50775 fs_save = get_fs();
50776 set_fs(get_ds());
50777 - rc = vfs_write(lower_file, data, size, &offset);
50778 + rc = vfs_write(lower_file, (const char __force_user *)data, size, &offset);
50779 set_fs(fs_save);
50780 mark_inode_dirty_sync(ecryptfs_inode);
50781 return rc;
50782 @@ -244,7 +244,7 @@ int ecryptfs_read_lower(char *data, loff_t offset, size_t size,
50783 return -EIO;
50784 fs_save = get_fs();
50785 set_fs(get_ds());
50786 - rc = vfs_read(lower_file, data, size, &offset);
50787 + rc = vfs_read(lower_file, (char __force_user *)data, size, &offset);
50788 set_fs(fs_save);
50789 return rc;
50790 }
50791 diff --git a/fs/exec.c b/fs/exec.c
50792 index 20df02c..1b1d946 100644
50793 --- a/fs/exec.c
50794 +++ b/fs/exec.c
50795 @@ -55,6 +55,17 @@
50796 #include <linux/pipe_fs_i.h>
50797 #include <linux/oom.h>
50798 #include <linux/compat.h>
50799 +#include <linux/random.h>
50800 +#include <linux/seq_file.h>
50801 +#include <linux/coredump.h>
50802 +#include <linux/mman.h>
50803 +
50804 +#ifdef CONFIG_PAX_REFCOUNT
50805 +#include <linux/kallsyms.h>
50806 +#include <linux/kdebug.h>
50807 +#endif
50808 +
50809 +#include <trace/events/fs.h>
50810
50811 #include <asm/uaccess.h>
50812 #include <asm/mmu_context.h>
50813 @@ -66,6 +77,18 @@
50814
50815 #include <trace/events/sched.h>
50816
50817 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50818 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50819 +{
50820 + 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");
50821 +}
50822 +#endif
50823 +
50824 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50825 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50826 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50827 +#endif
50828 +
50829 int suid_dumpable = 0;
50830
50831 static LIST_HEAD(formats);
50832 @@ -75,8 +98,8 @@ void __register_binfmt(struct linux_binfmt * fmt, int insert)
50833 {
50834 BUG_ON(!fmt);
50835 write_lock(&binfmt_lock);
50836 - insert ? list_add(&fmt->lh, &formats) :
50837 - list_add_tail(&fmt->lh, &formats);
50838 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50839 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50840 write_unlock(&binfmt_lock);
50841 }
50842
50843 @@ -85,7 +108,7 @@ EXPORT_SYMBOL(__register_binfmt);
50844 void unregister_binfmt(struct linux_binfmt * fmt)
50845 {
50846 write_lock(&binfmt_lock);
50847 - list_del(&fmt->lh);
50848 + pax_list_del((struct list_head *)&fmt->lh);
50849 write_unlock(&binfmt_lock);
50850 }
50851
50852 @@ -180,18 +203,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50853 int write)
50854 {
50855 struct page *page;
50856 - int ret;
50857
50858 -#ifdef CONFIG_STACK_GROWSUP
50859 - if (write) {
50860 - ret = expand_downwards(bprm->vma, pos);
50861 - if (ret < 0)
50862 - return NULL;
50863 - }
50864 -#endif
50865 - ret = get_user_pages(current, bprm->mm, pos,
50866 - 1, write, 1, &page, NULL);
50867 - if (ret <= 0)
50868 + if (0 > expand_downwards(bprm->vma, pos))
50869 + return NULL;
50870 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50871 return NULL;
50872
50873 if (write) {
50874 @@ -207,6 +222,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50875 if (size <= ARG_MAX)
50876 return page;
50877
50878 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50879 + // only allow 512KB for argv+env on suid/sgid binaries
50880 + // to prevent easy ASLR exhaustion
50881 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50882 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50883 + (size > (512 * 1024))) {
50884 + put_page(page);
50885 + return NULL;
50886 + }
50887 +#endif
50888 +
50889 /*
50890 * Limit to 1/4-th the stack size for the argv+env strings.
50891 * This ensures that:
50892 @@ -266,6 +292,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50893 vma->vm_end = STACK_TOP_MAX;
50894 vma->vm_start = vma->vm_end - PAGE_SIZE;
50895 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50896 +
50897 +#ifdef CONFIG_PAX_SEGMEXEC
50898 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50899 +#endif
50900 +
50901 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50902 INIT_LIST_HEAD(&vma->anon_vma_chain);
50903
50904 @@ -276,6 +307,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50905 mm->stack_vm = mm->total_vm = 1;
50906 up_write(&mm->mmap_sem);
50907 bprm->p = vma->vm_end - sizeof(void *);
50908 +
50909 +#ifdef CONFIG_PAX_RANDUSTACK
50910 + if (randomize_va_space)
50911 + bprm->p ^= random32() & ~PAGE_MASK;
50912 +#endif
50913 +
50914 return 0;
50915 err:
50916 up_write(&mm->mmap_sem);
50917 @@ -396,7 +433,7 @@ struct user_arg_ptr {
50918 } ptr;
50919 };
50920
50921 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50922 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50923 {
50924 const char __user *native;
50925
50926 @@ -405,14 +442,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50927 compat_uptr_t compat;
50928
50929 if (get_user(compat, argv.ptr.compat + nr))
50930 - return ERR_PTR(-EFAULT);
50931 + return (const char __force_user *)ERR_PTR(-EFAULT);
50932
50933 return compat_ptr(compat);
50934 }
50935 #endif
50936
50937 if (get_user(native, argv.ptr.native + nr))
50938 - return ERR_PTR(-EFAULT);
50939 + return (const char __force_user *)ERR_PTR(-EFAULT);
50940
50941 return native;
50942 }
50943 @@ -431,7 +468,7 @@ static int count(struct user_arg_ptr argv, int max)
50944 if (!p)
50945 break;
50946
50947 - if (IS_ERR(p))
50948 + if (IS_ERR((const char __force_kernel *)p))
50949 return -EFAULT;
50950
50951 if (i >= max)
50952 @@ -466,7 +503,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50953
50954 ret = -EFAULT;
50955 str = get_user_arg_ptr(argv, argc);
50956 - if (IS_ERR(str))
50957 + if (IS_ERR((const char __force_kernel *)str))
50958 goto out;
50959
50960 len = strnlen_user(str, MAX_ARG_STRLEN);
50961 @@ -548,7 +585,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50962 int r;
50963 mm_segment_t oldfs = get_fs();
50964 struct user_arg_ptr argv = {
50965 - .ptr.native = (const char __user *const __user *)__argv,
50966 + .ptr.native = (const char __force_user *const __force_user *)__argv,
50967 };
50968
50969 set_fs(KERNEL_DS);
50970 @@ -583,7 +620,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50971 unsigned long new_end = old_end - shift;
50972 struct mmu_gather tlb;
50973
50974 - BUG_ON(new_start > new_end);
50975 + if (new_start >= new_end || new_start < mmap_min_addr)
50976 + return -ENOMEM;
50977
50978 /*
50979 * ensure there are no vmas between where we want to go
50980 @@ -592,6 +630,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50981 if (vma != find_vma(mm, new_start))
50982 return -EFAULT;
50983
50984 +#ifdef CONFIG_PAX_SEGMEXEC
50985 + BUG_ON(pax_find_mirror_vma(vma));
50986 +#endif
50987 +
50988 /*
50989 * cover the whole range: [new_start, old_end)
50990 */
50991 @@ -672,10 +714,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50992 stack_top = arch_align_stack(stack_top);
50993 stack_top = PAGE_ALIGN(stack_top);
50994
50995 - if (unlikely(stack_top < mmap_min_addr) ||
50996 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50997 - return -ENOMEM;
50998 -
50999 stack_shift = vma->vm_end - stack_top;
51000
51001 bprm->p -= stack_shift;
51002 @@ -687,8 +725,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
51003 bprm->exec -= stack_shift;
51004
51005 down_write(&mm->mmap_sem);
51006 +
51007 + /* Move stack pages down in memory. */
51008 + if (stack_shift) {
51009 + ret = shift_arg_pages(vma, stack_shift);
51010 + if (ret)
51011 + goto out_unlock;
51012 + }
51013 +
51014 vm_flags = VM_STACK_FLAGS;
51015
51016 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51017 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51018 + vm_flags &= ~VM_EXEC;
51019 +
51020 +#ifdef CONFIG_PAX_MPROTECT
51021 + if (mm->pax_flags & MF_PAX_MPROTECT)
51022 + vm_flags &= ~VM_MAYEXEC;
51023 +#endif
51024 +
51025 + }
51026 +#endif
51027 +
51028 /*
51029 * Adjust stack execute permissions; explicitly enable for
51030 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
51031 @@ -707,13 +765,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
51032 goto out_unlock;
51033 BUG_ON(prev != vma);
51034
51035 - /* Move stack pages down in memory. */
51036 - if (stack_shift) {
51037 - ret = shift_arg_pages(vma, stack_shift);
51038 - if (ret)
51039 - goto out_unlock;
51040 - }
51041 -
51042 /* mprotect_fixup is overkill to remove the temporary stack flags */
51043 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
51044
51045 @@ -737,6 +788,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
51046 #endif
51047 current->mm->start_stack = bprm->p;
51048 ret = expand_stack(vma, stack_base);
51049 +
51050 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
51051 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
51052 + unsigned long size, flags, vm_flags;
51053 +
51054 + size = STACK_TOP - vma->vm_end;
51055 + flags = MAP_FIXED | MAP_PRIVATE;
51056 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
51057 +
51058 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, flags, vm_flags, 0);
51059 +
51060 +#ifdef CONFIG_X86
51061 + if (!ret) {
51062 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
51063 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), flags, vm_flags, 0);
51064 + }
51065 +#endif
51066 +
51067 + }
51068 +#endif
51069 +
51070 if (ret)
51071 ret = -EFAULT;
51072
51073 @@ -772,6 +844,8 @@ struct file *open_exec(const char *name)
51074
51075 fsnotify_open(file);
51076
51077 + trace_open_exec(name);
51078 +
51079 err = deny_write_access(file);
51080 if (err)
51081 goto exit;
51082 @@ -795,7 +869,7 @@ int kernel_read(struct file *file, loff_t offset,
51083 old_fs = get_fs();
51084 set_fs(get_ds());
51085 /* The cast to a user pointer is valid due to the set_fs() */
51086 - result = vfs_read(file, (void __user *)addr, count, &pos);
51087 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
51088 set_fs(old_fs);
51089 return result;
51090 }
51091 @@ -1247,7 +1321,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
51092 }
51093 rcu_read_unlock();
51094
51095 - if (p->fs->users > n_fs) {
51096 + if (atomic_read(&p->fs->users) > n_fs) {
51097 bprm->unsafe |= LSM_UNSAFE_SHARE;
51098 } else {
51099 res = -EAGAIN;
51100 @@ -1447,6 +1521,31 @@ int search_binary_handler(struct linux_binprm *bprm)
51101
51102 EXPORT_SYMBOL(search_binary_handler);
51103
51104 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51105 +static DEFINE_PER_CPU(u64, exec_counter);
51106 +static int __init init_exec_counters(void)
51107 +{
51108 + unsigned int cpu;
51109 +
51110 + for_each_possible_cpu(cpu) {
51111 + per_cpu(exec_counter, cpu) = (u64)cpu;
51112 + }
51113 +
51114 + return 0;
51115 +}
51116 +early_initcall(init_exec_counters);
51117 +static inline void increment_exec_counter(void)
51118 +{
51119 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
51120 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
51121 +}
51122 +#else
51123 +static inline void increment_exec_counter(void) {}
51124 +#endif
51125 +
51126 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
51127 + struct user_arg_ptr argv);
51128 +
51129 /*
51130 * sys_execve() executes a new program.
51131 */
51132 @@ -1454,6 +1553,11 @@ static int do_execve_common(const char *filename,
51133 struct user_arg_ptr argv,
51134 struct user_arg_ptr envp)
51135 {
51136 +#ifdef CONFIG_GRKERNSEC
51137 + struct file *old_exec_file;
51138 + struct acl_subject_label *old_acl;
51139 + struct rlimit old_rlim[RLIM_NLIMITS];
51140 +#endif
51141 struct linux_binprm *bprm;
51142 struct file *file;
51143 struct files_struct *displaced;
51144 @@ -1461,6 +1565,8 @@ static int do_execve_common(const char *filename,
51145 int retval;
51146 const struct cred *cred = current_cred();
51147
51148 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current->cred->user->processes), 1);
51149 +
51150 /*
51151 * We move the actual failure in case of RLIMIT_NPROC excess from
51152 * set*uid() to execve() because too many poorly written programs
51153 @@ -1501,12 +1607,27 @@ static int do_execve_common(const char *filename,
51154 if (IS_ERR(file))
51155 goto out_unmark;
51156
51157 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
51158 + retval = -EPERM;
51159 + goto out_file;
51160 + }
51161 +
51162 sched_exec();
51163
51164 bprm->file = file;
51165 bprm->filename = filename;
51166 bprm->interp = filename;
51167
51168 + if (gr_process_user_ban()) {
51169 + retval = -EPERM;
51170 + goto out_file;
51171 + }
51172 +
51173 + if (!gr_acl_handle_execve(file->f_dentry, file->f_vfsmnt)) {
51174 + retval = -EACCES;
51175 + goto out_file;
51176 + }
51177 +
51178 retval = bprm_mm_init(bprm);
51179 if (retval)
51180 goto out_file;
51181 @@ -1523,24 +1644,65 @@ static int do_execve_common(const char *filename,
51182 if (retval < 0)
51183 goto out;
51184
51185 +#ifdef CONFIG_GRKERNSEC
51186 + old_acl = current->acl;
51187 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
51188 + old_exec_file = current->exec_file;
51189 + get_file(file);
51190 + current->exec_file = file;
51191 +#endif
51192 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
51193 + /* limit suid stack to 8MB
51194 + * we saved the old limits above and will restore them if this exec fails
51195 + */
51196 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51197 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51198 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51199 +#endif
51200 +
51201 + if (!gr_tpe_allow(file)) {
51202 + retval = -EACCES;
51203 + goto out_fail;
51204 + }
51205 +
51206 + if (gr_check_crash_exec(file)) {
51207 + retval = -EACCES;
51208 + goto out_fail;
51209 + }
51210 +
51211 + retval = gr_set_proc_label(file->f_dentry, file->f_vfsmnt,
51212 + bprm->unsafe);
51213 + if (retval < 0)
51214 + goto out_fail;
51215 +
51216 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51217 if (retval < 0)
51218 - goto out;
51219 + goto out_fail;
51220
51221 bprm->exec = bprm->p;
51222 retval = copy_strings(bprm->envc, envp, bprm);
51223 if (retval < 0)
51224 - goto out;
51225 + goto out_fail;
51226
51227 retval = copy_strings(bprm->argc, argv, bprm);
51228 if (retval < 0)
51229 - goto out;
51230 + goto out_fail;
51231 +
51232 + gr_log_chroot_exec(file->f_dentry, file->f_vfsmnt);
51233 +
51234 + gr_handle_exec_args(bprm, argv);
51235
51236 retval = search_binary_handler(bprm);
51237 if (retval < 0)
51238 - goto out;
51239 + goto out_fail;
51240 +#ifdef CONFIG_GRKERNSEC
51241 + if (old_exec_file)
51242 + fput(old_exec_file);
51243 +#endif
51244
51245 /* execve succeeded */
51246 +
51247 + increment_exec_counter();
51248 current->fs->in_exec = 0;
51249 current->in_execve = 0;
51250 acct_update_integrals(current);
51251 @@ -1549,6 +1711,14 @@ static int do_execve_common(const char *filename,
51252 put_files_struct(displaced);
51253 return retval;
51254
51255 +out_fail:
51256 +#ifdef CONFIG_GRKERNSEC
51257 + current->acl = old_acl;
51258 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51259 + fput(current->exec_file);
51260 + current->exec_file = old_exec_file;
51261 +#endif
51262 +
51263 out:
51264 if (bprm->mm) {
51265 acct_arg_size(bprm, 0);
51266 @@ -1697,3 +1867,253 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51267 return error;
51268 }
51269 #endif
51270 +
51271 +int pax_check_flags(unsigned long *flags)
51272 +{
51273 + int retval = 0;
51274 +
51275 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51276 + if (*flags & MF_PAX_SEGMEXEC)
51277 + {
51278 + *flags &= ~MF_PAX_SEGMEXEC;
51279 + retval = -EINVAL;
51280 + }
51281 +#endif
51282 +
51283 + if ((*flags & MF_PAX_PAGEEXEC)
51284 +
51285 +#ifdef CONFIG_PAX_PAGEEXEC
51286 + && (*flags & MF_PAX_SEGMEXEC)
51287 +#endif
51288 +
51289 + )
51290 + {
51291 + *flags &= ~MF_PAX_PAGEEXEC;
51292 + retval = -EINVAL;
51293 + }
51294 +
51295 + if ((*flags & MF_PAX_MPROTECT)
51296 +
51297 +#ifdef CONFIG_PAX_MPROTECT
51298 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51299 +#endif
51300 +
51301 + )
51302 + {
51303 + *flags &= ~MF_PAX_MPROTECT;
51304 + retval = -EINVAL;
51305 + }
51306 +
51307 + if ((*flags & MF_PAX_EMUTRAMP)
51308 +
51309 +#ifdef CONFIG_PAX_EMUTRAMP
51310 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51311 +#endif
51312 +
51313 + )
51314 + {
51315 + *flags &= ~MF_PAX_EMUTRAMP;
51316 + retval = -EINVAL;
51317 + }
51318 +
51319 + return retval;
51320 +}
51321 +
51322 +EXPORT_SYMBOL(pax_check_flags);
51323 +
51324 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51325 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51326 +{
51327 + struct task_struct *tsk = current;
51328 + struct mm_struct *mm = current->mm;
51329 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51330 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51331 + char *path_exec = NULL;
51332 + char *path_fault = NULL;
51333 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51334 + siginfo_t info = { };
51335 +
51336 + if (buffer_exec && buffer_fault) {
51337 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51338 +
51339 + down_read(&mm->mmap_sem);
51340 + vma = mm->mmap;
51341 + while (vma && (!vma_exec || !vma_fault)) {
51342 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51343 + vma_exec = vma;
51344 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51345 + vma_fault = vma;
51346 + vma = vma->vm_next;
51347 + }
51348 + if (vma_exec) {
51349 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51350 + if (IS_ERR(path_exec))
51351 + path_exec = "<path too long>";
51352 + else {
51353 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51354 + if (path_exec) {
51355 + *path_exec = 0;
51356 + path_exec = buffer_exec;
51357 + } else
51358 + path_exec = "<path too long>";
51359 + }
51360 + }
51361 + if (vma_fault) {
51362 + start = vma_fault->vm_start;
51363 + end = vma_fault->vm_end;
51364 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51365 + if (vma_fault->vm_file) {
51366 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51367 + if (IS_ERR(path_fault))
51368 + path_fault = "<path too long>";
51369 + else {
51370 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51371 + if (path_fault) {
51372 + *path_fault = 0;
51373 + path_fault = buffer_fault;
51374 + } else
51375 + path_fault = "<path too long>";
51376 + }
51377 + } else
51378 + path_fault = "<anonymous mapping>";
51379 + }
51380 + up_read(&mm->mmap_sem);
51381 + }
51382 + if (tsk->signal->curr_ip)
51383 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51384 + else
51385 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51386 + 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),
51387 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51388 + free_page((unsigned long)buffer_exec);
51389 + free_page((unsigned long)buffer_fault);
51390 + pax_report_insns(regs, pc, sp);
51391 + info.si_signo = SIGKILL;
51392 + info.si_errno = 0;
51393 + info.si_code = SI_KERNEL;
51394 + info.si_pid = 0;
51395 + info.si_uid = 0;
51396 + do_coredump(&info);
51397 +}
51398 +#endif
51399 +
51400 +#ifdef CONFIG_PAX_REFCOUNT
51401 +void pax_report_refcount_overflow(struct pt_regs *regs)
51402 +{
51403 + if (current->signal->curr_ip)
51404 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51405 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51406 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51407 + else
51408 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51409 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51410 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51411 + show_regs(regs);
51412 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51413 +}
51414 +#endif
51415 +
51416 +#ifdef CONFIG_PAX_USERCOPY
51417 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51418 +static noinline int check_stack_object(const void *obj, unsigned long len)
51419 +{
51420 + const void * const stack = task_stack_page(current);
51421 + const void * const stackend = stack + THREAD_SIZE;
51422 +
51423 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51424 + const void *frame = NULL;
51425 + const void *oldframe;
51426 +#endif
51427 +
51428 + if (obj + len < obj)
51429 + return -1;
51430 +
51431 + if (obj + len <= stack || stackend <= obj)
51432 + return 0;
51433 +
51434 + if (obj < stack || stackend < obj + len)
51435 + return -1;
51436 +
51437 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51438 + oldframe = __builtin_frame_address(1);
51439 + if (oldframe)
51440 + frame = __builtin_frame_address(2);
51441 + /*
51442 + low ----------------------------------------------> high
51443 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51444 + ^----------------^
51445 + allow copies only within here
51446 + */
51447 + while (stack <= frame && frame < stackend) {
51448 + /* if obj + len extends past the last frame, this
51449 + check won't pass and the next frame will be 0,
51450 + causing us to bail out and correctly report
51451 + the copy as invalid
51452 + */
51453 + if (obj + len <= frame)
51454 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51455 + oldframe = frame;
51456 + frame = *(const void * const *)frame;
51457 + }
51458 + return -1;
51459 +#else
51460 + return 1;
51461 +#endif
51462 +}
51463 +
51464 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51465 +{
51466 + if (current->signal->curr_ip)
51467 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51468 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51469 + else
51470 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51471 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51472 + dump_stack();
51473 + gr_handle_kernel_exploit();
51474 + do_group_exit(SIGKILL);
51475 +}
51476 +#endif
51477 +
51478 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51479 +{
51480 +
51481 +#ifdef CONFIG_PAX_USERCOPY
51482 + const char *type;
51483 +
51484 + if (!n)
51485 + return;
51486 +
51487 + type = check_heap_object(ptr, n);
51488 + if (!type) {
51489 + if (check_stack_object(ptr, n) != -1)
51490 + return;
51491 + type = "<process stack>";
51492 + }
51493 +
51494 + pax_report_usercopy(ptr, n, to_user, type);
51495 +#endif
51496 +
51497 +}
51498 +EXPORT_SYMBOL(__check_object_size);
51499 +
51500 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51501 +void pax_track_stack(void)
51502 +{
51503 + unsigned long sp = (unsigned long)&sp;
51504 + if (sp < current_thread_info()->lowest_stack &&
51505 + sp > (unsigned long)task_stack_page(current))
51506 + current_thread_info()->lowest_stack = sp;
51507 +}
51508 +EXPORT_SYMBOL(pax_track_stack);
51509 +#endif
51510 +
51511 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51512 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51513 +{
51514 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51515 + dump_stack();
51516 + do_group_exit(SIGKILL);
51517 +}
51518 +EXPORT_SYMBOL(report_size_overflow);
51519 +#endif
51520 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51521 index 2616d0e..2ffdec9 100644
51522 --- a/fs/ext2/balloc.c
51523 +++ b/fs/ext2/balloc.c
51524 @@ -1190,10 +1190,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51525
51526 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51527 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51528 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51529 + if (free_blocks < root_blocks + 1 &&
51530 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51531 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51532 - !in_group_p (sbi->s_resgid))) {
51533 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51534 return 0;
51535 }
51536 return 1;
51537 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51538 index 22548f5..41521d8 100644
51539 --- a/fs/ext3/balloc.c
51540 +++ b/fs/ext3/balloc.c
51541 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51542
51543 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51544 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51545 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51546 + if (free_blocks < root_blocks + 1 &&
51547 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51548 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51549 - !in_group_p (sbi->s_resgid))) {
51550 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51551 return 0;
51552 }
51553 return 1;
51554 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51555 index 92e68b3..115d987 100644
51556 --- a/fs/ext4/balloc.c
51557 +++ b/fs/ext4/balloc.c
51558 @@ -505,8 +505,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51559 /* Hm, nope. Are (enough) root reserved clusters available? */
51560 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51561 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51562 - capable(CAP_SYS_RESOURCE) ||
51563 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51564 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51565 + capable_nolog(CAP_SYS_RESOURCE)) {
51566
51567 if (free_clusters >= (nclusters + dirty_clusters))
51568 return 1;
51569 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51570 index bbcd6a0..2824592 100644
51571 --- a/fs/ext4/ext4.h
51572 +++ b/fs/ext4/ext4.h
51573 @@ -1265,19 +1265,19 @@ struct ext4_sb_info {
51574 unsigned long s_mb_last_start;
51575
51576 /* stats for buddy allocator */
51577 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51578 - atomic_t s_bal_success; /* we found long enough chunks */
51579 - atomic_t s_bal_allocated; /* in blocks */
51580 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51581 - atomic_t s_bal_goals; /* goal hits */
51582 - atomic_t s_bal_breaks; /* too long searches */
51583 - atomic_t s_bal_2orders; /* 2^order hits */
51584 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51585 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51586 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51587 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51588 + atomic_unchecked_t s_bal_goals; /* goal hits */
51589 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51590 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51591 spinlock_t s_bal_lock;
51592 unsigned long s_mb_buddies_generated;
51593 unsigned long long s_mb_generation_time;
51594 - atomic_t s_mb_lost_chunks;
51595 - atomic_t s_mb_preallocated;
51596 - atomic_t s_mb_discarded;
51597 + atomic_unchecked_t s_mb_lost_chunks;
51598 + atomic_unchecked_t s_mb_preallocated;
51599 + atomic_unchecked_t s_mb_discarded;
51600 atomic_t s_lock_busy;
51601
51602 /* locality groups */
51603 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51604 index 82f8c2d..ce7c889 100644
51605 --- a/fs/ext4/mballoc.c
51606 +++ b/fs/ext4/mballoc.c
51607 @@ -1747,7 +1747,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51608 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51609
51610 if (EXT4_SB(sb)->s_mb_stats)
51611 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51612 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51613
51614 break;
51615 }
51616 @@ -2044,7 +2044,7 @@ repeat:
51617 ac->ac_status = AC_STATUS_CONTINUE;
51618 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51619 cr = 3;
51620 - atomic_inc(&sbi->s_mb_lost_chunks);
51621 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51622 goto repeat;
51623 }
51624 }
51625 @@ -2552,25 +2552,25 @@ int ext4_mb_release(struct super_block *sb)
51626 if (sbi->s_mb_stats) {
51627 ext4_msg(sb, KERN_INFO,
51628 "mballoc: %u blocks %u reqs (%u success)",
51629 - atomic_read(&sbi->s_bal_allocated),
51630 - atomic_read(&sbi->s_bal_reqs),
51631 - atomic_read(&sbi->s_bal_success));
51632 + atomic_read_unchecked(&sbi->s_bal_allocated),
51633 + atomic_read_unchecked(&sbi->s_bal_reqs),
51634 + atomic_read_unchecked(&sbi->s_bal_success));
51635 ext4_msg(sb, KERN_INFO,
51636 "mballoc: %u extents scanned, %u goal hits, "
51637 "%u 2^N hits, %u breaks, %u lost",
51638 - atomic_read(&sbi->s_bal_ex_scanned),
51639 - atomic_read(&sbi->s_bal_goals),
51640 - atomic_read(&sbi->s_bal_2orders),
51641 - atomic_read(&sbi->s_bal_breaks),
51642 - atomic_read(&sbi->s_mb_lost_chunks));
51643 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51644 + atomic_read_unchecked(&sbi->s_bal_goals),
51645 + atomic_read_unchecked(&sbi->s_bal_2orders),
51646 + atomic_read_unchecked(&sbi->s_bal_breaks),
51647 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51648 ext4_msg(sb, KERN_INFO,
51649 "mballoc: %lu generated and it took %Lu",
51650 sbi->s_mb_buddies_generated,
51651 sbi->s_mb_generation_time);
51652 ext4_msg(sb, KERN_INFO,
51653 "mballoc: %u preallocated, %u discarded",
51654 - atomic_read(&sbi->s_mb_preallocated),
51655 - atomic_read(&sbi->s_mb_discarded));
51656 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51657 + atomic_read_unchecked(&sbi->s_mb_discarded));
51658 }
51659
51660 free_percpu(sbi->s_locality_groups);
51661 @@ -3060,16 +3060,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51662 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51663
51664 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51665 - atomic_inc(&sbi->s_bal_reqs);
51666 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51667 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51668 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51669 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51670 - atomic_inc(&sbi->s_bal_success);
51671 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51672 + atomic_inc_unchecked(&sbi->s_bal_success);
51673 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51674 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51675 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51676 - atomic_inc(&sbi->s_bal_goals);
51677 + atomic_inc_unchecked(&sbi->s_bal_goals);
51678 if (ac->ac_found > sbi->s_mb_max_to_scan)
51679 - atomic_inc(&sbi->s_bal_breaks);
51680 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51681 }
51682
51683 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51684 @@ -3469,7 +3469,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51685 trace_ext4_mb_new_inode_pa(ac, pa);
51686
51687 ext4_mb_use_inode_pa(ac, pa);
51688 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51689 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51690
51691 ei = EXT4_I(ac->ac_inode);
51692 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51693 @@ -3529,7 +3529,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51694 trace_ext4_mb_new_group_pa(ac, pa);
51695
51696 ext4_mb_use_group_pa(ac, pa);
51697 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51698 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51699
51700 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51701 lg = ac->ac_lg;
51702 @@ -3618,7 +3618,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51703 * from the bitmap and continue.
51704 */
51705 }
51706 - atomic_add(free, &sbi->s_mb_discarded);
51707 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51708
51709 return err;
51710 }
51711 @@ -3636,7 +3636,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51712 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51713 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51714 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51715 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51716 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51717 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51718
51719 return 0;
51720 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51721 index 24c767d..893aa55 100644
51722 --- a/fs/ext4/super.c
51723 +++ b/fs/ext4/super.c
51724 @@ -2429,7 +2429,7 @@ struct ext4_attr {
51725 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51726 const char *, size_t);
51727 int offset;
51728 -};
51729 +} __do_const;
51730
51731 static int parse_strtoul(const char *buf,
51732 unsigned long max, unsigned long *value)
51733 diff --git a/fs/fcntl.c b/fs/fcntl.c
51734 index 71a600a..20d87b1 100644
51735 --- a/fs/fcntl.c
51736 +++ b/fs/fcntl.c
51737 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51738 if (err)
51739 return err;
51740
51741 + if (gr_handle_chroot_fowner(pid, type))
51742 + return -ENOENT;
51743 + if (gr_check_protected_task_fowner(pid, type))
51744 + return -EACCES;
51745 +
51746 f_modown(filp, pid, type, force);
51747 return 0;
51748 }
51749 diff --git a/fs/fhandle.c b/fs/fhandle.c
51750 index 999ff5c..41f4109 100644
51751 --- a/fs/fhandle.c
51752 +++ b/fs/fhandle.c
51753 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51754 } else
51755 retval = 0;
51756 /* copy the mount id */
51757 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51758 - sizeof(*mnt_id)) ||
51759 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51760 copy_to_user(ufh, handle,
51761 sizeof(struct file_handle) + handle_bytes))
51762 retval = -EFAULT;
51763 diff --git a/fs/fifo.c b/fs/fifo.c
51764 index cf6f434..3d7942c 100644
51765 --- a/fs/fifo.c
51766 +++ b/fs/fifo.c
51767 @@ -59,10 +59,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
51768 */
51769 filp->f_op = &read_pipefifo_fops;
51770 pipe->r_counter++;
51771 - if (pipe->readers++ == 0)
51772 + if (atomic_inc_return(&pipe->readers) == 1)
51773 wake_up_partner(inode);
51774
51775 - if (!pipe->writers) {
51776 + if (!atomic_read(&pipe->writers)) {
51777 if ((filp->f_flags & O_NONBLOCK)) {
51778 /* suppress POLLHUP until we have
51779 * seen a writer */
51780 @@ -81,15 +81,15 @@ static int fifo_open(struct inode *inode, struct file *filp)
51781 * errno=ENXIO when there is no process reading the FIFO.
51782 */
51783 ret = -ENXIO;
51784 - if ((filp->f_flags & O_NONBLOCK) && !pipe->readers)
51785 + if ((filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
51786 goto err;
51787
51788 filp->f_op = &write_pipefifo_fops;
51789 pipe->w_counter++;
51790 - if (!pipe->writers++)
51791 + if (atomic_inc_return(&pipe->writers) == 1)
51792 wake_up_partner(inode);
51793
51794 - if (!pipe->readers) {
51795 + if (!atomic_read(&pipe->readers)) {
51796 if (wait_for_partner(inode, &pipe->r_counter))
51797 goto err_wr;
51798 }
51799 @@ -104,11 +104,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
51800 */
51801 filp->f_op = &rdwr_pipefifo_fops;
51802
51803 - pipe->readers++;
51804 - pipe->writers++;
51805 + atomic_inc(&pipe->readers);
51806 + atomic_inc(&pipe->writers);
51807 pipe->r_counter++;
51808 pipe->w_counter++;
51809 - if (pipe->readers == 1 || pipe->writers == 1)
51810 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
51811 wake_up_partner(inode);
51812 break;
51813
51814 @@ -122,19 +122,19 @@ static int fifo_open(struct inode *inode, struct file *filp)
51815 return 0;
51816
51817 err_rd:
51818 - if (!--pipe->readers)
51819 + if (atomic_dec_and_test(&pipe->readers))
51820 wake_up_interruptible(&pipe->wait);
51821 ret = -ERESTARTSYS;
51822 goto err;
51823
51824 err_wr:
51825 - if (!--pipe->writers)
51826 + if (atomic_dec_and_test(&pipe->writers))
51827 wake_up_interruptible(&pipe->wait);
51828 ret = -ERESTARTSYS;
51829 goto err;
51830
51831 err:
51832 - if (!pipe->readers && !pipe->writers)
51833 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers))
51834 free_pipe_info(inode);
51835
51836 err_nocleanup:
51837 diff --git a/fs/file.c b/fs/file.c
51838 index 2b3570b..c57924b 100644
51839 --- a/fs/file.c
51840 +++ b/fs/file.c
51841 @@ -16,6 +16,7 @@
51842 #include <linux/slab.h>
51843 #include <linux/vmalloc.h>
51844 #include <linux/file.h>
51845 +#include <linux/security.h>
51846 #include <linux/fdtable.h>
51847 #include <linux/bitops.h>
51848 #include <linux/interrupt.h>
51849 @@ -892,6 +893,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51850 if (!file)
51851 return __close_fd(files, fd);
51852
51853 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51854 if (fd >= rlimit(RLIMIT_NOFILE))
51855 return -EBADF;
51856
51857 @@ -918,6 +920,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51858 if (unlikely(oldfd == newfd))
51859 return -EINVAL;
51860
51861 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51862 if (newfd >= rlimit(RLIMIT_NOFILE))
51863 return -EBADF;
51864
51865 @@ -973,6 +976,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51866 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51867 {
51868 int err;
51869 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51870 if (from >= rlimit(RLIMIT_NOFILE))
51871 return -EINVAL;
51872 err = alloc_fd(from, flags);
51873 diff --git a/fs/filesystems.c b/fs/filesystems.c
51874 index da165f6..3671bdb 100644
51875 --- a/fs/filesystems.c
51876 +++ b/fs/filesystems.c
51877 @@ -273,7 +273,12 @@ struct file_system_type *get_fs_type(const char *name)
51878 int len = dot ? dot - name : strlen(name);
51879
51880 fs = __get_fs_type(name, len);
51881 +
51882 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51883 + if (!fs && (___request_module(true, "grsec_modharden_fs", "%.*s", len, name) == 0))
51884 +#else
51885 if (!fs && (request_module("%.*s", len, name) == 0))
51886 +#endif
51887 fs = __get_fs_type(name, len);
51888
51889 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51890 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51891 index fe6ca58..65318cf 100644
51892 --- a/fs/fs_struct.c
51893 +++ b/fs/fs_struct.c
51894 @@ -4,6 +4,7 @@
51895 #include <linux/path.h>
51896 #include <linux/slab.h>
51897 #include <linux/fs_struct.h>
51898 +#include <linux/grsecurity.h>
51899 #include "internal.h"
51900
51901 /*
51902 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, struct path *path)
51903 write_seqcount_begin(&fs->seq);
51904 old_root = fs->root;
51905 fs->root = *path;
51906 + gr_set_chroot_entries(current, path);
51907 write_seqcount_end(&fs->seq);
51908 spin_unlock(&fs->lock);
51909 if (old_root.dentry)
51910 @@ -53,6 +55,21 @@ static inline int replace_path(struct path *p, const struct path *old, const str
51911 return 1;
51912 }
51913
51914 +static inline int replace_root_path(struct task_struct *task, struct path *p, const struct path *old, struct path *new)
51915 +{
51916 + if (likely(p->dentry != old->dentry || p->mnt != old->mnt))
51917 + return 0;
51918 + *p = *new;
51919 +
51920 + /* This function is only called from pivot_root(). Leave our
51921 + gr_chroot_dentry and is_chrooted flags as-is, so that a
51922 + pivoted root isn't treated as a chroot
51923 + */
51924 + //gr_set_chroot_entries(task, new);
51925 +
51926 + return 1;
51927 +}
51928 +
51929 void chroot_fs_refs(struct path *old_root, struct path *new_root)
51930 {
51931 struct task_struct *g, *p;
51932 @@ -67,7 +84,7 @@ void chroot_fs_refs(struct path *old_root, struct path *new_root)
51933 int hits = 0;
51934 spin_lock(&fs->lock);
51935 write_seqcount_begin(&fs->seq);
51936 - hits += replace_path(&fs->root, old_root, new_root);
51937 + hits += replace_root_path(p, &fs->root, old_root, new_root);
51938 hits += replace_path(&fs->pwd, old_root, new_root);
51939 write_seqcount_end(&fs->seq);
51940 while (hits--) {
51941 @@ -99,7 +116,8 @@ void exit_fs(struct task_struct *tsk)
51942 task_lock(tsk);
51943 spin_lock(&fs->lock);
51944 tsk->fs = NULL;
51945 - kill = !--fs->users;
51946 + gr_clear_chroot_entries(tsk);
51947 + kill = !atomic_dec_return(&fs->users);
51948 spin_unlock(&fs->lock);
51949 task_unlock(tsk);
51950 if (kill)
51951 @@ -112,7 +130,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51952 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51953 /* We don't need to lock fs - think why ;-) */
51954 if (fs) {
51955 - fs->users = 1;
51956 + atomic_set(&fs->users, 1);
51957 fs->in_exec = 0;
51958 spin_lock_init(&fs->lock);
51959 seqcount_init(&fs->seq);
51960 @@ -121,6 +139,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51961 spin_lock(&old->lock);
51962 fs->root = old->root;
51963 path_get(&fs->root);
51964 + /* instead of calling gr_set_chroot_entries here,
51965 + we call it from every caller of this function
51966 + */
51967 fs->pwd = old->pwd;
51968 path_get(&fs->pwd);
51969 spin_unlock(&old->lock);
51970 @@ -139,8 +160,9 @@ int unshare_fs_struct(void)
51971
51972 task_lock(current);
51973 spin_lock(&fs->lock);
51974 - kill = !--fs->users;
51975 + kill = !atomic_dec_return(&fs->users);
51976 current->fs = new_fs;
51977 + gr_set_chroot_entries(current, &new_fs->root);
51978 spin_unlock(&fs->lock);
51979 task_unlock(current);
51980
51981 @@ -153,13 +175,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51982
51983 int current_umask(void)
51984 {
51985 - return current->fs->umask;
51986 + return current->fs->umask | gr_acl_umask();
51987 }
51988 EXPORT_SYMBOL(current_umask);
51989
51990 /* to be mentioned only in INIT_TASK */
51991 struct fs_struct init_fs = {
51992 - .users = 1,
51993 + .users = ATOMIC_INIT(1),
51994 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51995 .seq = SEQCNT_ZERO,
51996 .umask = 0022,
51997 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51998 index 8dcb114..b1072e2 100644
51999 --- a/fs/fscache/cookie.c
52000 +++ b/fs/fscache/cookie.c
52001 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
52002 parent ? (char *) parent->def->name : "<no-parent>",
52003 def->name, netfs_data);
52004
52005 - fscache_stat(&fscache_n_acquires);
52006 + fscache_stat_unchecked(&fscache_n_acquires);
52007
52008 /* if there's no parent cookie, then we don't create one here either */
52009 if (!parent) {
52010 - fscache_stat(&fscache_n_acquires_null);
52011 + fscache_stat_unchecked(&fscache_n_acquires_null);
52012 _leave(" [no parent]");
52013 return NULL;
52014 }
52015 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
52016 /* allocate and initialise a cookie */
52017 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
52018 if (!cookie) {
52019 - fscache_stat(&fscache_n_acquires_oom);
52020 + fscache_stat_unchecked(&fscache_n_acquires_oom);
52021 _leave(" [ENOMEM]");
52022 return NULL;
52023 }
52024 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52025
52026 switch (cookie->def->type) {
52027 case FSCACHE_COOKIE_TYPE_INDEX:
52028 - fscache_stat(&fscache_n_cookie_index);
52029 + fscache_stat_unchecked(&fscache_n_cookie_index);
52030 break;
52031 case FSCACHE_COOKIE_TYPE_DATAFILE:
52032 - fscache_stat(&fscache_n_cookie_data);
52033 + fscache_stat_unchecked(&fscache_n_cookie_data);
52034 break;
52035 default:
52036 - fscache_stat(&fscache_n_cookie_special);
52037 + fscache_stat_unchecked(&fscache_n_cookie_special);
52038 break;
52039 }
52040
52041 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
52042 if (fscache_acquire_non_index_cookie(cookie) < 0) {
52043 atomic_dec(&parent->n_children);
52044 __fscache_cookie_put(cookie);
52045 - fscache_stat(&fscache_n_acquires_nobufs);
52046 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
52047 _leave(" = NULL");
52048 return NULL;
52049 }
52050 }
52051
52052 - fscache_stat(&fscache_n_acquires_ok);
52053 + fscache_stat_unchecked(&fscache_n_acquires_ok);
52054 _leave(" = %p", cookie);
52055 return cookie;
52056 }
52057 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
52058 cache = fscache_select_cache_for_object(cookie->parent);
52059 if (!cache) {
52060 up_read(&fscache_addremove_sem);
52061 - fscache_stat(&fscache_n_acquires_no_cache);
52062 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
52063 _leave(" = -ENOMEDIUM [no cache]");
52064 return -ENOMEDIUM;
52065 }
52066 @@ -256,12 +256,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
52067 object = cache->ops->alloc_object(cache, cookie);
52068 fscache_stat_d(&fscache_n_cop_alloc_object);
52069 if (IS_ERR(object)) {
52070 - fscache_stat(&fscache_n_object_no_alloc);
52071 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
52072 ret = PTR_ERR(object);
52073 goto error;
52074 }
52075
52076 - fscache_stat(&fscache_n_object_alloc);
52077 + fscache_stat_unchecked(&fscache_n_object_alloc);
52078
52079 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
52080
52081 @@ -378,7 +378,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
52082
52083 _enter("{%s}", cookie->def->name);
52084
52085 - fscache_stat(&fscache_n_invalidates);
52086 + fscache_stat_unchecked(&fscache_n_invalidates);
52087
52088 /* Only permit invalidation of data files. Invalidating an index will
52089 * require the caller to release all its attachments to the tree rooted
52090 @@ -437,10 +437,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
52091 struct fscache_object *object;
52092 struct hlist_node *_p;
52093
52094 - fscache_stat(&fscache_n_updates);
52095 + fscache_stat_unchecked(&fscache_n_updates);
52096
52097 if (!cookie) {
52098 - fscache_stat(&fscache_n_updates_null);
52099 + fscache_stat_unchecked(&fscache_n_updates_null);
52100 _leave(" [no cookie]");
52101 return;
52102 }
52103 @@ -474,12 +474,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52104 struct fscache_object *object;
52105 unsigned long event;
52106
52107 - fscache_stat(&fscache_n_relinquishes);
52108 + fscache_stat_unchecked(&fscache_n_relinquishes);
52109 if (retire)
52110 - fscache_stat(&fscache_n_relinquishes_retire);
52111 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
52112
52113 if (!cookie) {
52114 - fscache_stat(&fscache_n_relinquishes_null);
52115 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
52116 _leave(" [no cookie]");
52117 return;
52118 }
52119 @@ -495,7 +495,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
52120
52121 /* wait for the cookie to finish being instantiated (or to fail) */
52122 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
52123 - fscache_stat(&fscache_n_relinquishes_waitcrt);
52124 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
52125 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
52126 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
52127 }
52128 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
52129 index ee38fef..0a326d4 100644
52130 --- a/fs/fscache/internal.h
52131 +++ b/fs/fscache/internal.h
52132 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
52133 * stats.c
52134 */
52135 #ifdef CONFIG_FSCACHE_STATS
52136 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52137 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52138 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
52139 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
52140
52141 -extern atomic_t fscache_n_op_pend;
52142 -extern atomic_t fscache_n_op_run;
52143 -extern atomic_t fscache_n_op_enqueue;
52144 -extern atomic_t fscache_n_op_deferred_release;
52145 -extern atomic_t fscache_n_op_release;
52146 -extern atomic_t fscache_n_op_gc;
52147 -extern atomic_t fscache_n_op_cancelled;
52148 -extern atomic_t fscache_n_op_rejected;
52149 +extern atomic_unchecked_t fscache_n_op_pend;
52150 +extern atomic_unchecked_t fscache_n_op_run;
52151 +extern atomic_unchecked_t fscache_n_op_enqueue;
52152 +extern atomic_unchecked_t fscache_n_op_deferred_release;
52153 +extern atomic_unchecked_t fscache_n_op_release;
52154 +extern atomic_unchecked_t fscache_n_op_gc;
52155 +extern atomic_unchecked_t fscache_n_op_cancelled;
52156 +extern atomic_unchecked_t fscache_n_op_rejected;
52157
52158 -extern atomic_t fscache_n_attr_changed;
52159 -extern atomic_t fscache_n_attr_changed_ok;
52160 -extern atomic_t fscache_n_attr_changed_nobufs;
52161 -extern atomic_t fscache_n_attr_changed_nomem;
52162 -extern atomic_t fscache_n_attr_changed_calls;
52163 +extern atomic_unchecked_t fscache_n_attr_changed;
52164 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
52165 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
52166 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
52167 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
52168
52169 -extern atomic_t fscache_n_allocs;
52170 -extern atomic_t fscache_n_allocs_ok;
52171 -extern atomic_t fscache_n_allocs_wait;
52172 -extern atomic_t fscache_n_allocs_nobufs;
52173 -extern atomic_t fscache_n_allocs_intr;
52174 -extern atomic_t fscache_n_allocs_object_dead;
52175 -extern atomic_t fscache_n_alloc_ops;
52176 -extern atomic_t fscache_n_alloc_op_waits;
52177 +extern atomic_unchecked_t fscache_n_allocs;
52178 +extern atomic_unchecked_t fscache_n_allocs_ok;
52179 +extern atomic_unchecked_t fscache_n_allocs_wait;
52180 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
52181 +extern atomic_unchecked_t fscache_n_allocs_intr;
52182 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
52183 +extern atomic_unchecked_t fscache_n_alloc_ops;
52184 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
52185
52186 -extern atomic_t fscache_n_retrievals;
52187 -extern atomic_t fscache_n_retrievals_ok;
52188 -extern atomic_t fscache_n_retrievals_wait;
52189 -extern atomic_t fscache_n_retrievals_nodata;
52190 -extern atomic_t fscache_n_retrievals_nobufs;
52191 -extern atomic_t fscache_n_retrievals_intr;
52192 -extern atomic_t fscache_n_retrievals_nomem;
52193 -extern atomic_t fscache_n_retrievals_object_dead;
52194 -extern atomic_t fscache_n_retrieval_ops;
52195 -extern atomic_t fscache_n_retrieval_op_waits;
52196 +extern atomic_unchecked_t fscache_n_retrievals;
52197 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52198 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52199 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52200 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52201 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52202 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52203 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52204 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52205 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52206
52207 -extern atomic_t fscache_n_stores;
52208 -extern atomic_t fscache_n_stores_ok;
52209 -extern atomic_t fscache_n_stores_again;
52210 -extern atomic_t fscache_n_stores_nobufs;
52211 -extern atomic_t fscache_n_stores_oom;
52212 -extern atomic_t fscache_n_store_ops;
52213 -extern atomic_t fscache_n_store_calls;
52214 -extern atomic_t fscache_n_store_pages;
52215 -extern atomic_t fscache_n_store_radix_deletes;
52216 -extern atomic_t fscache_n_store_pages_over_limit;
52217 +extern atomic_unchecked_t fscache_n_stores;
52218 +extern atomic_unchecked_t fscache_n_stores_ok;
52219 +extern atomic_unchecked_t fscache_n_stores_again;
52220 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52221 +extern atomic_unchecked_t fscache_n_stores_oom;
52222 +extern atomic_unchecked_t fscache_n_store_ops;
52223 +extern atomic_unchecked_t fscache_n_store_calls;
52224 +extern atomic_unchecked_t fscache_n_store_pages;
52225 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52226 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52227
52228 -extern atomic_t fscache_n_store_vmscan_not_storing;
52229 -extern atomic_t fscache_n_store_vmscan_gone;
52230 -extern atomic_t fscache_n_store_vmscan_busy;
52231 -extern atomic_t fscache_n_store_vmscan_cancelled;
52232 -extern atomic_t fscache_n_store_vmscan_wait;
52233 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52234 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52235 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52236 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52237 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52238
52239 -extern atomic_t fscache_n_marks;
52240 -extern atomic_t fscache_n_uncaches;
52241 +extern atomic_unchecked_t fscache_n_marks;
52242 +extern atomic_unchecked_t fscache_n_uncaches;
52243
52244 -extern atomic_t fscache_n_acquires;
52245 -extern atomic_t fscache_n_acquires_null;
52246 -extern atomic_t fscache_n_acquires_no_cache;
52247 -extern atomic_t fscache_n_acquires_ok;
52248 -extern atomic_t fscache_n_acquires_nobufs;
52249 -extern atomic_t fscache_n_acquires_oom;
52250 +extern atomic_unchecked_t fscache_n_acquires;
52251 +extern atomic_unchecked_t fscache_n_acquires_null;
52252 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52253 +extern atomic_unchecked_t fscache_n_acquires_ok;
52254 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52255 +extern atomic_unchecked_t fscache_n_acquires_oom;
52256
52257 -extern atomic_t fscache_n_invalidates;
52258 -extern atomic_t fscache_n_invalidates_run;
52259 +extern atomic_unchecked_t fscache_n_invalidates;
52260 +extern atomic_unchecked_t fscache_n_invalidates_run;
52261
52262 -extern atomic_t fscache_n_updates;
52263 -extern atomic_t fscache_n_updates_null;
52264 -extern atomic_t fscache_n_updates_run;
52265 +extern atomic_unchecked_t fscache_n_updates;
52266 +extern atomic_unchecked_t fscache_n_updates_null;
52267 +extern atomic_unchecked_t fscache_n_updates_run;
52268
52269 -extern atomic_t fscache_n_relinquishes;
52270 -extern atomic_t fscache_n_relinquishes_null;
52271 -extern atomic_t fscache_n_relinquishes_waitcrt;
52272 -extern atomic_t fscache_n_relinquishes_retire;
52273 +extern atomic_unchecked_t fscache_n_relinquishes;
52274 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52275 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52276 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52277
52278 -extern atomic_t fscache_n_cookie_index;
52279 -extern atomic_t fscache_n_cookie_data;
52280 -extern atomic_t fscache_n_cookie_special;
52281 +extern atomic_unchecked_t fscache_n_cookie_index;
52282 +extern atomic_unchecked_t fscache_n_cookie_data;
52283 +extern atomic_unchecked_t fscache_n_cookie_special;
52284
52285 -extern atomic_t fscache_n_object_alloc;
52286 -extern atomic_t fscache_n_object_no_alloc;
52287 -extern atomic_t fscache_n_object_lookups;
52288 -extern atomic_t fscache_n_object_lookups_negative;
52289 -extern atomic_t fscache_n_object_lookups_positive;
52290 -extern atomic_t fscache_n_object_lookups_timed_out;
52291 -extern atomic_t fscache_n_object_created;
52292 -extern atomic_t fscache_n_object_avail;
52293 -extern atomic_t fscache_n_object_dead;
52294 +extern atomic_unchecked_t fscache_n_object_alloc;
52295 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52296 +extern atomic_unchecked_t fscache_n_object_lookups;
52297 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52298 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52299 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52300 +extern atomic_unchecked_t fscache_n_object_created;
52301 +extern atomic_unchecked_t fscache_n_object_avail;
52302 +extern atomic_unchecked_t fscache_n_object_dead;
52303
52304 -extern atomic_t fscache_n_checkaux_none;
52305 -extern atomic_t fscache_n_checkaux_okay;
52306 -extern atomic_t fscache_n_checkaux_update;
52307 -extern atomic_t fscache_n_checkaux_obsolete;
52308 +extern atomic_unchecked_t fscache_n_checkaux_none;
52309 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52310 +extern atomic_unchecked_t fscache_n_checkaux_update;
52311 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52312
52313 extern atomic_t fscache_n_cop_alloc_object;
52314 extern atomic_t fscache_n_cop_lookup_object;
52315 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52316 atomic_inc(stat);
52317 }
52318
52319 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52320 +{
52321 + atomic_inc_unchecked(stat);
52322 +}
52323 +
52324 static inline void fscache_stat_d(atomic_t *stat)
52325 {
52326 atomic_dec(stat);
52327 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52328
52329 #define __fscache_stat(stat) (NULL)
52330 #define fscache_stat(stat) do {} while (0)
52331 +#define fscache_stat_unchecked(stat) do {} while (0)
52332 #define fscache_stat_d(stat) do {} while (0)
52333 #endif
52334
52335 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52336 index 50d41c1..10ee117 100644
52337 --- a/fs/fscache/object.c
52338 +++ b/fs/fscache/object.c
52339 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52340 /* Invalidate an object on disk */
52341 case FSCACHE_OBJECT_INVALIDATING:
52342 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52343 - fscache_stat(&fscache_n_invalidates_run);
52344 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52345 fscache_stat(&fscache_n_cop_invalidate_object);
52346 fscache_invalidate_object(object);
52347 fscache_stat_d(&fscache_n_cop_invalidate_object);
52348 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52349 /* update the object metadata on disk */
52350 case FSCACHE_OBJECT_UPDATING:
52351 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52352 - fscache_stat(&fscache_n_updates_run);
52353 + fscache_stat_unchecked(&fscache_n_updates_run);
52354 fscache_stat(&fscache_n_cop_update_object);
52355 object->cache->ops->update_object(object);
52356 fscache_stat_d(&fscache_n_cop_update_object);
52357 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52358 spin_lock(&object->lock);
52359 object->state = FSCACHE_OBJECT_DEAD;
52360 spin_unlock(&object->lock);
52361 - fscache_stat(&fscache_n_object_dead);
52362 + fscache_stat_unchecked(&fscache_n_object_dead);
52363 goto terminal_transit;
52364
52365 /* handle the parent cache of this object being withdrawn from
52366 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52367 spin_lock(&object->lock);
52368 object->state = FSCACHE_OBJECT_DEAD;
52369 spin_unlock(&object->lock);
52370 - fscache_stat(&fscache_n_object_dead);
52371 + fscache_stat_unchecked(&fscache_n_object_dead);
52372 goto terminal_transit;
52373
52374 /* complain about the object being woken up once it is
52375 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52376 parent->cookie->def->name, cookie->def->name,
52377 object->cache->tag->name);
52378
52379 - fscache_stat(&fscache_n_object_lookups);
52380 + fscache_stat_unchecked(&fscache_n_object_lookups);
52381 fscache_stat(&fscache_n_cop_lookup_object);
52382 ret = object->cache->ops->lookup_object(object);
52383 fscache_stat_d(&fscache_n_cop_lookup_object);
52384 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52385 if (ret == -ETIMEDOUT) {
52386 /* probably stuck behind another object, so move this one to
52387 * the back of the queue */
52388 - fscache_stat(&fscache_n_object_lookups_timed_out);
52389 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52390 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52391 }
52392
52393 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52394
52395 spin_lock(&object->lock);
52396 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52397 - fscache_stat(&fscache_n_object_lookups_negative);
52398 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52399
52400 /* transit here to allow write requests to begin stacking up
52401 * and read requests to begin returning ENODATA */
52402 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52403 * result, in which case there may be data available */
52404 spin_lock(&object->lock);
52405 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52406 - fscache_stat(&fscache_n_object_lookups_positive);
52407 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52408
52409 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52410
52411 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52412 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52413 } else {
52414 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52415 - fscache_stat(&fscache_n_object_created);
52416 + fscache_stat_unchecked(&fscache_n_object_created);
52417
52418 object->state = FSCACHE_OBJECT_AVAILABLE;
52419 spin_unlock(&object->lock);
52420 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52421 fscache_enqueue_dependents(object);
52422
52423 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52424 - fscache_stat(&fscache_n_object_avail);
52425 + fscache_stat_unchecked(&fscache_n_object_avail);
52426
52427 _leave("");
52428 }
52429 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52430 enum fscache_checkaux result;
52431
52432 if (!object->cookie->def->check_aux) {
52433 - fscache_stat(&fscache_n_checkaux_none);
52434 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52435 return FSCACHE_CHECKAUX_OKAY;
52436 }
52437
52438 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52439 switch (result) {
52440 /* entry okay as is */
52441 case FSCACHE_CHECKAUX_OKAY:
52442 - fscache_stat(&fscache_n_checkaux_okay);
52443 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52444 break;
52445
52446 /* entry requires update */
52447 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52448 - fscache_stat(&fscache_n_checkaux_update);
52449 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52450 break;
52451
52452 /* entry requires deletion */
52453 case FSCACHE_CHECKAUX_OBSOLETE:
52454 - fscache_stat(&fscache_n_checkaux_obsolete);
52455 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52456 break;
52457
52458 default:
52459 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52460 index 762a9ec..2023284 100644
52461 --- a/fs/fscache/operation.c
52462 +++ b/fs/fscache/operation.c
52463 @@ -17,7 +17,7 @@
52464 #include <linux/slab.h>
52465 #include "internal.h"
52466
52467 -atomic_t fscache_op_debug_id;
52468 +atomic_unchecked_t fscache_op_debug_id;
52469 EXPORT_SYMBOL(fscache_op_debug_id);
52470
52471 /**
52472 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52473 ASSERTCMP(atomic_read(&op->usage), >, 0);
52474 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52475
52476 - fscache_stat(&fscache_n_op_enqueue);
52477 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52478 switch (op->flags & FSCACHE_OP_TYPE) {
52479 case FSCACHE_OP_ASYNC:
52480 _debug("queue async");
52481 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52482 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52483 if (op->processor)
52484 fscache_enqueue_operation(op);
52485 - fscache_stat(&fscache_n_op_run);
52486 + fscache_stat_unchecked(&fscache_n_op_run);
52487 }
52488
52489 /*
52490 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52491 if (object->n_in_progress > 0) {
52492 atomic_inc(&op->usage);
52493 list_add_tail(&op->pend_link, &object->pending_ops);
52494 - fscache_stat(&fscache_n_op_pend);
52495 + fscache_stat_unchecked(&fscache_n_op_pend);
52496 } else if (!list_empty(&object->pending_ops)) {
52497 atomic_inc(&op->usage);
52498 list_add_tail(&op->pend_link, &object->pending_ops);
52499 - fscache_stat(&fscache_n_op_pend);
52500 + fscache_stat_unchecked(&fscache_n_op_pend);
52501 fscache_start_operations(object);
52502 } else {
52503 ASSERTCMP(object->n_in_progress, ==, 0);
52504 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52505 object->n_exclusive++; /* reads and writes must wait */
52506 atomic_inc(&op->usage);
52507 list_add_tail(&op->pend_link, &object->pending_ops);
52508 - fscache_stat(&fscache_n_op_pend);
52509 + fscache_stat_unchecked(&fscache_n_op_pend);
52510 ret = 0;
52511 } else {
52512 /* If we're in any other state, there must have been an I/O
52513 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52514 if (object->n_exclusive > 0) {
52515 atomic_inc(&op->usage);
52516 list_add_tail(&op->pend_link, &object->pending_ops);
52517 - fscache_stat(&fscache_n_op_pend);
52518 + fscache_stat_unchecked(&fscache_n_op_pend);
52519 } else if (!list_empty(&object->pending_ops)) {
52520 atomic_inc(&op->usage);
52521 list_add_tail(&op->pend_link, &object->pending_ops);
52522 - fscache_stat(&fscache_n_op_pend);
52523 + fscache_stat_unchecked(&fscache_n_op_pend);
52524 fscache_start_operations(object);
52525 } else {
52526 ASSERTCMP(object->n_exclusive, ==, 0);
52527 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52528 object->n_ops++;
52529 atomic_inc(&op->usage);
52530 list_add_tail(&op->pend_link, &object->pending_ops);
52531 - fscache_stat(&fscache_n_op_pend);
52532 + fscache_stat_unchecked(&fscache_n_op_pend);
52533 ret = 0;
52534 } else if (object->state == FSCACHE_OBJECT_DYING ||
52535 object->state == FSCACHE_OBJECT_LC_DYING ||
52536 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52537 - fscache_stat(&fscache_n_op_rejected);
52538 + fscache_stat_unchecked(&fscache_n_op_rejected);
52539 op->state = FSCACHE_OP_ST_CANCELLED;
52540 ret = -ENOBUFS;
52541 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52542 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52543 ret = -EBUSY;
52544 if (op->state == FSCACHE_OP_ST_PENDING) {
52545 ASSERT(!list_empty(&op->pend_link));
52546 - fscache_stat(&fscache_n_op_cancelled);
52547 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52548 list_del_init(&op->pend_link);
52549 if (do_cancel)
52550 do_cancel(op);
52551 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52552 while (!list_empty(&object->pending_ops)) {
52553 op = list_entry(object->pending_ops.next,
52554 struct fscache_operation, pend_link);
52555 - fscache_stat(&fscache_n_op_cancelled);
52556 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52557 list_del_init(&op->pend_link);
52558
52559 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52560 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52561 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52562 op->state = FSCACHE_OP_ST_DEAD;
52563
52564 - fscache_stat(&fscache_n_op_release);
52565 + fscache_stat_unchecked(&fscache_n_op_release);
52566
52567 if (op->release) {
52568 op->release(op);
52569 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52570 * lock, and defer it otherwise */
52571 if (!spin_trylock(&object->lock)) {
52572 _debug("defer put");
52573 - fscache_stat(&fscache_n_op_deferred_release);
52574 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52575
52576 cache = object->cache;
52577 spin_lock(&cache->op_gc_list_lock);
52578 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52579
52580 _debug("GC DEFERRED REL OBJ%x OP%x",
52581 object->debug_id, op->debug_id);
52582 - fscache_stat(&fscache_n_op_gc);
52583 + fscache_stat_unchecked(&fscache_n_op_gc);
52584
52585 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52586 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52587 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52588 index ff000e5..c44ec6d 100644
52589 --- a/fs/fscache/page.c
52590 +++ b/fs/fscache/page.c
52591 @@ -61,7 +61,7 @@ try_again:
52592 val = radix_tree_lookup(&cookie->stores, page->index);
52593 if (!val) {
52594 rcu_read_unlock();
52595 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52596 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52597 __fscache_uncache_page(cookie, page);
52598 return true;
52599 }
52600 @@ -91,11 +91,11 @@ try_again:
52601 spin_unlock(&cookie->stores_lock);
52602
52603 if (xpage) {
52604 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52605 - fscache_stat(&fscache_n_store_radix_deletes);
52606 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52607 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52608 ASSERTCMP(xpage, ==, page);
52609 } else {
52610 - fscache_stat(&fscache_n_store_vmscan_gone);
52611 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52612 }
52613
52614 wake_up_bit(&cookie->flags, 0);
52615 @@ -110,11 +110,11 @@ page_busy:
52616 * sleeping on memory allocation, so we may need to impose a timeout
52617 * too. */
52618 if (!(gfp & __GFP_WAIT)) {
52619 - fscache_stat(&fscache_n_store_vmscan_busy);
52620 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52621 return false;
52622 }
52623
52624 - fscache_stat(&fscache_n_store_vmscan_wait);
52625 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52626 __fscache_wait_on_page_write(cookie, page);
52627 gfp &= ~__GFP_WAIT;
52628 goto try_again;
52629 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52630 FSCACHE_COOKIE_STORING_TAG);
52631 if (!radix_tree_tag_get(&cookie->stores, page->index,
52632 FSCACHE_COOKIE_PENDING_TAG)) {
52633 - fscache_stat(&fscache_n_store_radix_deletes);
52634 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52635 xpage = radix_tree_delete(&cookie->stores, page->index);
52636 }
52637 spin_unlock(&cookie->stores_lock);
52638 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52639
52640 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52641
52642 - fscache_stat(&fscache_n_attr_changed_calls);
52643 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52644
52645 if (fscache_object_is_active(object)) {
52646 fscache_stat(&fscache_n_cop_attr_changed);
52647 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52648
52649 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52650
52651 - fscache_stat(&fscache_n_attr_changed);
52652 + fscache_stat_unchecked(&fscache_n_attr_changed);
52653
52654 op = kzalloc(sizeof(*op), GFP_KERNEL);
52655 if (!op) {
52656 - fscache_stat(&fscache_n_attr_changed_nomem);
52657 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52658 _leave(" = -ENOMEM");
52659 return -ENOMEM;
52660 }
52661 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52662 if (fscache_submit_exclusive_op(object, op) < 0)
52663 goto nobufs;
52664 spin_unlock(&cookie->lock);
52665 - fscache_stat(&fscache_n_attr_changed_ok);
52666 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52667 fscache_put_operation(op);
52668 _leave(" = 0");
52669 return 0;
52670 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52671 nobufs:
52672 spin_unlock(&cookie->lock);
52673 kfree(op);
52674 - fscache_stat(&fscache_n_attr_changed_nobufs);
52675 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52676 _leave(" = %d", -ENOBUFS);
52677 return -ENOBUFS;
52678 }
52679 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52680 /* allocate a retrieval operation and attempt to submit it */
52681 op = kzalloc(sizeof(*op), GFP_NOIO);
52682 if (!op) {
52683 - fscache_stat(&fscache_n_retrievals_nomem);
52684 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52685 return NULL;
52686 }
52687
52688 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52689 return 0;
52690 }
52691
52692 - fscache_stat(&fscache_n_retrievals_wait);
52693 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52694
52695 jif = jiffies;
52696 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52697 fscache_wait_bit_interruptible,
52698 TASK_INTERRUPTIBLE) != 0) {
52699 - fscache_stat(&fscache_n_retrievals_intr);
52700 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52701 _leave(" = -ERESTARTSYS");
52702 return -ERESTARTSYS;
52703 }
52704 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52705 */
52706 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52707 struct fscache_retrieval *op,
52708 - atomic_t *stat_op_waits,
52709 - atomic_t *stat_object_dead)
52710 + atomic_unchecked_t *stat_op_waits,
52711 + atomic_unchecked_t *stat_object_dead)
52712 {
52713 int ret;
52714
52715 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52716 goto check_if_dead;
52717
52718 _debug(">>> WT");
52719 - fscache_stat(stat_op_waits);
52720 + fscache_stat_unchecked(stat_op_waits);
52721 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52722 fscache_wait_bit_interruptible,
52723 TASK_INTERRUPTIBLE) != 0) {
52724 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52725
52726 check_if_dead:
52727 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52728 - fscache_stat(stat_object_dead);
52729 + fscache_stat_unchecked(stat_object_dead);
52730 _leave(" = -ENOBUFS [cancelled]");
52731 return -ENOBUFS;
52732 }
52733 if (unlikely(fscache_object_is_dead(object))) {
52734 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52735 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52736 - fscache_stat(stat_object_dead);
52737 + fscache_stat_unchecked(stat_object_dead);
52738 return -ENOBUFS;
52739 }
52740 return 0;
52741 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52742
52743 _enter("%p,%p,,,", cookie, page);
52744
52745 - fscache_stat(&fscache_n_retrievals);
52746 + fscache_stat_unchecked(&fscache_n_retrievals);
52747
52748 if (hlist_empty(&cookie->backing_objects))
52749 goto nobufs;
52750 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52751 goto nobufs_unlock_dec;
52752 spin_unlock(&cookie->lock);
52753
52754 - fscache_stat(&fscache_n_retrieval_ops);
52755 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52756
52757 /* pin the netfs read context in case we need to do the actual netfs
52758 * read because we've encountered a cache read failure */
52759 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52760
52761 error:
52762 if (ret == -ENOMEM)
52763 - fscache_stat(&fscache_n_retrievals_nomem);
52764 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52765 else if (ret == -ERESTARTSYS)
52766 - fscache_stat(&fscache_n_retrievals_intr);
52767 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52768 else if (ret == -ENODATA)
52769 - fscache_stat(&fscache_n_retrievals_nodata);
52770 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52771 else if (ret < 0)
52772 - fscache_stat(&fscache_n_retrievals_nobufs);
52773 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52774 else
52775 - fscache_stat(&fscache_n_retrievals_ok);
52776 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52777
52778 fscache_put_retrieval(op);
52779 _leave(" = %d", ret);
52780 @@ -467,7 +467,7 @@ nobufs_unlock:
52781 spin_unlock(&cookie->lock);
52782 kfree(op);
52783 nobufs:
52784 - fscache_stat(&fscache_n_retrievals_nobufs);
52785 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52786 _leave(" = -ENOBUFS");
52787 return -ENOBUFS;
52788 }
52789 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52790
52791 _enter("%p,,%d,,,", cookie, *nr_pages);
52792
52793 - fscache_stat(&fscache_n_retrievals);
52794 + fscache_stat_unchecked(&fscache_n_retrievals);
52795
52796 if (hlist_empty(&cookie->backing_objects))
52797 goto nobufs;
52798 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52799 goto nobufs_unlock_dec;
52800 spin_unlock(&cookie->lock);
52801
52802 - fscache_stat(&fscache_n_retrieval_ops);
52803 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52804
52805 /* pin the netfs read context in case we need to do the actual netfs
52806 * read because we've encountered a cache read failure */
52807 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52808
52809 error:
52810 if (ret == -ENOMEM)
52811 - fscache_stat(&fscache_n_retrievals_nomem);
52812 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52813 else if (ret == -ERESTARTSYS)
52814 - fscache_stat(&fscache_n_retrievals_intr);
52815 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52816 else if (ret == -ENODATA)
52817 - fscache_stat(&fscache_n_retrievals_nodata);
52818 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52819 else if (ret < 0)
52820 - fscache_stat(&fscache_n_retrievals_nobufs);
52821 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52822 else
52823 - fscache_stat(&fscache_n_retrievals_ok);
52824 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52825
52826 fscache_put_retrieval(op);
52827 _leave(" = %d", ret);
52828 @@ -591,7 +591,7 @@ nobufs_unlock:
52829 spin_unlock(&cookie->lock);
52830 kfree(op);
52831 nobufs:
52832 - fscache_stat(&fscache_n_retrievals_nobufs);
52833 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52834 _leave(" = -ENOBUFS");
52835 return -ENOBUFS;
52836 }
52837 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52838
52839 _enter("%p,%p,,,", cookie, page);
52840
52841 - fscache_stat(&fscache_n_allocs);
52842 + fscache_stat_unchecked(&fscache_n_allocs);
52843
52844 if (hlist_empty(&cookie->backing_objects))
52845 goto nobufs;
52846 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52847 goto nobufs_unlock;
52848 spin_unlock(&cookie->lock);
52849
52850 - fscache_stat(&fscache_n_alloc_ops);
52851 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52852
52853 ret = fscache_wait_for_retrieval_activation(
52854 object, op,
52855 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52856
52857 error:
52858 if (ret == -ERESTARTSYS)
52859 - fscache_stat(&fscache_n_allocs_intr);
52860 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52861 else if (ret < 0)
52862 - fscache_stat(&fscache_n_allocs_nobufs);
52863 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52864 else
52865 - fscache_stat(&fscache_n_allocs_ok);
52866 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52867
52868 fscache_put_retrieval(op);
52869 _leave(" = %d", ret);
52870 @@ -677,7 +677,7 @@ nobufs_unlock:
52871 spin_unlock(&cookie->lock);
52872 kfree(op);
52873 nobufs:
52874 - fscache_stat(&fscache_n_allocs_nobufs);
52875 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52876 _leave(" = -ENOBUFS");
52877 return -ENOBUFS;
52878 }
52879 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52880
52881 spin_lock(&cookie->stores_lock);
52882
52883 - fscache_stat(&fscache_n_store_calls);
52884 + fscache_stat_unchecked(&fscache_n_store_calls);
52885
52886 /* find a page to store */
52887 page = NULL;
52888 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52889 page = results[0];
52890 _debug("gang %d [%lx]", n, page->index);
52891 if (page->index > op->store_limit) {
52892 - fscache_stat(&fscache_n_store_pages_over_limit);
52893 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52894 goto superseded;
52895 }
52896
52897 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52898 spin_unlock(&cookie->stores_lock);
52899 spin_unlock(&object->lock);
52900
52901 - fscache_stat(&fscache_n_store_pages);
52902 + fscache_stat_unchecked(&fscache_n_store_pages);
52903 fscache_stat(&fscache_n_cop_write_page);
52904 ret = object->cache->ops->write_page(op, page);
52905 fscache_stat_d(&fscache_n_cop_write_page);
52906 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52907 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52908 ASSERT(PageFsCache(page));
52909
52910 - fscache_stat(&fscache_n_stores);
52911 + fscache_stat_unchecked(&fscache_n_stores);
52912
52913 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52914 _leave(" = -ENOBUFS [invalidating]");
52915 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52916 spin_unlock(&cookie->stores_lock);
52917 spin_unlock(&object->lock);
52918
52919 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52920 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52921 op->store_limit = object->store_limit;
52922
52923 if (fscache_submit_op(object, &op->op) < 0)
52924 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52925
52926 spin_unlock(&cookie->lock);
52927 radix_tree_preload_end();
52928 - fscache_stat(&fscache_n_store_ops);
52929 - fscache_stat(&fscache_n_stores_ok);
52930 + fscache_stat_unchecked(&fscache_n_store_ops);
52931 + fscache_stat_unchecked(&fscache_n_stores_ok);
52932
52933 /* the work queue now carries its own ref on the object */
52934 fscache_put_operation(&op->op);
52935 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52936 return 0;
52937
52938 already_queued:
52939 - fscache_stat(&fscache_n_stores_again);
52940 + fscache_stat_unchecked(&fscache_n_stores_again);
52941 already_pending:
52942 spin_unlock(&cookie->stores_lock);
52943 spin_unlock(&object->lock);
52944 spin_unlock(&cookie->lock);
52945 radix_tree_preload_end();
52946 kfree(op);
52947 - fscache_stat(&fscache_n_stores_ok);
52948 + fscache_stat_unchecked(&fscache_n_stores_ok);
52949 _leave(" = 0");
52950 return 0;
52951
52952 @@ -959,14 +959,14 @@ nobufs:
52953 spin_unlock(&cookie->lock);
52954 radix_tree_preload_end();
52955 kfree(op);
52956 - fscache_stat(&fscache_n_stores_nobufs);
52957 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52958 _leave(" = -ENOBUFS");
52959 return -ENOBUFS;
52960
52961 nomem_free:
52962 kfree(op);
52963 nomem:
52964 - fscache_stat(&fscache_n_stores_oom);
52965 + fscache_stat_unchecked(&fscache_n_stores_oom);
52966 _leave(" = -ENOMEM");
52967 return -ENOMEM;
52968 }
52969 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52970 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52971 ASSERTCMP(page, !=, NULL);
52972
52973 - fscache_stat(&fscache_n_uncaches);
52974 + fscache_stat_unchecked(&fscache_n_uncaches);
52975
52976 /* cache withdrawal may beat us to it */
52977 if (!PageFsCache(page))
52978 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52979 struct fscache_cookie *cookie = op->op.object->cookie;
52980
52981 #ifdef CONFIG_FSCACHE_STATS
52982 - atomic_inc(&fscache_n_marks);
52983 + atomic_inc_unchecked(&fscache_n_marks);
52984 #endif
52985
52986 _debug("- mark %p{%lx}", page, page->index);
52987 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52988 index 8179e8b..5072cc7 100644
52989 --- a/fs/fscache/stats.c
52990 +++ b/fs/fscache/stats.c
52991 @@ -18,99 +18,99 @@
52992 /*
52993 * operation counters
52994 */
52995 -atomic_t fscache_n_op_pend;
52996 -atomic_t fscache_n_op_run;
52997 -atomic_t fscache_n_op_enqueue;
52998 -atomic_t fscache_n_op_requeue;
52999 -atomic_t fscache_n_op_deferred_release;
53000 -atomic_t fscache_n_op_release;
53001 -atomic_t fscache_n_op_gc;
53002 -atomic_t fscache_n_op_cancelled;
53003 -atomic_t fscache_n_op_rejected;
53004 +atomic_unchecked_t fscache_n_op_pend;
53005 +atomic_unchecked_t fscache_n_op_run;
53006 +atomic_unchecked_t fscache_n_op_enqueue;
53007 +atomic_unchecked_t fscache_n_op_requeue;
53008 +atomic_unchecked_t fscache_n_op_deferred_release;
53009 +atomic_unchecked_t fscache_n_op_release;
53010 +atomic_unchecked_t fscache_n_op_gc;
53011 +atomic_unchecked_t fscache_n_op_cancelled;
53012 +atomic_unchecked_t fscache_n_op_rejected;
53013
53014 -atomic_t fscache_n_attr_changed;
53015 -atomic_t fscache_n_attr_changed_ok;
53016 -atomic_t fscache_n_attr_changed_nobufs;
53017 -atomic_t fscache_n_attr_changed_nomem;
53018 -atomic_t fscache_n_attr_changed_calls;
53019 +atomic_unchecked_t fscache_n_attr_changed;
53020 +atomic_unchecked_t fscache_n_attr_changed_ok;
53021 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
53022 +atomic_unchecked_t fscache_n_attr_changed_nomem;
53023 +atomic_unchecked_t fscache_n_attr_changed_calls;
53024
53025 -atomic_t fscache_n_allocs;
53026 -atomic_t fscache_n_allocs_ok;
53027 -atomic_t fscache_n_allocs_wait;
53028 -atomic_t fscache_n_allocs_nobufs;
53029 -atomic_t fscache_n_allocs_intr;
53030 -atomic_t fscache_n_allocs_object_dead;
53031 -atomic_t fscache_n_alloc_ops;
53032 -atomic_t fscache_n_alloc_op_waits;
53033 +atomic_unchecked_t fscache_n_allocs;
53034 +atomic_unchecked_t fscache_n_allocs_ok;
53035 +atomic_unchecked_t fscache_n_allocs_wait;
53036 +atomic_unchecked_t fscache_n_allocs_nobufs;
53037 +atomic_unchecked_t fscache_n_allocs_intr;
53038 +atomic_unchecked_t fscache_n_allocs_object_dead;
53039 +atomic_unchecked_t fscache_n_alloc_ops;
53040 +atomic_unchecked_t fscache_n_alloc_op_waits;
53041
53042 -atomic_t fscache_n_retrievals;
53043 -atomic_t fscache_n_retrievals_ok;
53044 -atomic_t fscache_n_retrievals_wait;
53045 -atomic_t fscache_n_retrievals_nodata;
53046 -atomic_t fscache_n_retrievals_nobufs;
53047 -atomic_t fscache_n_retrievals_intr;
53048 -atomic_t fscache_n_retrievals_nomem;
53049 -atomic_t fscache_n_retrievals_object_dead;
53050 -atomic_t fscache_n_retrieval_ops;
53051 -atomic_t fscache_n_retrieval_op_waits;
53052 +atomic_unchecked_t fscache_n_retrievals;
53053 +atomic_unchecked_t fscache_n_retrievals_ok;
53054 +atomic_unchecked_t fscache_n_retrievals_wait;
53055 +atomic_unchecked_t fscache_n_retrievals_nodata;
53056 +atomic_unchecked_t fscache_n_retrievals_nobufs;
53057 +atomic_unchecked_t fscache_n_retrievals_intr;
53058 +atomic_unchecked_t fscache_n_retrievals_nomem;
53059 +atomic_unchecked_t fscache_n_retrievals_object_dead;
53060 +atomic_unchecked_t fscache_n_retrieval_ops;
53061 +atomic_unchecked_t fscache_n_retrieval_op_waits;
53062
53063 -atomic_t fscache_n_stores;
53064 -atomic_t fscache_n_stores_ok;
53065 -atomic_t fscache_n_stores_again;
53066 -atomic_t fscache_n_stores_nobufs;
53067 -atomic_t fscache_n_stores_oom;
53068 -atomic_t fscache_n_store_ops;
53069 -atomic_t fscache_n_store_calls;
53070 -atomic_t fscache_n_store_pages;
53071 -atomic_t fscache_n_store_radix_deletes;
53072 -atomic_t fscache_n_store_pages_over_limit;
53073 +atomic_unchecked_t fscache_n_stores;
53074 +atomic_unchecked_t fscache_n_stores_ok;
53075 +atomic_unchecked_t fscache_n_stores_again;
53076 +atomic_unchecked_t fscache_n_stores_nobufs;
53077 +atomic_unchecked_t fscache_n_stores_oom;
53078 +atomic_unchecked_t fscache_n_store_ops;
53079 +atomic_unchecked_t fscache_n_store_calls;
53080 +atomic_unchecked_t fscache_n_store_pages;
53081 +atomic_unchecked_t fscache_n_store_radix_deletes;
53082 +atomic_unchecked_t fscache_n_store_pages_over_limit;
53083
53084 -atomic_t fscache_n_store_vmscan_not_storing;
53085 -atomic_t fscache_n_store_vmscan_gone;
53086 -atomic_t fscache_n_store_vmscan_busy;
53087 -atomic_t fscache_n_store_vmscan_cancelled;
53088 -atomic_t fscache_n_store_vmscan_wait;
53089 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
53090 +atomic_unchecked_t fscache_n_store_vmscan_gone;
53091 +atomic_unchecked_t fscache_n_store_vmscan_busy;
53092 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
53093 +atomic_unchecked_t fscache_n_store_vmscan_wait;
53094
53095 -atomic_t fscache_n_marks;
53096 -atomic_t fscache_n_uncaches;
53097 +atomic_unchecked_t fscache_n_marks;
53098 +atomic_unchecked_t fscache_n_uncaches;
53099
53100 -atomic_t fscache_n_acquires;
53101 -atomic_t fscache_n_acquires_null;
53102 -atomic_t fscache_n_acquires_no_cache;
53103 -atomic_t fscache_n_acquires_ok;
53104 -atomic_t fscache_n_acquires_nobufs;
53105 -atomic_t fscache_n_acquires_oom;
53106 +atomic_unchecked_t fscache_n_acquires;
53107 +atomic_unchecked_t fscache_n_acquires_null;
53108 +atomic_unchecked_t fscache_n_acquires_no_cache;
53109 +atomic_unchecked_t fscache_n_acquires_ok;
53110 +atomic_unchecked_t fscache_n_acquires_nobufs;
53111 +atomic_unchecked_t fscache_n_acquires_oom;
53112
53113 -atomic_t fscache_n_invalidates;
53114 -atomic_t fscache_n_invalidates_run;
53115 +atomic_unchecked_t fscache_n_invalidates;
53116 +atomic_unchecked_t fscache_n_invalidates_run;
53117
53118 -atomic_t fscache_n_updates;
53119 -atomic_t fscache_n_updates_null;
53120 -atomic_t fscache_n_updates_run;
53121 +atomic_unchecked_t fscache_n_updates;
53122 +atomic_unchecked_t fscache_n_updates_null;
53123 +atomic_unchecked_t fscache_n_updates_run;
53124
53125 -atomic_t fscache_n_relinquishes;
53126 -atomic_t fscache_n_relinquishes_null;
53127 -atomic_t fscache_n_relinquishes_waitcrt;
53128 -atomic_t fscache_n_relinquishes_retire;
53129 +atomic_unchecked_t fscache_n_relinquishes;
53130 +atomic_unchecked_t fscache_n_relinquishes_null;
53131 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
53132 +atomic_unchecked_t fscache_n_relinquishes_retire;
53133
53134 -atomic_t fscache_n_cookie_index;
53135 -atomic_t fscache_n_cookie_data;
53136 -atomic_t fscache_n_cookie_special;
53137 +atomic_unchecked_t fscache_n_cookie_index;
53138 +atomic_unchecked_t fscache_n_cookie_data;
53139 +atomic_unchecked_t fscache_n_cookie_special;
53140
53141 -atomic_t fscache_n_object_alloc;
53142 -atomic_t fscache_n_object_no_alloc;
53143 -atomic_t fscache_n_object_lookups;
53144 -atomic_t fscache_n_object_lookups_negative;
53145 -atomic_t fscache_n_object_lookups_positive;
53146 -atomic_t fscache_n_object_lookups_timed_out;
53147 -atomic_t fscache_n_object_created;
53148 -atomic_t fscache_n_object_avail;
53149 -atomic_t fscache_n_object_dead;
53150 +atomic_unchecked_t fscache_n_object_alloc;
53151 +atomic_unchecked_t fscache_n_object_no_alloc;
53152 +atomic_unchecked_t fscache_n_object_lookups;
53153 +atomic_unchecked_t fscache_n_object_lookups_negative;
53154 +atomic_unchecked_t fscache_n_object_lookups_positive;
53155 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
53156 +atomic_unchecked_t fscache_n_object_created;
53157 +atomic_unchecked_t fscache_n_object_avail;
53158 +atomic_unchecked_t fscache_n_object_dead;
53159
53160 -atomic_t fscache_n_checkaux_none;
53161 -atomic_t fscache_n_checkaux_okay;
53162 -atomic_t fscache_n_checkaux_update;
53163 -atomic_t fscache_n_checkaux_obsolete;
53164 +atomic_unchecked_t fscache_n_checkaux_none;
53165 +atomic_unchecked_t fscache_n_checkaux_okay;
53166 +atomic_unchecked_t fscache_n_checkaux_update;
53167 +atomic_unchecked_t fscache_n_checkaux_obsolete;
53168
53169 atomic_t fscache_n_cop_alloc_object;
53170 atomic_t fscache_n_cop_lookup_object;
53171 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
53172 seq_puts(m, "FS-Cache statistics\n");
53173
53174 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
53175 - atomic_read(&fscache_n_cookie_index),
53176 - atomic_read(&fscache_n_cookie_data),
53177 - atomic_read(&fscache_n_cookie_special));
53178 + atomic_read_unchecked(&fscache_n_cookie_index),
53179 + atomic_read_unchecked(&fscache_n_cookie_data),
53180 + atomic_read_unchecked(&fscache_n_cookie_special));
53181
53182 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
53183 - atomic_read(&fscache_n_object_alloc),
53184 - atomic_read(&fscache_n_object_no_alloc),
53185 - atomic_read(&fscache_n_object_avail),
53186 - atomic_read(&fscache_n_object_dead));
53187 + atomic_read_unchecked(&fscache_n_object_alloc),
53188 + atomic_read_unchecked(&fscache_n_object_no_alloc),
53189 + atomic_read_unchecked(&fscache_n_object_avail),
53190 + atomic_read_unchecked(&fscache_n_object_dead));
53191 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
53192 - atomic_read(&fscache_n_checkaux_none),
53193 - atomic_read(&fscache_n_checkaux_okay),
53194 - atomic_read(&fscache_n_checkaux_update),
53195 - atomic_read(&fscache_n_checkaux_obsolete));
53196 + atomic_read_unchecked(&fscache_n_checkaux_none),
53197 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53198 + atomic_read_unchecked(&fscache_n_checkaux_update),
53199 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53200
53201 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53202 - atomic_read(&fscache_n_marks),
53203 - atomic_read(&fscache_n_uncaches));
53204 + atomic_read_unchecked(&fscache_n_marks),
53205 + atomic_read_unchecked(&fscache_n_uncaches));
53206
53207 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53208 " oom=%u\n",
53209 - atomic_read(&fscache_n_acquires),
53210 - atomic_read(&fscache_n_acquires_null),
53211 - atomic_read(&fscache_n_acquires_no_cache),
53212 - atomic_read(&fscache_n_acquires_ok),
53213 - atomic_read(&fscache_n_acquires_nobufs),
53214 - atomic_read(&fscache_n_acquires_oom));
53215 + atomic_read_unchecked(&fscache_n_acquires),
53216 + atomic_read_unchecked(&fscache_n_acquires_null),
53217 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53218 + atomic_read_unchecked(&fscache_n_acquires_ok),
53219 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53220 + atomic_read_unchecked(&fscache_n_acquires_oom));
53221
53222 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53223 - atomic_read(&fscache_n_object_lookups),
53224 - atomic_read(&fscache_n_object_lookups_negative),
53225 - atomic_read(&fscache_n_object_lookups_positive),
53226 - atomic_read(&fscache_n_object_created),
53227 - atomic_read(&fscache_n_object_lookups_timed_out));
53228 + atomic_read_unchecked(&fscache_n_object_lookups),
53229 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53230 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53231 + atomic_read_unchecked(&fscache_n_object_created),
53232 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53233
53234 seq_printf(m, "Invals : n=%u run=%u\n",
53235 - atomic_read(&fscache_n_invalidates),
53236 - atomic_read(&fscache_n_invalidates_run));
53237 + atomic_read_unchecked(&fscache_n_invalidates),
53238 + atomic_read_unchecked(&fscache_n_invalidates_run));
53239
53240 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53241 - atomic_read(&fscache_n_updates),
53242 - atomic_read(&fscache_n_updates_null),
53243 - atomic_read(&fscache_n_updates_run));
53244 + atomic_read_unchecked(&fscache_n_updates),
53245 + atomic_read_unchecked(&fscache_n_updates_null),
53246 + atomic_read_unchecked(&fscache_n_updates_run));
53247
53248 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53249 - atomic_read(&fscache_n_relinquishes),
53250 - atomic_read(&fscache_n_relinquishes_null),
53251 - atomic_read(&fscache_n_relinquishes_waitcrt),
53252 - atomic_read(&fscache_n_relinquishes_retire));
53253 + atomic_read_unchecked(&fscache_n_relinquishes),
53254 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53255 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53256 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53257
53258 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53259 - atomic_read(&fscache_n_attr_changed),
53260 - atomic_read(&fscache_n_attr_changed_ok),
53261 - atomic_read(&fscache_n_attr_changed_nobufs),
53262 - atomic_read(&fscache_n_attr_changed_nomem),
53263 - atomic_read(&fscache_n_attr_changed_calls));
53264 + atomic_read_unchecked(&fscache_n_attr_changed),
53265 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53266 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53267 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53268 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53269
53270 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53271 - atomic_read(&fscache_n_allocs),
53272 - atomic_read(&fscache_n_allocs_ok),
53273 - atomic_read(&fscache_n_allocs_wait),
53274 - atomic_read(&fscache_n_allocs_nobufs),
53275 - atomic_read(&fscache_n_allocs_intr));
53276 + atomic_read_unchecked(&fscache_n_allocs),
53277 + atomic_read_unchecked(&fscache_n_allocs_ok),
53278 + atomic_read_unchecked(&fscache_n_allocs_wait),
53279 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53280 + atomic_read_unchecked(&fscache_n_allocs_intr));
53281 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53282 - atomic_read(&fscache_n_alloc_ops),
53283 - atomic_read(&fscache_n_alloc_op_waits),
53284 - atomic_read(&fscache_n_allocs_object_dead));
53285 + atomic_read_unchecked(&fscache_n_alloc_ops),
53286 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53287 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53288
53289 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53290 " int=%u oom=%u\n",
53291 - atomic_read(&fscache_n_retrievals),
53292 - atomic_read(&fscache_n_retrievals_ok),
53293 - atomic_read(&fscache_n_retrievals_wait),
53294 - atomic_read(&fscache_n_retrievals_nodata),
53295 - atomic_read(&fscache_n_retrievals_nobufs),
53296 - atomic_read(&fscache_n_retrievals_intr),
53297 - atomic_read(&fscache_n_retrievals_nomem));
53298 + atomic_read_unchecked(&fscache_n_retrievals),
53299 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53300 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53301 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53302 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53303 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53304 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53305 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53306 - atomic_read(&fscache_n_retrieval_ops),
53307 - atomic_read(&fscache_n_retrieval_op_waits),
53308 - atomic_read(&fscache_n_retrievals_object_dead));
53309 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53310 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53311 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53312
53313 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53314 - atomic_read(&fscache_n_stores),
53315 - atomic_read(&fscache_n_stores_ok),
53316 - atomic_read(&fscache_n_stores_again),
53317 - atomic_read(&fscache_n_stores_nobufs),
53318 - atomic_read(&fscache_n_stores_oom));
53319 + atomic_read_unchecked(&fscache_n_stores),
53320 + atomic_read_unchecked(&fscache_n_stores_ok),
53321 + atomic_read_unchecked(&fscache_n_stores_again),
53322 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53323 + atomic_read_unchecked(&fscache_n_stores_oom));
53324 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53325 - atomic_read(&fscache_n_store_ops),
53326 - atomic_read(&fscache_n_store_calls),
53327 - atomic_read(&fscache_n_store_pages),
53328 - atomic_read(&fscache_n_store_radix_deletes),
53329 - atomic_read(&fscache_n_store_pages_over_limit));
53330 + atomic_read_unchecked(&fscache_n_store_ops),
53331 + atomic_read_unchecked(&fscache_n_store_calls),
53332 + atomic_read_unchecked(&fscache_n_store_pages),
53333 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53334 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53335
53336 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53337 - atomic_read(&fscache_n_store_vmscan_not_storing),
53338 - atomic_read(&fscache_n_store_vmscan_gone),
53339 - atomic_read(&fscache_n_store_vmscan_busy),
53340 - atomic_read(&fscache_n_store_vmscan_cancelled),
53341 - atomic_read(&fscache_n_store_vmscan_wait));
53342 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53343 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53344 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53345 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53346 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53347
53348 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53349 - atomic_read(&fscache_n_op_pend),
53350 - atomic_read(&fscache_n_op_run),
53351 - atomic_read(&fscache_n_op_enqueue),
53352 - atomic_read(&fscache_n_op_cancelled),
53353 - atomic_read(&fscache_n_op_rejected));
53354 + atomic_read_unchecked(&fscache_n_op_pend),
53355 + atomic_read_unchecked(&fscache_n_op_run),
53356 + atomic_read_unchecked(&fscache_n_op_enqueue),
53357 + atomic_read_unchecked(&fscache_n_op_cancelled),
53358 + atomic_read_unchecked(&fscache_n_op_rejected));
53359 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53360 - atomic_read(&fscache_n_op_deferred_release),
53361 - atomic_read(&fscache_n_op_release),
53362 - atomic_read(&fscache_n_op_gc));
53363 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53364 + atomic_read_unchecked(&fscache_n_op_release),
53365 + atomic_read_unchecked(&fscache_n_op_gc));
53366
53367 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53368 atomic_read(&fscache_n_cop_alloc_object),
53369 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53370 index e397b67..b0d8709 100644
53371 --- a/fs/fuse/cuse.c
53372 +++ b/fs/fuse/cuse.c
53373 @@ -593,10 +593,12 @@ static int __init cuse_init(void)
53374 INIT_LIST_HEAD(&cuse_conntbl[i]);
53375
53376 /* inherit and extend fuse_dev_operations */
53377 - cuse_channel_fops = fuse_dev_operations;
53378 - cuse_channel_fops.owner = THIS_MODULE;
53379 - cuse_channel_fops.open = cuse_channel_open;
53380 - cuse_channel_fops.release = cuse_channel_release;
53381 + pax_open_kernel();
53382 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53383 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53384 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53385 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53386 + pax_close_kernel();
53387
53388 cuse_class = class_create(THIS_MODULE, "cuse");
53389 if (IS_ERR(cuse_class))
53390 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53391 index e83351a..41e3c9c 100644
53392 --- a/fs/fuse/dev.c
53393 +++ b/fs/fuse/dev.c
53394 @@ -1236,7 +1236,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53395 ret = 0;
53396 pipe_lock(pipe);
53397
53398 - if (!pipe->readers) {
53399 + if (!atomic_read(&pipe->readers)) {
53400 send_sig(SIGPIPE, current, 0);
53401 if (!ret)
53402 ret = -EPIPE;
53403 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53404 index 315e1f8..91f890c 100644
53405 --- a/fs/fuse/dir.c
53406 +++ b/fs/fuse/dir.c
53407 @@ -1233,7 +1233,7 @@ static char *read_link(struct dentry *dentry)
53408 return link;
53409 }
53410
53411 -static void free_link(char *link)
53412 +static void free_link(const char *link)
53413 {
53414 if (!IS_ERR(link))
53415 free_page((unsigned long) link);
53416 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53417 index 2b6f569..fcb4d1f 100644
53418 --- a/fs/gfs2/inode.c
53419 +++ b/fs/gfs2/inode.c
53420 @@ -1499,7 +1499,7 @@ out:
53421
53422 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53423 {
53424 - char *s = nd_get_link(nd);
53425 + const char *s = nd_get_link(nd);
53426 if (!IS_ERR(s))
53427 kfree(s);
53428 }
53429 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53430 index 78bde32..767e906 100644
53431 --- a/fs/hugetlbfs/inode.c
53432 +++ b/fs/hugetlbfs/inode.c
53433 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53434 struct mm_struct *mm = current->mm;
53435 struct vm_area_struct *vma;
53436 struct hstate *h = hstate_file(file);
53437 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53438 struct vm_unmapped_area_info info;
53439
53440 if (len & ~huge_page_mask(h))
53441 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53442 return addr;
53443 }
53444
53445 +#ifdef CONFIG_PAX_RANDMMAP
53446 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53447 +#endif
53448 +
53449 if (addr) {
53450 addr = ALIGN(addr, huge_page_size(h));
53451 vma = find_vma(mm, addr);
53452 - if (TASK_SIZE - len >= addr &&
53453 - (!vma || addr + len <= vma->vm_start))
53454 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53455 return addr;
53456 }
53457
53458 info.flags = 0;
53459 info.length = len;
53460 info.low_limit = TASK_UNMAPPED_BASE;
53461 +
53462 +#ifdef CONFIG_PAX_RANDMMAP
53463 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53464 + info.low_limit += mm->delta_mmap;
53465 +#endif
53466 +
53467 info.high_limit = TASK_SIZE;
53468 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53469 info.align_offset = 0;
53470 @@ -897,7 +907,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53471 .kill_sb = kill_litter_super,
53472 };
53473
53474 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53475 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53476
53477 static int can_do_hugetlb_shm(void)
53478 {
53479 diff --git a/fs/inode.c b/fs/inode.c
53480 index 14084b7..6a439ea 100644
53481 --- a/fs/inode.c
53482 +++ b/fs/inode.c
53483 @@ -725,7 +725,7 @@ void prune_icache_sb(struct super_block *sb, int nr_to_scan)
53484 * inode to the back of the list so we don't spin on it.
53485 */
53486 if (!spin_trylock(&inode->i_lock)) {
53487 - list_move_tail(&inode->i_lru, &sb->s_inode_lru);
53488 + list_move(&inode->i_lru, &sb->s_inode_lru);
53489 continue;
53490 }
53491
53492 @@ -880,8 +880,8 @@ unsigned int get_next_ino(void)
53493
53494 #ifdef CONFIG_SMP
53495 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53496 - static atomic_t shared_last_ino;
53497 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53498 + static atomic_unchecked_t shared_last_ino;
53499 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53500
53501 res = next - LAST_INO_BATCH;
53502 }
53503 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53504 index 4a6cf28..d3a29d3 100644
53505 --- a/fs/jffs2/erase.c
53506 +++ b/fs/jffs2/erase.c
53507 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53508 struct jffs2_unknown_node marker = {
53509 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53510 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53511 - .totlen = cpu_to_je32(c->cleanmarker_size)
53512 + .totlen = cpu_to_je32(c->cleanmarker_size),
53513 + .hdr_crc = cpu_to_je32(0)
53514 };
53515
53516 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53517 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53518 index a6597d6..41b30ec 100644
53519 --- a/fs/jffs2/wbuf.c
53520 +++ b/fs/jffs2/wbuf.c
53521 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53522 {
53523 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53524 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53525 - .totlen = constant_cpu_to_je32(8)
53526 + .totlen = constant_cpu_to_je32(8),
53527 + .hdr_crc = constant_cpu_to_je32(0)
53528 };
53529
53530 /*
53531 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53532 index 1a543be..a4e1363 100644
53533 --- a/fs/jfs/super.c
53534 +++ b/fs/jfs/super.c
53535 @@ -225,7 +225,7 @@ static const match_table_t tokens = {
53536 static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53537 int *flag)
53538 {
53539 - void *nls_map = (void *)-1; /* -1: no change; NULL: none */
53540 + const void *nls_map = (const void *)-1; /* -1: no change; NULL: none */
53541 char *p;
53542 struct jfs_sb_info *sbi = JFS_SBI(sb);
53543
53544 @@ -253,7 +253,7 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize,
53545 /* Don't do anything ;-) */
53546 break;
53547 case Opt_iocharset:
53548 - if (nls_map && nls_map != (void *) -1)
53549 + if (nls_map && nls_map != (const void *) -1)
53550 unload_nls(nls_map);
53551 if (!strcmp(args[0].from, "none"))
53552 nls_map = NULL;
53553 @@ -855,7 +855,7 @@ static int __init init_jfs_fs(void)
53554
53555 jfs_inode_cachep =
53556 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53557 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53558 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53559 init_once);
53560 if (jfs_inode_cachep == NULL)
53561 return -ENOMEM;
53562 diff --git a/fs/libfs.c b/fs/libfs.c
53563 index 916da8c..1588998 100644
53564 --- a/fs/libfs.c
53565 +++ b/fs/libfs.c
53566 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53567
53568 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53569 struct dentry *next;
53570 + char d_name[sizeof(next->d_iname)];
53571 + const unsigned char *name;
53572 +
53573 next = list_entry(p, struct dentry, d_u.d_child);
53574 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53575 if (!simple_positive(next)) {
53576 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53577
53578 spin_unlock(&next->d_lock);
53579 spin_unlock(&dentry->d_lock);
53580 - if (filldir(dirent, next->d_name.name,
53581 + name = next->d_name.name;
53582 + if (name == next->d_iname) {
53583 + memcpy(d_name, name, next->d_name.len);
53584 + name = d_name;
53585 + }
53586 + if (filldir(dirent, name,
53587 next->d_name.len, filp->f_pos,
53588 next->d_inode->i_ino,
53589 dt_type(next->d_inode)) < 0)
53590 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53591 index 52e5120..808936e 100644
53592 --- a/fs/lockd/clntproc.c
53593 +++ b/fs/lockd/clntproc.c
53594 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53595 /*
53596 * Cookie counter for NLM requests
53597 */
53598 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53599 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53600
53601 void nlmclnt_next_cookie(struct nlm_cookie *c)
53602 {
53603 - u32 cookie = atomic_inc_return(&nlm_cookie);
53604 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53605
53606 memcpy(c->data, &cookie, 4);
53607 c->len=4;
53608 diff --git a/fs/locks.c b/fs/locks.c
53609 index a94e331..060bce3 100644
53610 --- a/fs/locks.c
53611 +++ b/fs/locks.c
53612 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53613 return;
53614
53615 if (filp->f_op && filp->f_op->flock) {
53616 - struct file_lock fl = {
53617 + struct file_lock flock = {
53618 .fl_pid = current->tgid,
53619 .fl_file = filp,
53620 .fl_flags = FL_FLOCK,
53621 .fl_type = F_UNLCK,
53622 .fl_end = OFFSET_MAX,
53623 };
53624 - filp->f_op->flock(filp, F_SETLKW, &fl);
53625 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53626 - fl.fl_ops->fl_release_private(&fl);
53627 + filp->f_op->flock(filp, F_SETLKW, &flock);
53628 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53629 + flock.fl_ops->fl_release_private(&flock);
53630 }
53631
53632 lock_flocks();
53633 diff --git a/fs/namei.c b/fs/namei.c
53634 index ec97aef..e67718d 100644
53635 --- a/fs/namei.c
53636 +++ b/fs/namei.c
53637 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53638 if (ret != -EACCES)
53639 return ret;
53640
53641 +#ifdef CONFIG_GRKERNSEC
53642 + /* we'll block if we have to log due to a denied capability use */
53643 + if (mask & MAY_NOT_BLOCK)
53644 + return -ECHILD;
53645 +#endif
53646 +
53647 if (S_ISDIR(inode->i_mode)) {
53648 /* DACs are overridable for directories */
53649 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53650 - return 0;
53651 if (!(mask & MAY_WRITE))
53652 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53653 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53654 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53655 return 0;
53656 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53657 + return 0;
53658 return -EACCES;
53659 }
53660 /*
53661 + * Searching includes executable on directories, else just read.
53662 + */
53663 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53664 + if (mask == MAY_READ)
53665 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53666 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53667 + return 0;
53668 +
53669 + /*
53670 * Read/write DACs are always overridable.
53671 * Executable DACs are overridable when there is
53672 * at least one exec bit set.
53673 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53674 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53675 return 0;
53676
53677 - /*
53678 - * Searching includes executable on directories, else just read.
53679 - */
53680 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53681 - if (mask == MAY_READ)
53682 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53683 - return 0;
53684 -
53685 return -EACCES;
53686 }
53687
53688 @@ -824,7 +832,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53689 {
53690 struct dentry *dentry = link->dentry;
53691 int error;
53692 - char *s;
53693 + const char *s;
53694
53695 BUG_ON(nd->flags & LOOKUP_RCU);
53696
53697 @@ -845,6 +853,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53698 if (error)
53699 goto out_put_nd_path;
53700
53701 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53702 + dentry->d_inode, dentry, nd->path.mnt)) {
53703 + error = -EACCES;
53704 + goto out_put_nd_path;
53705 + }
53706 +
53707 nd->last_type = LAST_BIND;
53708 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53709 error = PTR_ERR(*p);
53710 @@ -1594,6 +1608,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53711 break;
53712 res = walk_component(nd, path, &nd->last,
53713 nd->last_type, LOOKUP_FOLLOW);
53714 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53715 + res = -EACCES;
53716 put_link(nd, &link, cookie);
53717 } while (res > 0);
53718
53719 @@ -1692,7 +1708,7 @@ EXPORT_SYMBOL(full_name_hash);
53720 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53721 {
53722 unsigned long a, b, adata, bdata, mask, hash, len;
53723 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53724 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53725
53726 hash = a = 0;
53727 len = -sizeof(unsigned long);
53728 @@ -1977,6 +1993,8 @@ static int path_lookupat(int dfd, const char *name,
53729 if (err)
53730 break;
53731 err = lookup_last(nd, &path);
53732 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53733 + err = -EACCES;
53734 put_link(nd, &link, cookie);
53735 }
53736 }
53737 @@ -1984,6 +2002,13 @@ static int path_lookupat(int dfd, const char *name,
53738 if (!err)
53739 err = complete_walk(nd);
53740
53741 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53742 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53743 + path_put(&nd->path);
53744 + err = -ENOENT;
53745 + }
53746 + }
53747 +
53748 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53749 if (!nd->inode->i_op->lookup) {
53750 path_put(&nd->path);
53751 @@ -2011,8 +2036,15 @@ static int filename_lookup(int dfd, struct filename *name,
53752 retval = path_lookupat(dfd, name->name,
53753 flags | LOOKUP_REVAL, nd);
53754
53755 - if (likely(!retval))
53756 + if (likely(!retval)) {
53757 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53758 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53759 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53760 + path_put(&nd->path);
53761 + return -ENOENT;
53762 + }
53763 + }
53764 + }
53765 return retval;
53766 }
53767
53768 @@ -2390,6 +2422,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53769 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53770 return -EPERM;
53771
53772 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53773 + return -EPERM;
53774 + if (gr_handle_rawio(inode))
53775 + return -EPERM;
53776 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53777 + return -EACCES;
53778 +
53779 return 0;
53780 }
53781
53782 @@ -2611,7 +2650,7 @@ looked_up:
53783 * cleared otherwise prior to returning.
53784 */
53785 static int lookup_open(struct nameidata *nd, struct path *path,
53786 - struct file *file,
53787 + struct path *link, struct file *file,
53788 const struct open_flags *op,
53789 bool got_write, int *opened)
53790 {
53791 @@ -2646,6 +2685,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53792 /* Negative dentry, just create the file */
53793 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53794 umode_t mode = op->mode;
53795 +
53796 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53797 + error = -EACCES;
53798 + goto out_dput;
53799 + }
53800 +
53801 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53802 + error = -EACCES;
53803 + goto out_dput;
53804 + }
53805 +
53806 if (!IS_POSIXACL(dir->d_inode))
53807 mode &= ~current_umask();
53808 /*
53809 @@ -2667,6 +2717,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53810 nd->flags & LOOKUP_EXCL);
53811 if (error)
53812 goto out_dput;
53813 + else
53814 + gr_handle_create(dentry, nd->path.mnt);
53815 }
53816 out_no_open:
53817 path->dentry = dentry;
53818 @@ -2681,7 +2733,7 @@ out_dput:
53819 /*
53820 * Handle the last step of open()
53821 */
53822 -static int do_last(struct nameidata *nd, struct path *path,
53823 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53824 struct file *file, const struct open_flags *op,
53825 int *opened, struct filename *name)
53826 {
53827 @@ -2710,16 +2762,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53828 error = complete_walk(nd);
53829 if (error)
53830 return error;
53831 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53832 + error = -ENOENT;
53833 + goto out;
53834 + }
53835 audit_inode(name, nd->path.dentry, 0);
53836 if (open_flag & O_CREAT) {
53837 error = -EISDIR;
53838 goto out;
53839 }
53840 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53841 + error = -EACCES;
53842 + goto out;
53843 + }
53844 goto finish_open;
53845 case LAST_BIND:
53846 error = complete_walk(nd);
53847 if (error)
53848 return error;
53849 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53850 + error = -ENOENT;
53851 + goto out;
53852 + }
53853 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53854 + error = -EACCES;
53855 + goto out;
53856 + }
53857 audit_inode(name, dir, 0);
53858 goto finish_open;
53859 }
53860 @@ -2768,7 +2836,7 @@ retry_lookup:
53861 */
53862 }
53863 mutex_lock(&dir->d_inode->i_mutex);
53864 - error = lookup_open(nd, path, file, op, got_write, opened);
53865 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53866 mutex_unlock(&dir->d_inode->i_mutex);
53867
53868 if (error <= 0) {
53869 @@ -2792,11 +2860,28 @@ retry_lookup:
53870 goto finish_open_created;
53871 }
53872
53873 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53874 + error = -ENOENT;
53875 + goto exit_dput;
53876 + }
53877 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53878 + error = -EACCES;
53879 + goto exit_dput;
53880 + }
53881 +
53882 /*
53883 * create/update audit record if it already exists.
53884 */
53885 - if (path->dentry->d_inode)
53886 + if (path->dentry->d_inode) {
53887 + /* only check if O_CREAT is specified, all other checks need to go
53888 + into may_open */
53889 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53890 + error = -EACCES;
53891 + goto exit_dput;
53892 + }
53893 +
53894 audit_inode(name, path->dentry, 0);
53895 + }
53896
53897 /*
53898 * If atomic_open() acquired write access it is dropped now due to
53899 @@ -2837,6 +2922,11 @@ finish_lookup:
53900 }
53901 }
53902 BUG_ON(inode != path->dentry->d_inode);
53903 + /* if we're resolving a symlink to another symlink */
53904 + if (link && gr_handle_symlink_owner(link, inode)) {
53905 + error = -EACCES;
53906 + goto out;
53907 + }
53908 return 1;
53909 }
53910
53911 @@ -2846,7 +2936,6 @@ finish_lookup:
53912 save_parent.dentry = nd->path.dentry;
53913 save_parent.mnt = mntget(path->mnt);
53914 nd->path.dentry = path->dentry;
53915 -
53916 }
53917 nd->inode = inode;
53918 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53919 @@ -2855,6 +2944,16 @@ finish_lookup:
53920 path_put(&save_parent);
53921 return error;
53922 }
53923 +
53924 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53925 + error = -ENOENT;
53926 + goto out;
53927 + }
53928 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53929 + error = -EACCES;
53930 + goto out;
53931 + }
53932 +
53933 error = -EISDIR;
53934 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53935 goto out;
53936 @@ -2953,7 +3052,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53937 if (unlikely(error))
53938 goto out;
53939
53940 - error = do_last(nd, &path, file, op, &opened, pathname);
53941 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53942 while (unlikely(error > 0)) { /* trailing symlink */
53943 struct path link = path;
53944 void *cookie;
53945 @@ -2971,7 +3070,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53946 error = follow_link(&link, nd, &cookie);
53947 if (unlikely(error))
53948 break;
53949 - error = do_last(nd, &path, file, op, &opened, pathname);
53950 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53951 put_link(nd, &link, cookie);
53952 }
53953 out:
53954 @@ -3071,8 +3170,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53955 goto unlock;
53956
53957 error = -EEXIST;
53958 - if (dentry->d_inode)
53959 + if (dentry->d_inode) {
53960 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53961 + error = -ENOENT;
53962 + }
53963 goto fail;
53964 + }
53965 /*
53966 * Special case - lookup gave negative, but... we had foo/bar/
53967 * From the vfs_mknod() POV we just have a negative dentry -
53968 @@ -3124,6 +3227,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53969 }
53970 EXPORT_SYMBOL(user_path_create);
53971
53972 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53973 +{
53974 + struct filename *tmp = getname(pathname);
53975 + struct dentry *res;
53976 + if (IS_ERR(tmp))
53977 + return ERR_CAST(tmp);
53978 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53979 + if (IS_ERR(res))
53980 + putname(tmp);
53981 + else
53982 + *to = tmp;
53983 + return res;
53984 +}
53985 +
53986 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53987 {
53988 int error = may_create(dir, dentry);
53989 @@ -3186,6 +3303,17 @@ retry:
53990
53991 if (!IS_POSIXACL(path.dentry->d_inode))
53992 mode &= ~current_umask();
53993 +
53994 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53995 + error = -EPERM;
53996 + goto out;
53997 + }
53998 +
53999 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
54000 + error = -EACCES;
54001 + goto out;
54002 + }
54003 +
54004 error = security_path_mknod(&path, dentry, mode, dev);
54005 if (error)
54006 goto out;
54007 @@ -3202,6 +3330,8 @@ retry:
54008 break;
54009 }
54010 out:
54011 + if (!error)
54012 + gr_handle_create(dentry, path.mnt);
54013 done_path_create(&path, dentry);
54014 if (retry_estale(error, lookup_flags)) {
54015 lookup_flags |= LOOKUP_REVAL;
54016 @@ -3254,9 +3384,16 @@ retry:
54017
54018 if (!IS_POSIXACL(path.dentry->d_inode))
54019 mode &= ~current_umask();
54020 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
54021 + error = -EACCES;
54022 + goto out;
54023 + }
54024 error = security_path_mkdir(&path, dentry, mode);
54025 if (!error)
54026 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
54027 + if (!error)
54028 + gr_handle_create(dentry, path.mnt);
54029 +out:
54030 done_path_create(&path, dentry);
54031 if (retry_estale(error, lookup_flags)) {
54032 lookup_flags |= LOOKUP_REVAL;
54033 @@ -3337,6 +3474,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
54034 struct filename *name;
54035 struct dentry *dentry;
54036 struct nameidata nd;
54037 + ino_t saved_ino = 0;
54038 + dev_t saved_dev = 0;
54039 unsigned int lookup_flags = 0;
54040 retry:
54041 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54042 @@ -3369,10 +3508,21 @@ retry:
54043 error = -ENOENT;
54044 goto exit3;
54045 }
54046 +
54047 + saved_ino = dentry->d_inode->i_ino;
54048 + saved_dev = gr_get_dev_from_dentry(dentry);
54049 +
54050 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
54051 + error = -EACCES;
54052 + goto exit3;
54053 + }
54054 +
54055 error = security_path_rmdir(&nd.path, dentry);
54056 if (error)
54057 goto exit3;
54058 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
54059 + if (!error && (saved_dev || saved_ino))
54060 + gr_handle_delete(saved_ino, saved_dev);
54061 exit3:
54062 dput(dentry);
54063 exit2:
54064 @@ -3438,6 +3588,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
54065 struct dentry *dentry;
54066 struct nameidata nd;
54067 struct inode *inode = NULL;
54068 + ino_t saved_ino = 0;
54069 + dev_t saved_dev = 0;
54070 unsigned int lookup_flags = 0;
54071 retry:
54072 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
54073 @@ -3464,10 +3616,22 @@ retry:
54074 if (!inode)
54075 goto slashes;
54076 ihold(inode);
54077 +
54078 + if (inode->i_nlink <= 1) {
54079 + saved_ino = inode->i_ino;
54080 + saved_dev = gr_get_dev_from_dentry(dentry);
54081 + }
54082 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
54083 + error = -EACCES;
54084 + goto exit2;
54085 + }
54086 +
54087 error = security_path_unlink(&nd.path, dentry);
54088 if (error)
54089 goto exit2;
54090 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
54091 + if (!error && (saved_ino || saved_dev))
54092 + gr_handle_delete(saved_ino, saved_dev);
54093 exit2:
54094 dput(dentry);
54095 }
54096 @@ -3545,9 +3709,17 @@ retry:
54097 if (IS_ERR(dentry))
54098 goto out_putname;
54099
54100 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
54101 + error = -EACCES;
54102 + goto out;
54103 + }
54104 +
54105 error = security_path_symlink(&path, dentry, from->name);
54106 if (!error)
54107 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
54108 + if (!error)
54109 + gr_handle_create(dentry, path.mnt);
54110 +out:
54111 done_path_create(&path, dentry);
54112 if (retry_estale(error, lookup_flags)) {
54113 lookup_flags |= LOOKUP_REVAL;
54114 @@ -3621,6 +3793,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
54115 {
54116 struct dentry *new_dentry;
54117 struct path old_path, new_path;
54118 + struct filename *to = NULL;
54119 int how = 0;
54120 int error;
54121
54122 @@ -3644,7 +3817,7 @@ retry:
54123 if (error)
54124 return error;
54125
54126 - new_dentry = user_path_create(newdfd, newname, &new_path,
54127 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
54128 (how & LOOKUP_REVAL));
54129 error = PTR_ERR(new_dentry);
54130 if (IS_ERR(new_dentry))
54131 @@ -3656,11 +3829,28 @@ retry:
54132 error = may_linkat(&old_path);
54133 if (unlikely(error))
54134 goto out_dput;
54135 +
54136 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
54137 + old_path.dentry->d_inode,
54138 + old_path.dentry->d_inode->i_mode, to)) {
54139 + error = -EACCES;
54140 + goto out_dput;
54141 + }
54142 +
54143 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
54144 + old_path.dentry, old_path.mnt, to)) {
54145 + error = -EACCES;
54146 + goto out_dput;
54147 + }
54148 +
54149 error = security_path_link(old_path.dentry, &new_path, new_dentry);
54150 if (error)
54151 goto out_dput;
54152 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
54153 + if (!error)
54154 + gr_handle_create(new_dentry, new_path.mnt);
54155 out_dput:
54156 + putname(to);
54157 done_path_create(&new_path, new_dentry);
54158 if (retry_estale(error, how)) {
54159 how |= LOOKUP_REVAL;
54160 @@ -3906,12 +4096,21 @@ retry:
54161 if (new_dentry == trap)
54162 goto exit5;
54163
54164 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
54165 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
54166 + to);
54167 + if (error)
54168 + goto exit5;
54169 +
54170 error = security_path_rename(&oldnd.path, old_dentry,
54171 &newnd.path, new_dentry);
54172 if (error)
54173 goto exit5;
54174 error = vfs_rename(old_dir->d_inode, old_dentry,
54175 new_dir->d_inode, new_dentry);
54176 + if (!error)
54177 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
54178 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
54179 exit5:
54180 dput(new_dentry);
54181 exit4:
54182 @@ -3943,6 +4142,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
54183
54184 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
54185 {
54186 + char tmpbuf[64];
54187 + const char *newlink;
54188 int len;
54189
54190 len = PTR_ERR(link);
54191 @@ -3952,7 +4153,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
54192 len = strlen(link);
54193 if (len > (unsigned) buflen)
54194 len = buflen;
54195 - if (copy_to_user(buffer, link, len))
54196 +
54197 + if (len < sizeof(tmpbuf)) {
54198 + memcpy(tmpbuf, link, len);
54199 + newlink = tmpbuf;
54200 + } else
54201 + newlink = link;
54202 +
54203 + if (copy_to_user(buffer, newlink, len))
54204 len = -EFAULT;
54205 out:
54206 return len;
54207 diff --git a/fs/namespace.c b/fs/namespace.c
54208 index 5dd7709..6f64e9c 100644
54209 --- a/fs/namespace.c
54210 +++ b/fs/namespace.c
54211 @@ -1219,6 +1219,9 @@ static int do_umount(struct mount *mnt, int flags)
54212 if (!(sb->s_flags & MS_RDONLY))
54213 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54214 up_write(&sb->s_umount);
54215 +
54216 + gr_log_remount(mnt->mnt_devname, retval);
54217 +
54218 return retval;
54219 }
54220
54221 @@ -1238,6 +1241,9 @@ static int do_umount(struct mount *mnt, int flags)
54222 br_write_unlock(&vfsmount_lock);
54223 up_write(&namespace_sem);
54224 release_mounts(&umount_list);
54225 +
54226 + gr_log_unmount(mnt->mnt_devname, retval);
54227 +
54228 return retval;
54229 }
54230
54231 @@ -1713,7 +1719,7 @@ static int do_loopback(struct path *path, const char *old_name,
54232
54233 if (IS_ERR(mnt)) {
54234 err = PTR_ERR(mnt);
54235 - goto out;
54236 + goto out2;
54237 }
54238
54239 err = graft_tree(mnt, path);
54240 @@ -2294,6 +2300,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54241 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54242 MS_STRICTATIME);
54243
54244 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54245 + retval = -EPERM;
54246 + goto dput_out;
54247 + }
54248 +
54249 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54250 + retval = -EPERM;
54251 + goto dput_out;
54252 + }
54253 +
54254 if (flags & MS_REMOUNT)
54255 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54256 data_page);
54257 @@ -2308,6 +2324,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54258 dev_name, data_page);
54259 dput_out:
54260 path_put(&path);
54261 +
54262 + gr_log_mount(dev_name, dir_name, retval);
54263 +
54264 return retval;
54265 }
54266
54267 @@ -2594,6 +2613,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54268 if (error)
54269 goto out2;
54270
54271 + if (gr_handle_chroot_pivot()) {
54272 + error = -EPERM;
54273 + goto out2;
54274 + }
54275 +
54276 get_fs_root(current->fs, &root);
54277 error = lock_mount(&old);
54278 if (error)
54279 @@ -2842,7 +2866,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54280 !nsown_capable(CAP_SYS_ADMIN))
54281 return -EPERM;
54282
54283 - if (fs->users != 1)
54284 + if (atomic_read(&fs->users) != 1)
54285 return -EINVAL;
54286
54287 get_mnt_ns(mnt_ns);
54288 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54289 index 59461c9..b17c57e 100644
54290 --- a/fs/nfs/callback_xdr.c
54291 +++ b/fs/nfs/callback_xdr.c
54292 @@ -51,7 +51,7 @@ struct callback_op {
54293 callback_decode_arg_t decode_args;
54294 callback_encode_res_t encode_res;
54295 long res_maxsize;
54296 -};
54297 +} __do_const;
54298
54299 static struct callback_op callback_ops[];
54300
54301 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54302 index ebeb94c..ff35337 100644
54303 --- a/fs/nfs/inode.c
54304 +++ b/fs/nfs/inode.c
54305 @@ -1042,16 +1042,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54306 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54307 }
54308
54309 -static atomic_long_t nfs_attr_generation_counter;
54310 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54311
54312 static unsigned long nfs_read_attr_generation_counter(void)
54313 {
54314 - return atomic_long_read(&nfs_attr_generation_counter);
54315 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54316 }
54317
54318 unsigned long nfs_inc_attr_generation_counter(void)
54319 {
54320 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54321 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54322 }
54323
54324 void nfs_fattr_init(struct nfs_fattr *fattr)
54325 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54326 index 9d1c5db..1e13db8 100644
54327 --- a/fs/nfsd/nfs4proc.c
54328 +++ b/fs/nfsd/nfs4proc.c
54329 @@ -1097,7 +1097,7 @@ struct nfsd4_operation {
54330 nfsd4op_rsize op_rsize_bop;
54331 stateid_getter op_get_currentstateid;
54332 stateid_setter op_set_currentstateid;
54333 -};
54334 +} __do_const;
54335
54336 static struct nfsd4_operation nfsd4_ops[];
54337
54338 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54339 index d1dd710..32ac0e8 100644
54340 --- a/fs/nfsd/nfs4xdr.c
54341 +++ b/fs/nfsd/nfs4xdr.c
54342 @@ -1456,7 +1456,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54343
54344 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54345
54346 -static nfsd4_dec nfsd4_dec_ops[] = {
54347 +static const nfsd4_dec nfsd4_dec_ops[] = {
54348 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54349 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54350 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54351 @@ -1496,7 +1496,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54352 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54353 };
54354
54355 -static nfsd4_dec nfsd41_dec_ops[] = {
54356 +static const nfsd4_dec nfsd41_dec_ops[] = {
54357 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54358 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54359 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54360 @@ -1558,7 +1558,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54361 };
54362
54363 struct nfsd4_minorversion_ops {
54364 - nfsd4_dec *decoders;
54365 + const nfsd4_dec *decoders;
54366 int nops;
54367 };
54368
54369 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54370 index 69c6413..c0408d2 100644
54371 --- a/fs/nfsd/vfs.c
54372 +++ b/fs/nfsd/vfs.c
54373 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54374 } else {
54375 oldfs = get_fs();
54376 set_fs(KERNEL_DS);
54377 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54378 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54379 set_fs(oldfs);
54380 }
54381
54382 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54383
54384 /* Write the data. */
54385 oldfs = get_fs(); set_fs(KERNEL_DS);
54386 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54387 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54388 set_fs(oldfs);
54389 if (host_err < 0)
54390 goto out_nfserr;
54391 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54392 */
54393
54394 oldfs = get_fs(); set_fs(KERNEL_DS);
54395 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54396 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54397 set_fs(oldfs);
54398
54399 if (host_err < 0)
54400 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54401 index fea6bd5..8ee9d81 100644
54402 --- a/fs/nls/nls_base.c
54403 +++ b/fs/nls/nls_base.c
54404 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54405
54406 int register_nls(struct nls_table * nls)
54407 {
54408 - struct nls_table ** tmp = &tables;
54409 + struct nls_table *tmp = tables;
54410
54411 if (nls->next)
54412 return -EBUSY;
54413
54414 spin_lock(&nls_lock);
54415 - while (*tmp) {
54416 - if (nls == *tmp) {
54417 + while (tmp) {
54418 + if (nls == tmp) {
54419 spin_unlock(&nls_lock);
54420 return -EBUSY;
54421 }
54422 - tmp = &(*tmp)->next;
54423 + tmp = tmp->next;
54424 }
54425 - nls->next = tables;
54426 + pax_open_kernel();
54427 + *(struct nls_table **)&nls->next = tables;
54428 + pax_close_kernel();
54429 tables = nls;
54430 spin_unlock(&nls_lock);
54431 return 0;
54432 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54433
54434 int unregister_nls(struct nls_table * nls)
54435 {
54436 - struct nls_table ** tmp = &tables;
54437 + struct nls_table * const * tmp = &tables;
54438
54439 spin_lock(&nls_lock);
54440 while (*tmp) {
54441 if (nls == *tmp) {
54442 - *tmp = nls->next;
54443 + pax_open_kernel();
54444 + *(struct nls_table **)tmp = nls->next;
54445 + pax_close_kernel();
54446 spin_unlock(&nls_lock);
54447 return 0;
54448 }
54449 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54450 index 7424929..35f6be5 100644
54451 --- a/fs/nls/nls_euc-jp.c
54452 +++ b/fs/nls/nls_euc-jp.c
54453 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54454 p_nls = load_nls("cp932");
54455
54456 if (p_nls) {
54457 - table.charset2upper = p_nls->charset2upper;
54458 - table.charset2lower = p_nls->charset2lower;
54459 + pax_open_kernel();
54460 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54461 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54462 + pax_close_kernel();
54463 return register_nls(&table);
54464 }
54465
54466 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54467 index e7bc1d7..06bd4bb 100644
54468 --- a/fs/nls/nls_koi8-ru.c
54469 +++ b/fs/nls/nls_koi8-ru.c
54470 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54471 p_nls = load_nls("koi8-u");
54472
54473 if (p_nls) {
54474 - table.charset2upper = p_nls->charset2upper;
54475 - table.charset2lower = p_nls->charset2lower;
54476 + pax_open_kernel();
54477 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54478 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54479 + pax_close_kernel();
54480 return register_nls(&table);
54481 }
54482
54483 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54484 index 9ff4a5e..deb1f0f 100644
54485 --- a/fs/notify/fanotify/fanotify_user.c
54486 +++ b/fs/notify/fanotify/fanotify_user.c
54487 @@ -251,8 +251,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54488
54489 fd = fanotify_event_metadata.fd;
54490 ret = -EFAULT;
54491 - if (copy_to_user(buf, &fanotify_event_metadata,
54492 - fanotify_event_metadata.event_len))
54493 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54494 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54495 goto out_close_fd;
54496
54497 ret = prepare_for_access_response(group, event, fd);
54498 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54499 index 7b51b05..5ea5ef6 100644
54500 --- a/fs/notify/notification.c
54501 +++ b/fs/notify/notification.c
54502 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54503 * get set to 0 so it will never get 'freed'
54504 */
54505 static struct fsnotify_event *q_overflow_event;
54506 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54507 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54508
54509 /**
54510 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54511 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54512 */
54513 u32 fsnotify_get_cookie(void)
54514 {
54515 - return atomic_inc_return(&fsnotify_sync_cookie);
54516 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54517 }
54518 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54519
54520 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54521 index 99e3610..02c1068 100644
54522 --- a/fs/ntfs/dir.c
54523 +++ b/fs/ntfs/dir.c
54524 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54525 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54526 ~(s64)(ndir->itype.index.block_size - 1)));
54527 /* Bounds checks. */
54528 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54529 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54530 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54531 "inode 0x%lx or driver bug.", vdir->i_ino);
54532 goto err_out;
54533 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54534 index 5b2d4f0..c6de396 100644
54535 --- a/fs/ntfs/file.c
54536 +++ b/fs/ntfs/file.c
54537 @@ -2242,6 +2242,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54538 #endif /* NTFS_RW */
54539 };
54540
54541 -const struct file_operations ntfs_empty_file_ops = {};
54542 +const struct file_operations ntfs_empty_file_ops __read_only;
54543
54544 -const struct inode_operations ntfs_empty_inode_ops = {};
54545 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54546 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54547 index a9f78c7..ed8a381 100644
54548 --- a/fs/ocfs2/localalloc.c
54549 +++ b/fs/ocfs2/localalloc.c
54550 @@ -1279,7 +1279,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54551 goto bail;
54552 }
54553
54554 - atomic_inc(&osb->alloc_stats.moves);
54555 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54556
54557 bail:
54558 if (handle)
54559 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54560 index d355e6e..578d905 100644
54561 --- a/fs/ocfs2/ocfs2.h
54562 +++ b/fs/ocfs2/ocfs2.h
54563 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54564
54565 struct ocfs2_alloc_stats
54566 {
54567 - atomic_t moves;
54568 - atomic_t local_data;
54569 - atomic_t bitmap_data;
54570 - atomic_t bg_allocs;
54571 - atomic_t bg_extends;
54572 + atomic_unchecked_t moves;
54573 + atomic_unchecked_t local_data;
54574 + atomic_unchecked_t bitmap_data;
54575 + atomic_unchecked_t bg_allocs;
54576 + atomic_unchecked_t bg_extends;
54577 };
54578
54579 enum ocfs2_local_alloc_state
54580 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54581 index b7e74b5..19c6536 100644
54582 --- a/fs/ocfs2/suballoc.c
54583 +++ b/fs/ocfs2/suballoc.c
54584 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54585 mlog_errno(status);
54586 goto bail;
54587 }
54588 - atomic_inc(&osb->alloc_stats.bg_extends);
54589 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54590
54591 /* You should never ask for this much metadata */
54592 BUG_ON(bits_wanted >
54593 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54594 mlog_errno(status);
54595 goto bail;
54596 }
54597 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54598 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54599
54600 *suballoc_loc = res.sr_bg_blkno;
54601 *suballoc_bit_start = res.sr_bit_offset;
54602 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54603 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54604 res->sr_bits);
54605
54606 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54607 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54608
54609 BUG_ON(res->sr_bits != 1);
54610
54611 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54612 mlog_errno(status);
54613 goto bail;
54614 }
54615 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54616 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54617
54618 BUG_ON(res.sr_bits != 1);
54619
54620 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54621 cluster_start,
54622 num_clusters);
54623 if (!status)
54624 - atomic_inc(&osb->alloc_stats.local_data);
54625 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54626 } else {
54627 if (min_clusters > (osb->bitmap_cpg - 1)) {
54628 /* The only paths asking for contiguousness
54629 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54630 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54631 res.sr_bg_blkno,
54632 res.sr_bit_offset);
54633 - atomic_inc(&osb->alloc_stats.bitmap_data);
54634 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54635 *num_clusters = res.sr_bits;
54636 }
54637 }
54638 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54639 index 0e91ec2..f4b3fc6 100644
54640 --- a/fs/ocfs2/super.c
54641 +++ b/fs/ocfs2/super.c
54642 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54643 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54644 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54645 "Stats",
54646 - atomic_read(&osb->alloc_stats.bitmap_data),
54647 - atomic_read(&osb->alloc_stats.local_data),
54648 - atomic_read(&osb->alloc_stats.bg_allocs),
54649 - atomic_read(&osb->alloc_stats.moves),
54650 - atomic_read(&osb->alloc_stats.bg_extends));
54651 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54652 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54653 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54654 + atomic_read_unchecked(&osb->alloc_stats.moves),
54655 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54656
54657 out += snprintf(buf + out, len - out,
54658 "%10s => State: %u Descriptor: %llu Size: %u bits "
54659 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54660 spin_lock_init(&osb->osb_xattr_lock);
54661 ocfs2_init_steal_slots(osb);
54662
54663 - atomic_set(&osb->alloc_stats.moves, 0);
54664 - atomic_set(&osb->alloc_stats.local_data, 0);
54665 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54666 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54667 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54668 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54669 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54670 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54671 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54672 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54673
54674 /* Copy the blockcheck stats from the superblock probe */
54675 osb->osb_ecc_stats = *stats;
54676 diff --git a/fs/open.c b/fs/open.c
54677 index 9b33c0c..2ffcca2 100644
54678 --- a/fs/open.c
54679 +++ b/fs/open.c
54680 @@ -31,6 +31,8 @@
54681 #include <linux/ima.h>
54682 #include <linux/dnotify.h>
54683
54684 +#define CREATE_TRACE_POINTS
54685 +#include <trace/events/fs.h>
54686 #include "internal.h"
54687
54688 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54689 @@ -101,6 +103,8 @@ long vfs_truncate(struct path *path, loff_t length)
54690 error = locks_verify_truncate(inode, NULL, length);
54691 if (!error)
54692 error = security_path_truncate(path);
54693 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54694 + error = -EACCES;
54695 if (!error)
54696 error = do_truncate(path->dentry, length, 0, NULL);
54697
54698 @@ -178,6 +182,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54699 error = locks_verify_truncate(inode, f.file, length);
54700 if (!error)
54701 error = security_path_truncate(&f.file->f_path);
54702 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54703 + error = -EACCES;
54704 if (!error)
54705 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54706 sb_end_write(inode->i_sb);
54707 @@ -373,6 +379,9 @@ retry:
54708 if (__mnt_is_readonly(path.mnt))
54709 res = -EROFS;
54710
54711 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54712 + res = -EACCES;
54713 +
54714 out_path_release:
54715 path_put(&path);
54716 if (retry_estale(res, lookup_flags)) {
54717 @@ -404,6 +413,8 @@ retry:
54718 if (error)
54719 goto dput_and_out;
54720
54721 + gr_log_chdir(path.dentry, path.mnt);
54722 +
54723 set_fs_pwd(current->fs, &path);
54724
54725 dput_and_out:
54726 @@ -433,6 +444,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54727 goto out_putf;
54728
54729 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54730 +
54731 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54732 + error = -EPERM;
54733 +
54734 + if (!error)
54735 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54736 +
54737 if (!error)
54738 set_fs_pwd(current->fs, &f.file->f_path);
54739 out_putf:
54740 @@ -462,7 +480,13 @@ retry:
54741 if (error)
54742 goto dput_and_out;
54743
54744 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54745 + goto dput_and_out;
54746 +
54747 set_fs_root(current->fs, &path);
54748 +
54749 + gr_handle_chroot_chdir(&path);
54750 +
54751 error = 0;
54752 dput_and_out:
54753 path_put(&path);
54754 @@ -484,6 +508,16 @@ static int chmod_common(struct path *path, umode_t mode)
54755 if (error)
54756 return error;
54757 mutex_lock(&inode->i_mutex);
54758 +
54759 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54760 + error = -EACCES;
54761 + goto out_unlock;
54762 + }
54763 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54764 + error = -EACCES;
54765 + goto out_unlock;
54766 + }
54767 +
54768 error = security_path_chmod(path, mode);
54769 if (error)
54770 goto out_unlock;
54771 @@ -544,6 +578,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54772 uid = make_kuid(current_user_ns(), user);
54773 gid = make_kgid(current_user_ns(), group);
54774
54775 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54776 + return -EACCES;
54777 +
54778 newattrs.ia_valid = ATTR_CTIME;
54779 if (user != (uid_t) -1) {
54780 if (!uid_valid(uid))
54781 @@ -960,6 +997,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54782 } else {
54783 fsnotify_open(f);
54784 fd_install(fd, f);
54785 + trace_do_sys_open(tmp->name, flags, mode);
54786 }
54787 }
54788 putname(tmp);
54789 diff --git a/fs/pipe.c b/fs/pipe.c
54790 index 8e2e73f..1ef1048 100644
54791 --- a/fs/pipe.c
54792 +++ b/fs/pipe.c
54793 @@ -438,9 +438,9 @@ redo:
54794 }
54795 if (bufs) /* More to do? */
54796 continue;
54797 - if (!pipe->writers)
54798 + if (!atomic_read(&pipe->writers))
54799 break;
54800 - if (!pipe->waiting_writers) {
54801 + if (!atomic_read(&pipe->waiting_writers)) {
54802 /* syscall merging: Usually we must not sleep
54803 * if O_NONBLOCK is set, or if we got some data.
54804 * But if a writer sleeps in kernel space, then
54805 @@ -504,7 +504,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54806 mutex_lock(&inode->i_mutex);
54807 pipe = inode->i_pipe;
54808
54809 - if (!pipe->readers) {
54810 + if (!atomic_read(&pipe->readers)) {
54811 send_sig(SIGPIPE, current, 0);
54812 ret = -EPIPE;
54813 goto out;
54814 @@ -553,7 +553,7 @@ redo1:
54815 for (;;) {
54816 int bufs;
54817
54818 - if (!pipe->readers) {
54819 + if (!atomic_read(&pipe->readers)) {
54820 send_sig(SIGPIPE, current, 0);
54821 if (!ret)
54822 ret = -EPIPE;
54823 @@ -644,9 +644,9 @@ redo2:
54824 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54825 do_wakeup = 0;
54826 }
54827 - pipe->waiting_writers++;
54828 + atomic_inc(&pipe->waiting_writers);
54829 pipe_wait(pipe);
54830 - pipe->waiting_writers--;
54831 + atomic_dec(&pipe->waiting_writers);
54832 }
54833 out:
54834 mutex_unlock(&inode->i_mutex);
54835 @@ -716,7 +716,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54836 mask = 0;
54837 if (filp->f_mode & FMODE_READ) {
54838 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54839 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54840 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54841 mask |= POLLHUP;
54842 }
54843
54844 @@ -726,7 +726,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54845 * Most Unices do not set POLLERR for FIFOs but on Linux they
54846 * behave exactly like pipes for poll().
54847 */
54848 - if (!pipe->readers)
54849 + if (!atomic_read(&pipe->readers))
54850 mask |= POLLERR;
54851 }
54852
54853 @@ -740,10 +740,10 @@ pipe_release(struct inode *inode, int decr, int decw)
54854
54855 mutex_lock(&inode->i_mutex);
54856 pipe = inode->i_pipe;
54857 - pipe->readers -= decr;
54858 - pipe->writers -= decw;
54859 + atomic_sub(decr, &pipe->readers);
54860 + atomic_sub(decw, &pipe->writers);
54861
54862 - if (!pipe->readers && !pipe->writers) {
54863 + if (!atomic_read(&pipe->readers) && !atomic_read(&pipe->writers)) {
54864 free_pipe_info(inode);
54865 } else {
54866 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54867 @@ -833,7 +833,7 @@ pipe_read_open(struct inode *inode, struct file *filp)
54868
54869 if (inode->i_pipe) {
54870 ret = 0;
54871 - inode->i_pipe->readers++;
54872 + atomic_inc(&inode->i_pipe->readers);
54873 }
54874
54875 mutex_unlock(&inode->i_mutex);
54876 @@ -850,7 +850,7 @@ pipe_write_open(struct inode *inode, struct file *filp)
54877
54878 if (inode->i_pipe) {
54879 ret = 0;
54880 - inode->i_pipe->writers++;
54881 + atomic_inc(&inode->i_pipe->writers);
54882 }
54883
54884 mutex_unlock(&inode->i_mutex);
54885 @@ -871,9 +871,9 @@ pipe_rdwr_open(struct inode *inode, struct file *filp)
54886 if (inode->i_pipe) {
54887 ret = 0;
54888 if (filp->f_mode & FMODE_READ)
54889 - inode->i_pipe->readers++;
54890 + atomic_inc(&inode->i_pipe->readers);
54891 if (filp->f_mode & FMODE_WRITE)
54892 - inode->i_pipe->writers++;
54893 + atomic_inc(&inode->i_pipe->writers);
54894 }
54895
54896 mutex_unlock(&inode->i_mutex);
54897 @@ -965,7 +965,7 @@ void free_pipe_info(struct inode *inode)
54898 inode->i_pipe = NULL;
54899 }
54900
54901 -static struct vfsmount *pipe_mnt __read_mostly;
54902 +struct vfsmount *pipe_mnt __read_mostly;
54903
54904 /*
54905 * pipefs_dname() is called from d_path().
54906 @@ -995,7 +995,8 @@ static struct inode * get_pipe_inode(void)
54907 goto fail_iput;
54908 inode->i_pipe = pipe;
54909
54910 - pipe->readers = pipe->writers = 1;
54911 + atomic_set(&pipe->readers, 1);
54912 + atomic_set(&pipe->writers, 1);
54913 inode->i_fop = &rdwr_pipefifo_fops;
54914
54915 /*
54916 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54917 index 15af622..0e9f4467 100644
54918 --- a/fs/proc/Kconfig
54919 +++ b/fs/proc/Kconfig
54920 @@ -30,12 +30,12 @@ config PROC_FS
54921
54922 config PROC_KCORE
54923 bool "/proc/kcore support" if !ARM
54924 - depends on PROC_FS && MMU
54925 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54926
54927 config PROC_VMCORE
54928 bool "/proc/vmcore support"
54929 - depends on PROC_FS && CRASH_DUMP
54930 - default y
54931 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54932 + default n
54933 help
54934 Exports the dump image of crashed kernel in ELF format.
54935
54936 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54937 limited in memory.
54938
54939 config PROC_PAGE_MONITOR
54940 - default y
54941 - depends on PROC_FS && MMU
54942 + default n
54943 + depends on PROC_FS && MMU && !GRKERNSEC
54944 bool "Enable /proc page monitoring" if EXPERT
54945 help
54946 Various /proc files exist to monitor process memory utilization:
54947 diff --git a/fs/proc/array.c b/fs/proc/array.c
54948 index 6a91e6f..e54dbc14 100644
54949 --- a/fs/proc/array.c
54950 +++ b/fs/proc/array.c
54951 @@ -60,6 +60,7 @@
54952 #include <linux/tty.h>
54953 #include <linux/string.h>
54954 #include <linux/mman.h>
54955 +#include <linux/grsecurity.h>
54956 #include <linux/proc_fs.h>
54957 #include <linux/ioport.h>
54958 #include <linux/uaccess.h>
54959 @@ -362,6 +363,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54960 seq_putc(m, '\n');
54961 }
54962
54963 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54964 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54965 +{
54966 + if (p->mm)
54967 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54968 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54969 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54970 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54971 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54972 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54973 + else
54974 + seq_printf(m, "PaX:\t-----\n");
54975 +}
54976 +#endif
54977 +
54978 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54979 struct pid *pid, struct task_struct *task)
54980 {
54981 @@ -380,9 +396,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54982 task_cpus_allowed(m, task);
54983 cpuset_task_status_allowed(m, task);
54984 task_context_switch_counts(m, task);
54985 +
54986 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54987 + task_pax(m, task);
54988 +#endif
54989 +
54990 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54991 + task_grsec_rbac(m, task);
54992 +#endif
54993 +
54994 return 0;
54995 }
54996
54997 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54998 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54999 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55000 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55001 +#endif
55002 +
55003 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55004 struct pid *pid, struct task_struct *task, int whole)
55005 {
55006 @@ -404,6 +435,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55007 char tcomm[sizeof(task->comm)];
55008 unsigned long flags;
55009
55010 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55011 + if (current->exec_id != m->exec_id) {
55012 + gr_log_badprocpid("stat");
55013 + return 0;
55014 + }
55015 +#endif
55016 +
55017 state = *get_task_state(task);
55018 vsize = eip = esp = 0;
55019 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55020 @@ -475,6 +513,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55021 gtime = task->gtime;
55022 }
55023
55024 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55025 + if (PAX_RAND_FLAGS(mm)) {
55026 + eip = 0;
55027 + esp = 0;
55028 + wchan = 0;
55029 + }
55030 +#endif
55031 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55032 + wchan = 0;
55033 + eip =0;
55034 + esp =0;
55035 +#endif
55036 +
55037 /* scale priority and nice values from timeslices to -20..20 */
55038 /* to make it look like a "normal" Unix priority/nice value */
55039 priority = task_prio(task);
55040 @@ -511,9 +562,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55041 seq_put_decimal_ull(m, ' ', vsize);
55042 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55043 seq_put_decimal_ull(m, ' ', rsslim);
55044 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55045 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55046 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55047 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55048 +#else
55049 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55050 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55051 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55052 +#endif
55053 seq_put_decimal_ull(m, ' ', esp);
55054 seq_put_decimal_ull(m, ' ', eip);
55055 /* The signal information here is obsolete.
55056 @@ -535,7 +592,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55057 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55058 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55059
55060 - if (mm && permitted) {
55061 + if (mm && permitted
55062 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55063 + && !PAX_RAND_FLAGS(mm)
55064 +#endif
55065 + ) {
55066 seq_put_decimal_ull(m, ' ', mm->start_data);
55067 seq_put_decimal_ull(m, ' ', mm->end_data);
55068 seq_put_decimal_ull(m, ' ', mm->start_brk);
55069 @@ -573,8 +634,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55070 struct pid *pid, struct task_struct *task)
55071 {
55072 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55073 - struct mm_struct *mm = get_task_mm(task);
55074 + struct mm_struct *mm;
55075
55076 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55077 + if (current->exec_id != m->exec_id) {
55078 + gr_log_badprocpid("statm");
55079 + return 0;
55080 + }
55081 +#endif
55082 + mm = get_task_mm(task);
55083 if (mm) {
55084 size = task_statm(mm, &shared, &text, &data, &resident);
55085 mmput(mm);
55086 @@ -597,6 +665,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55087 return 0;
55088 }
55089
55090 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55091 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55092 +{
55093 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55094 +}
55095 +#endif
55096 +
55097 #ifdef CONFIG_CHECKPOINT_RESTORE
55098 static struct pid *
55099 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55100 diff --git a/fs/proc/base.c b/fs/proc/base.c
55101 index 9b43ff77..0fa9564 100644
55102 --- a/fs/proc/base.c
55103 +++ b/fs/proc/base.c
55104 @@ -111,6 +111,14 @@ struct pid_entry {
55105 union proc_op op;
55106 };
55107
55108 +struct getdents_callback {
55109 + struct linux_dirent __user * current_dir;
55110 + struct linux_dirent __user * previous;
55111 + struct file * file;
55112 + int count;
55113 + int error;
55114 +};
55115 +
55116 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55117 .name = (NAME), \
55118 .len = sizeof(NAME) - 1, \
55119 @@ -208,6 +216,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55120 if (!mm->arg_end)
55121 goto out_mm; /* Shh! No looking before we're done */
55122
55123 + if (gr_acl_handle_procpidmem(task))
55124 + goto out_mm;
55125 +
55126 len = mm->arg_end - mm->arg_start;
55127
55128 if (len > PAGE_SIZE)
55129 @@ -235,12 +246,28 @@ out:
55130 return res;
55131 }
55132
55133 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55134 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55135 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55136 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55137 +#endif
55138 +
55139 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55140 {
55141 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55142 int res = PTR_ERR(mm);
55143 if (mm && !IS_ERR(mm)) {
55144 unsigned int nwords = 0;
55145 +
55146 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55147 + /* allow if we're currently ptracing this task */
55148 + if (PAX_RAND_FLAGS(mm) &&
55149 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55150 + mmput(mm);
55151 + return 0;
55152 + }
55153 +#endif
55154 +
55155 do {
55156 nwords += 2;
55157 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55158 @@ -254,7 +281,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55159 }
55160
55161
55162 -#ifdef CONFIG_KALLSYMS
55163 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55164 /*
55165 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55166 * Returns the resolved symbol. If that fails, simply return the address.
55167 @@ -293,7 +320,7 @@ static void unlock_trace(struct task_struct *task)
55168 mutex_unlock(&task->signal->cred_guard_mutex);
55169 }
55170
55171 -#ifdef CONFIG_STACKTRACE
55172 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55173
55174 #define MAX_STACK_TRACE_DEPTH 64
55175
55176 @@ -485,7 +512,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55177 return count;
55178 }
55179
55180 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55181 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55182 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55183 {
55184 long nr;
55185 @@ -514,7 +541,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55186 /************************************************************************/
55187
55188 /* permission checks */
55189 -static int proc_fd_access_allowed(struct inode *inode)
55190 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55191 {
55192 struct task_struct *task;
55193 int allowed = 0;
55194 @@ -524,7 +551,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55195 */
55196 task = get_proc_task(inode);
55197 if (task) {
55198 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55199 + if (log)
55200 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55201 + else
55202 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55203 put_task_struct(task);
55204 }
55205 return allowed;
55206 @@ -555,10 +585,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55207 struct task_struct *task,
55208 int hide_pid_min)
55209 {
55210 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55211 + return false;
55212 +
55213 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55214 + rcu_read_lock();
55215 + {
55216 + const struct cred *tmpcred = current_cred();
55217 + const struct cred *cred = __task_cred(task);
55218 +
55219 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55220 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55221 + || in_group_p(grsec_proc_gid)
55222 +#endif
55223 + ) {
55224 + rcu_read_unlock();
55225 + return true;
55226 + }
55227 + }
55228 + rcu_read_unlock();
55229 +
55230 + if (!pid->hide_pid)
55231 + return false;
55232 +#endif
55233 +
55234 if (pid->hide_pid < hide_pid_min)
55235 return true;
55236 if (in_group_p(pid->pid_gid))
55237 return true;
55238 +
55239 return ptrace_may_access(task, PTRACE_MODE_READ);
55240 }
55241
55242 @@ -576,7 +631,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55243 put_task_struct(task);
55244
55245 if (!has_perms) {
55246 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55247 + {
55248 +#else
55249 if (pid->hide_pid == 2) {
55250 +#endif
55251 /*
55252 * Let's make getdents(), stat(), and open()
55253 * consistent with each other. If a process
55254 @@ -674,6 +733,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55255 if (!task)
55256 return -ESRCH;
55257
55258 + if (gr_acl_handle_procpidmem(task)) {
55259 + put_task_struct(task);
55260 + return -EPERM;
55261 + }
55262 +
55263 mm = mm_access(task, mode);
55264 put_task_struct(task);
55265
55266 @@ -689,6 +753,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55267
55268 file->private_data = mm;
55269
55270 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55271 + file->f_version = current->exec_id;
55272 +#endif
55273 +
55274 return 0;
55275 }
55276
55277 @@ -710,6 +778,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55278 ssize_t copied;
55279 char *page;
55280
55281 +#ifdef CONFIG_GRKERNSEC
55282 + if (write)
55283 + return -EPERM;
55284 +#endif
55285 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55286 + if (file->f_version != current->exec_id) {
55287 + gr_log_badprocpid("mem");
55288 + return 0;
55289 + }
55290 +#endif
55291 +
55292 if (!mm)
55293 return 0;
55294
55295 @@ -722,7 +801,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55296 goto free;
55297
55298 while (count > 0) {
55299 - int this_len = min_t(int, count, PAGE_SIZE);
55300 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55301
55302 if (write && copy_from_user(page, buf, this_len)) {
55303 copied = -EFAULT;
55304 @@ -814,6 +893,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55305 if (!mm)
55306 return 0;
55307
55308 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55309 + if (file->f_version != current->exec_id) {
55310 + gr_log_badprocpid("environ");
55311 + return 0;
55312 + }
55313 +#endif
55314 +
55315 page = (char *)__get_free_page(GFP_TEMPORARY);
55316 if (!page)
55317 return -ENOMEM;
55318 @@ -823,7 +909,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55319 goto free;
55320 while (count > 0) {
55321 size_t this_len, max_len;
55322 - int retval;
55323 + ssize_t retval;
55324
55325 if (src >= (mm->env_end - mm->env_start))
55326 break;
55327 @@ -1429,7 +1515,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55328 int error = -EACCES;
55329
55330 /* Are we allowed to snoop on the tasks file descriptors? */
55331 - if (!proc_fd_access_allowed(inode))
55332 + if (!proc_fd_access_allowed(inode, 0))
55333 goto out;
55334
55335 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55336 @@ -1473,8 +1559,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55337 struct path path;
55338
55339 /* Are we allowed to snoop on the tasks file descriptors? */
55340 - if (!proc_fd_access_allowed(inode))
55341 - goto out;
55342 + /* logging this is needed for learning on chromium to work properly,
55343 + but we don't want to flood the logs from 'ps' which does a readlink
55344 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55345 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55346 + */
55347 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55348 + if (!proc_fd_access_allowed(inode,0))
55349 + goto out;
55350 + } else {
55351 + if (!proc_fd_access_allowed(inode,1))
55352 + goto out;
55353 + }
55354
55355 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55356 if (error)
55357 @@ -1524,7 +1620,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55358 rcu_read_lock();
55359 cred = __task_cred(task);
55360 inode->i_uid = cred->euid;
55361 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55362 + inode->i_gid = grsec_proc_gid;
55363 +#else
55364 inode->i_gid = cred->egid;
55365 +#endif
55366 rcu_read_unlock();
55367 }
55368 security_task_to_inode(task, inode);
55369 @@ -1560,10 +1660,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55370 return -ENOENT;
55371 }
55372 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55373 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55374 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55375 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55376 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55377 +#endif
55378 task_dumpable(task)) {
55379 cred = __task_cred(task);
55380 stat->uid = cred->euid;
55381 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55382 + stat->gid = grsec_proc_gid;
55383 +#else
55384 stat->gid = cred->egid;
55385 +#endif
55386 }
55387 }
55388 rcu_read_unlock();
55389 @@ -1601,11 +1710,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55390
55391 if (task) {
55392 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55393 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55394 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55395 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55396 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55397 +#endif
55398 task_dumpable(task)) {
55399 rcu_read_lock();
55400 cred = __task_cred(task);
55401 inode->i_uid = cred->euid;
55402 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55403 + inode->i_gid = grsec_proc_gid;
55404 +#else
55405 inode->i_gid = cred->egid;
55406 +#endif
55407 rcu_read_unlock();
55408 } else {
55409 inode->i_uid = GLOBAL_ROOT_UID;
55410 @@ -2058,6 +2176,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55411 if (!task)
55412 goto out_no_task;
55413
55414 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55415 + goto out;
55416 +
55417 /*
55418 * Yes, it does not scale. And it should not. Don't add
55419 * new entries into /proc/<tgid>/ without very good reasons.
55420 @@ -2102,6 +2223,9 @@ static int proc_pident_readdir(struct file *filp,
55421 if (!task)
55422 goto out_no_task;
55423
55424 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55425 + goto out;
55426 +
55427 ret = 0;
55428 i = filp->f_pos;
55429 switch (i) {
55430 @@ -2515,7 +2639,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55431 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55432 #endif
55433 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55434 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55435 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55436 INF("syscall", S_IRUGO, proc_pid_syscall),
55437 #endif
55438 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55439 @@ -2540,10 +2664,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55440 #ifdef CONFIG_SECURITY
55441 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55442 #endif
55443 -#ifdef CONFIG_KALLSYMS
55444 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55445 INF("wchan", S_IRUGO, proc_pid_wchan),
55446 #endif
55447 -#ifdef CONFIG_STACKTRACE
55448 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55449 ONE("stack", S_IRUGO, proc_pid_stack),
55450 #endif
55451 #ifdef CONFIG_SCHEDSTATS
55452 @@ -2577,6 +2701,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55453 #ifdef CONFIG_HARDWALL
55454 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55455 #endif
55456 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55457 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55458 +#endif
55459 #ifdef CONFIG_USER_NS
55460 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55461 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55462 @@ -2705,7 +2832,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55463 if (!inode)
55464 goto out;
55465
55466 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55467 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55468 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55469 + inode->i_gid = grsec_proc_gid;
55470 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55471 +#else
55472 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55473 +#endif
55474 inode->i_op = &proc_tgid_base_inode_operations;
55475 inode->i_fop = &proc_tgid_base_operations;
55476 inode->i_flags|=S_IMMUTABLE;
55477 @@ -2743,7 +2877,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55478 if (!task)
55479 goto out;
55480
55481 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55482 + goto out_put_task;
55483 +
55484 result = proc_pid_instantiate(dir, dentry, task, NULL);
55485 +out_put_task:
55486 put_task_struct(task);
55487 out:
55488 return result;
55489 @@ -2806,6 +2944,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55490 static int fake_filldir(void *buf, const char *name, int namelen,
55491 loff_t offset, u64 ino, unsigned d_type)
55492 {
55493 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55494 + __buf->error = -EINVAL;
55495 return 0;
55496 }
55497
55498 @@ -2857,7 +2997,7 @@ static const struct pid_entry tid_base_stuff[] = {
55499 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55500 #endif
55501 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55502 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55503 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55504 INF("syscall", S_IRUGO, proc_pid_syscall),
55505 #endif
55506 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55507 @@ -2884,10 +3024,10 @@ static const struct pid_entry tid_base_stuff[] = {
55508 #ifdef CONFIG_SECURITY
55509 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55510 #endif
55511 -#ifdef CONFIG_KALLSYMS
55512 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55513 INF("wchan", S_IRUGO, proc_pid_wchan),
55514 #endif
55515 -#ifdef CONFIG_STACKTRACE
55516 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55517 ONE("stack", S_IRUGO, proc_pid_stack),
55518 #endif
55519 #ifdef CONFIG_SCHEDSTATS
55520 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55521 index 82676e3..5f8518a 100644
55522 --- a/fs/proc/cmdline.c
55523 +++ b/fs/proc/cmdline.c
55524 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55525
55526 static int __init proc_cmdline_init(void)
55527 {
55528 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55529 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55530 +#else
55531 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55532 +#endif
55533 return 0;
55534 }
55535 module_init(proc_cmdline_init);
55536 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55537 index b143471..bb105e5 100644
55538 --- a/fs/proc/devices.c
55539 +++ b/fs/proc/devices.c
55540 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55541
55542 static int __init proc_devices_init(void)
55543 {
55544 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55545 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55546 +#else
55547 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55548 +#endif
55549 return 0;
55550 }
55551 module_init(proc_devices_init);
55552 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55553 index d7a4a28..0201742 100644
55554 --- a/fs/proc/fd.c
55555 +++ b/fs/proc/fd.c
55556 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55557 if (!task)
55558 return -ENOENT;
55559
55560 - files = get_files_struct(task);
55561 + if (!gr_acl_handle_procpidmem(task))
55562 + files = get_files_struct(task);
55563 put_task_struct(task);
55564
55565 if (files) {
55566 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55567 */
55568 int proc_fd_permission(struct inode *inode, int mask)
55569 {
55570 + struct task_struct *task;
55571 int rv = generic_permission(inode, mask);
55572 - if (rv == 0)
55573 - return 0;
55574 +
55575 if (task_pid(current) == proc_pid(inode))
55576 rv = 0;
55577 +
55578 + task = get_proc_task(inode);
55579 + if (task == NULL)
55580 + return rv;
55581 +
55582 + if (gr_acl_handle_procpidmem(task))
55583 + rv = -EACCES;
55584 +
55585 + put_task_struct(task);
55586 +
55587 return rv;
55588 }
55589
55590 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55591 index 0ac1e1b..0497e58 100644
55592 --- a/fs/proc/inode.c
55593 +++ b/fs/proc/inode.c
55594 @@ -21,11 +21,17 @@
55595 #include <linux/seq_file.h>
55596 #include <linux/slab.h>
55597 #include <linux/mount.h>
55598 +#include <linux/grsecurity.h>
55599
55600 #include <asm/uaccess.h>
55601
55602 #include "internal.h"
55603
55604 +#ifdef CONFIG_PROC_SYSCTL
55605 +extern const struct inode_operations proc_sys_inode_operations;
55606 +extern const struct inode_operations proc_sys_dir_operations;
55607 +#endif
55608 +
55609 static void proc_evict_inode(struct inode *inode)
55610 {
55611 struct proc_dir_entry *de;
55612 @@ -53,6 +59,13 @@ static void proc_evict_inode(struct inode *inode)
55613 ns = PROC_I(inode)->ns;
55614 if (ns_ops && ns)
55615 ns_ops->put(ns);
55616 +
55617 +#ifdef CONFIG_PROC_SYSCTL
55618 + if (inode->i_op == &proc_sys_inode_operations ||
55619 + inode->i_op == &proc_sys_dir_operations)
55620 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55621 +#endif
55622 +
55623 }
55624
55625 static struct kmem_cache * proc_inode_cachep;
55626 @@ -455,7 +468,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55627 if (de->mode) {
55628 inode->i_mode = de->mode;
55629 inode->i_uid = de->uid;
55630 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55631 + inode->i_gid = grsec_proc_gid;
55632 +#else
55633 inode->i_gid = de->gid;
55634 +#endif
55635 }
55636 if (de->size)
55637 inode->i_size = de->size;
55638 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55639 index 252544c..04395b9 100644
55640 --- a/fs/proc/internal.h
55641 +++ b/fs/proc/internal.h
55642 @@ -55,6 +55,9 @@ extern int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
55643 struct pid *pid, struct task_struct *task);
55644 extern int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55645 struct pid *pid, struct task_struct *task);
55646 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55647 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55648 +#endif
55649 extern loff_t mem_lseek(struct file *file, loff_t offset, int orig);
55650
55651 extern const struct file_operations proc_tid_children_operations;
55652 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55653 index e96d4f1..8b116ed 100644
55654 --- a/fs/proc/kcore.c
55655 +++ b/fs/proc/kcore.c
55656 @@ -480,9 +480,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55657 * the addresses in the elf_phdr on our list.
55658 */
55659 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55660 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55661 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55662 + if (tsz > buflen)
55663 tsz = buflen;
55664 -
55665 +
55666 while (buflen) {
55667 struct kcore_list *m;
55668
55669 @@ -511,20 +512,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55670 kfree(elf_buf);
55671 } else {
55672 if (kern_addr_valid(start)) {
55673 - unsigned long n;
55674 + char *elf_buf;
55675 + mm_segment_t oldfs;
55676
55677 - n = copy_to_user(buffer, (char *)start, tsz);
55678 - /*
55679 - * We cannot distinguish between fault on source
55680 - * and fault on destination. When this happens
55681 - * we clear too and hope it will trigger the
55682 - * EFAULT again.
55683 - */
55684 - if (n) {
55685 - if (clear_user(buffer + tsz - n,
55686 - n))
55687 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55688 + if (!elf_buf)
55689 + return -ENOMEM;
55690 + oldfs = get_fs();
55691 + set_fs(KERNEL_DS);
55692 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55693 + set_fs(oldfs);
55694 + if (copy_to_user(buffer, elf_buf, tsz)) {
55695 + kfree(elf_buf);
55696 return -EFAULT;
55697 + }
55698 }
55699 + set_fs(oldfs);
55700 + kfree(elf_buf);
55701 } else {
55702 if (clear_user(buffer, tsz))
55703 return -EFAULT;
55704 @@ -544,6 +548,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55705
55706 static int open_kcore(struct inode *inode, struct file *filp)
55707 {
55708 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55709 + return -EPERM;
55710 +#endif
55711 if (!capable(CAP_SYS_RAWIO))
55712 return -EPERM;
55713 if (kcore_need_update)
55714 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55715 index 80e4645..53e5fcf 100644
55716 --- a/fs/proc/meminfo.c
55717 +++ b/fs/proc/meminfo.c
55718 @@ -158,7 +158,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55719 vmi.used >> 10,
55720 vmi.largest_chunk >> 10
55721 #ifdef CONFIG_MEMORY_FAILURE
55722 - ,atomic_long_read(&mce_bad_pages) << (PAGE_SHIFT - 10)
55723 + ,atomic_long_read_unchecked(&mce_bad_pages) << (PAGE_SHIFT - 10)
55724 #endif
55725 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55726 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55727 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55728 index b1822dd..df622cb 100644
55729 --- a/fs/proc/nommu.c
55730 +++ b/fs/proc/nommu.c
55731 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55732 if (len < 1)
55733 len = 1;
55734 seq_printf(m, "%*c", len, ' ');
55735 - seq_path(m, &file->f_path, "");
55736 + seq_path(m, &file->f_path, "\n\\");
55737 }
55738
55739 seq_putc(m, '\n');
55740 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55741 index fe72cd0..21b52ff 100644
55742 --- a/fs/proc/proc_net.c
55743 +++ b/fs/proc/proc_net.c
55744 @@ -23,6 +23,7 @@
55745 #include <linux/nsproxy.h>
55746 #include <net/net_namespace.h>
55747 #include <linux/seq_file.h>
55748 +#include <linux/grsecurity.h>
55749
55750 #include "internal.h"
55751
55752 @@ -105,6 +106,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55753 struct task_struct *task;
55754 struct nsproxy *ns;
55755 struct net *net = NULL;
55756 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55757 + const struct cred *cred = current_cred();
55758 +#endif
55759 +
55760 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55761 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55762 + return net;
55763 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55764 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55765 + return net;
55766 +#endif
55767
55768 rcu_read_lock();
55769 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55770 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55771 index 1827d88..43b0279 100644
55772 --- a/fs/proc/proc_sysctl.c
55773 +++ b/fs/proc/proc_sysctl.c
55774 @@ -12,11 +12,15 @@
55775 #include <linux/module.h>
55776 #include "internal.h"
55777
55778 +extern int gr_handle_chroot_sysctl(const int op);
55779 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55780 + const int op);
55781 +
55782 static const struct dentry_operations proc_sys_dentry_operations;
55783 static const struct file_operations proc_sys_file_operations;
55784 -static const struct inode_operations proc_sys_inode_operations;
55785 +const struct inode_operations proc_sys_inode_operations;
55786 static const struct file_operations proc_sys_dir_file_operations;
55787 -static const struct inode_operations proc_sys_dir_operations;
55788 +const struct inode_operations proc_sys_dir_operations;
55789
55790 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55791 {
55792 @@ -466,6 +470,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55793
55794 err = NULL;
55795 d_set_d_op(dentry, &proc_sys_dentry_operations);
55796 +
55797 + gr_handle_proc_create(dentry, inode);
55798 +
55799 d_add(dentry, inode);
55800
55801 out:
55802 @@ -481,6 +488,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55803 struct inode *inode = filp->f_path.dentry->d_inode;
55804 struct ctl_table_header *head = grab_header(inode);
55805 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55806 + int op = write ? MAY_WRITE : MAY_READ;
55807 ssize_t error;
55808 size_t res;
55809
55810 @@ -492,7 +500,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55811 * and won't be until we finish.
55812 */
55813 error = -EPERM;
55814 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55815 + if (sysctl_perm(head, table, op))
55816 goto out;
55817
55818 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55819 @@ -500,6 +508,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55820 if (!table->proc_handler)
55821 goto out;
55822
55823 +#ifdef CONFIG_GRKERNSEC
55824 + error = -EPERM;
55825 + if (gr_handle_chroot_sysctl(op))
55826 + goto out;
55827 + dget(filp->f_path.dentry);
55828 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55829 + dput(filp->f_path.dentry);
55830 + goto out;
55831 + }
55832 + dput(filp->f_path.dentry);
55833 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55834 + goto out;
55835 + if (write && !capable(CAP_SYS_ADMIN))
55836 + goto out;
55837 +#endif
55838 +
55839 /* careful: calling conventions are nasty here */
55840 res = count;
55841 error = table->proc_handler(table, write, buf, &res, ppos);
55842 @@ -597,6 +621,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55843 return -ENOMEM;
55844 } else {
55845 d_set_d_op(child, &proc_sys_dentry_operations);
55846 +
55847 + gr_handle_proc_create(child, inode);
55848 +
55849 d_add(child, inode);
55850 }
55851 } else {
55852 @@ -640,6 +667,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55853 if ((*pos)++ < file->f_pos)
55854 return 0;
55855
55856 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55857 + return 0;
55858 +
55859 if (unlikely(S_ISLNK(table->mode)))
55860 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55861 else
55862 @@ -750,6 +780,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55863 if (IS_ERR(head))
55864 return PTR_ERR(head);
55865
55866 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55867 + return -ENOENT;
55868 +
55869 generic_fillattr(inode, stat);
55870 if (table)
55871 stat->mode = (stat->mode & S_IFMT) | table->mode;
55872 @@ -772,13 +805,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55873 .llseek = generic_file_llseek,
55874 };
55875
55876 -static const struct inode_operations proc_sys_inode_operations = {
55877 +const struct inode_operations proc_sys_inode_operations = {
55878 .permission = proc_sys_permission,
55879 .setattr = proc_sys_setattr,
55880 .getattr = proc_sys_getattr,
55881 };
55882
55883 -static const struct inode_operations proc_sys_dir_operations = {
55884 +const struct inode_operations proc_sys_dir_operations = {
55885 .lookup = proc_sys_lookup,
55886 .permission = proc_sys_permission,
55887 .setattr = proc_sys_setattr,
55888 @@ -854,7 +887,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55889 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55890 const char *name, int namelen)
55891 {
55892 - struct ctl_table *table;
55893 + ctl_table_no_const *table;
55894 struct ctl_dir *new;
55895 struct ctl_node *node;
55896 char *new_name;
55897 @@ -866,7 +899,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55898 return NULL;
55899
55900 node = (struct ctl_node *)(new + 1);
55901 - table = (struct ctl_table *)(node + 1);
55902 + table = (ctl_table_no_const *)(node + 1);
55903 new_name = (char *)(table + 2);
55904 memcpy(new_name, name, namelen);
55905 new_name[namelen] = '\0';
55906 @@ -1035,7 +1068,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55907 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55908 struct ctl_table_root *link_root)
55909 {
55910 - struct ctl_table *link_table, *entry, *link;
55911 + ctl_table_no_const *link_table, *link;
55912 + struct ctl_table *entry;
55913 struct ctl_table_header *links;
55914 struct ctl_node *node;
55915 char *link_name;
55916 @@ -1058,7 +1092,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55917 return NULL;
55918
55919 node = (struct ctl_node *)(links + 1);
55920 - link_table = (struct ctl_table *)(node + nr_entries);
55921 + link_table = (ctl_table_no_const *)(node + nr_entries);
55922 link_name = (char *)&link_table[nr_entries + 1];
55923
55924 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55925 @@ -1306,8 +1340,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55926 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55927 struct ctl_table *table)
55928 {
55929 - struct ctl_table *ctl_table_arg = NULL;
55930 - struct ctl_table *entry, *files;
55931 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55932 + struct ctl_table *entry;
55933 int nr_files = 0;
55934 int nr_dirs = 0;
55935 int err = -ENOMEM;
55936 @@ -1319,10 +1353,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55937 nr_files++;
55938 }
55939
55940 - files = table;
55941 /* If there are mixed files and directories we need a new table */
55942 if (nr_dirs && nr_files) {
55943 - struct ctl_table *new;
55944 + ctl_table_no_const *new;
55945 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55946 GFP_KERNEL);
55947 if (!files)
55948 @@ -1340,7 +1373,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55949 /* Register everything except a directory full of subdirectories */
55950 if (nr_files || !nr_dirs) {
55951 struct ctl_table_header *header;
55952 - header = __register_sysctl_table(set, path, files);
55953 + header = __register_sysctl_table(set, path, files ? files : table);
55954 if (!header) {
55955 kfree(ctl_table_arg);
55956 goto out;
55957 diff --git a/fs/proc/root.c b/fs/proc/root.c
55958 index 9c7fab1..ed1c8e0 100644
55959 --- a/fs/proc/root.c
55960 +++ b/fs/proc/root.c
55961 @@ -180,7 +180,15 @@ void __init proc_root_init(void)
55962 #ifdef CONFIG_PROC_DEVICETREE
55963 proc_device_tree_init();
55964 #endif
55965 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55966 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55967 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55968 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55969 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55970 +#endif
55971 +#else
55972 proc_mkdir("bus", NULL);
55973 +#endif
55974 proc_sys_init();
55975 }
55976
55977 diff --git a/fs/proc/self.c b/fs/proc/self.c
55978 index aa5cc3b..c91a5d0 100644
55979 --- a/fs/proc/self.c
55980 +++ b/fs/proc/self.c
55981 @@ -37,7 +37,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55982 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55983 void *cookie)
55984 {
55985 - char *s = nd_get_link(nd);
55986 + const char *s = nd_get_link(nd);
55987 if (!IS_ERR(s))
55988 kfree(s);
55989 }
55990 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55991 index ca5ce7f..02c1cf0 100644
55992 --- a/fs/proc/task_mmu.c
55993 +++ b/fs/proc/task_mmu.c
55994 @@ -11,12 +11,19 @@
55995 #include <linux/rmap.h>
55996 #include <linux/swap.h>
55997 #include <linux/swapops.h>
55998 +#include <linux/grsecurity.h>
55999
56000 #include <asm/elf.h>
56001 #include <asm/uaccess.h>
56002 #include <asm/tlbflush.h>
56003 #include "internal.h"
56004
56005 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56006 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
56007 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
56008 + _mm->pax_flags & MF_PAX_SEGMEXEC))
56009 +#endif
56010 +
56011 void task_mem(struct seq_file *m, struct mm_struct *mm)
56012 {
56013 unsigned long data, text, lib, swap;
56014 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56015 "VmExe:\t%8lu kB\n"
56016 "VmLib:\t%8lu kB\n"
56017 "VmPTE:\t%8lu kB\n"
56018 - "VmSwap:\t%8lu kB\n",
56019 - hiwater_vm << (PAGE_SHIFT-10),
56020 + "VmSwap:\t%8lu kB\n"
56021 +
56022 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56023 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56024 +#endif
56025 +
56026 + ,hiwater_vm << (PAGE_SHIFT-10),
56027 total_vm << (PAGE_SHIFT-10),
56028 mm->locked_vm << (PAGE_SHIFT-10),
56029 mm->pinned_vm << (PAGE_SHIFT-10),
56030 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56031 data << (PAGE_SHIFT-10),
56032 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56033 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56034 - swap << (PAGE_SHIFT-10));
56035 + swap << (PAGE_SHIFT-10)
56036 +
56037 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56038 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56039 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56040 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56041 +#else
56042 + , mm->context.user_cs_base
56043 + , mm->context.user_cs_limit
56044 +#endif
56045 +#endif
56046 +
56047 + );
56048 }
56049
56050 unsigned long task_vsize(struct mm_struct *mm)
56051 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56052 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56053 }
56054
56055 - /* We don't show the stack guard page in /proc/maps */
56056 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56057 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56058 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56059 +#else
56060 start = vma->vm_start;
56061 - if (stack_guard_page_start(vma, start))
56062 - start += PAGE_SIZE;
56063 end = vma->vm_end;
56064 - if (stack_guard_page_end(vma, end))
56065 - end -= PAGE_SIZE;
56066 +#endif
56067
56068 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56069 start,
56070 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56071 flags & VM_WRITE ? 'w' : '-',
56072 flags & VM_EXEC ? 'x' : '-',
56073 flags & VM_MAYSHARE ? 's' : 'p',
56074 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56075 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56076 +#else
56077 pgoff,
56078 +#endif
56079 MAJOR(dev), MINOR(dev), ino, &len);
56080
56081 /*
56082 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56083 */
56084 if (file) {
56085 pad_len_spaces(m, len);
56086 - seq_path(m, &file->f_path, "\n");
56087 + seq_path(m, &file->f_path, "\n\\");
56088 goto done;
56089 }
56090
56091 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56092 * Thread stack in /proc/PID/task/TID/maps or
56093 * the main process stack.
56094 */
56095 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56096 - vma->vm_end >= mm->start_stack)) {
56097 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56098 + (vma->vm_start <= mm->start_stack &&
56099 + vma->vm_end >= mm->start_stack)) {
56100 name = "[stack]";
56101 } else {
56102 /* Thread stack in /proc/PID/maps */
56103 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56104 struct proc_maps_private *priv = m->private;
56105 struct task_struct *task = priv->task;
56106
56107 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56108 + if (current->exec_id != m->exec_id) {
56109 + gr_log_badprocpid("maps");
56110 + return 0;
56111 + }
56112 +#endif
56113 +
56114 show_map_vma(m, vma, is_pid);
56115
56116 if (m->count < m->size) /* vma is copied successfully */
56117 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56118 .private = &mss,
56119 };
56120
56121 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56122 + if (current->exec_id != m->exec_id) {
56123 + gr_log_badprocpid("smaps");
56124 + return 0;
56125 + }
56126 +#endif
56127 memset(&mss, 0, sizeof mss);
56128 - mss.vma = vma;
56129 - /* mmap_sem is held in m_start */
56130 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56131 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56132 -
56133 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56134 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56135 +#endif
56136 + mss.vma = vma;
56137 + /* mmap_sem is held in m_start */
56138 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56139 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56140 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56141 + }
56142 +#endif
56143 show_map_vma(m, vma, is_pid);
56144
56145 seq_printf(m,
56146 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56147 "KernelPageSize: %8lu kB\n"
56148 "MMUPageSize: %8lu kB\n"
56149 "Locked: %8lu kB\n",
56150 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56151 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56152 +#else
56153 (vma->vm_end - vma->vm_start) >> 10,
56154 +#endif
56155 mss.resident >> 10,
56156 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56157 mss.shared_clean >> 10,
56158 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56159 int n;
56160 char buffer[50];
56161
56162 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56163 + if (current->exec_id != m->exec_id) {
56164 + gr_log_badprocpid("numa_maps");
56165 + return 0;
56166 + }
56167 +#endif
56168 +
56169 if (!mm)
56170 return 0;
56171
56172 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56173 mpol_to_str(buffer, sizeof(buffer), pol);
56174 mpol_cond_put(pol);
56175
56176 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56177 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56178 +#else
56179 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56180 +#endif
56181
56182 if (file) {
56183 seq_printf(m, " file=");
56184 - seq_path(m, &file->f_path, "\n\t= ");
56185 + seq_path(m, &file->f_path, "\n\t\\= ");
56186 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56187 seq_printf(m, " heap");
56188 } else {
56189 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56190 index 1ccfa53..0848f95 100644
56191 --- a/fs/proc/task_nommu.c
56192 +++ b/fs/proc/task_nommu.c
56193 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56194 else
56195 bytes += kobjsize(mm);
56196
56197 - if (current->fs && current->fs->users > 1)
56198 + if (current->fs && atomic_read(&current->fs->users) > 1)
56199 sbytes += kobjsize(current->fs);
56200 else
56201 bytes += kobjsize(current->fs);
56202 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56203
56204 if (file) {
56205 pad_len_spaces(m, len);
56206 - seq_path(m, &file->f_path, "");
56207 + seq_path(m, &file->f_path, "\n\\");
56208 } else if (mm) {
56209 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56210
56211 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56212 index b00fcc9..e0c6381 100644
56213 --- a/fs/qnx6/qnx6.h
56214 +++ b/fs/qnx6/qnx6.h
56215 @@ -74,7 +74,7 @@ enum {
56216 BYTESEX_BE,
56217 };
56218
56219 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56220 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56221 {
56222 if (sbi->s_bytesex == BYTESEX_LE)
56223 return le64_to_cpu((__force __le64)n);
56224 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56225 return (__force __fs64)cpu_to_be64(n);
56226 }
56227
56228 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56229 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56230 {
56231 if (sbi->s_bytesex == BYTESEX_LE)
56232 return le32_to_cpu((__force __le32)n);
56233 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56234 index 16e8abb..2dcf914 100644
56235 --- a/fs/quota/netlink.c
56236 +++ b/fs/quota/netlink.c
56237 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56238 void quota_send_warning(struct kqid qid, dev_t dev,
56239 const char warntype)
56240 {
56241 - static atomic_t seq;
56242 + static atomic_unchecked_t seq;
56243 struct sk_buff *skb;
56244 void *msg_head;
56245 int ret;
56246 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56247 "VFS: Not enough memory to send quota warning.\n");
56248 return;
56249 }
56250 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56251 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56252 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56253 if (!msg_head) {
56254 printk(KERN_ERR
56255 diff --git a/fs/readdir.c b/fs/readdir.c
56256 index 5e69ef5..e5d9099 100644
56257 --- a/fs/readdir.c
56258 +++ b/fs/readdir.c
56259 @@ -17,6 +17,7 @@
56260 #include <linux/security.h>
56261 #include <linux/syscalls.h>
56262 #include <linux/unistd.h>
56263 +#include <linux/namei.h>
56264
56265 #include <asm/uaccess.h>
56266
56267 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56268
56269 struct readdir_callback {
56270 struct old_linux_dirent __user * dirent;
56271 + struct file * file;
56272 int result;
56273 };
56274
56275 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56276 buf->result = -EOVERFLOW;
56277 return -EOVERFLOW;
56278 }
56279 +
56280 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56281 + return 0;
56282 +
56283 buf->result++;
56284 dirent = buf->dirent;
56285 if (!access_ok(VERIFY_WRITE, dirent,
56286 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56287
56288 buf.result = 0;
56289 buf.dirent = dirent;
56290 + buf.file = f.file;
56291
56292 error = vfs_readdir(f.file, fillonedir, &buf);
56293 if (buf.result)
56294 @@ -139,6 +146,7 @@ struct linux_dirent {
56295 struct getdents_callback {
56296 struct linux_dirent __user * current_dir;
56297 struct linux_dirent __user * previous;
56298 + struct file * file;
56299 int count;
56300 int error;
56301 };
56302 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56303 buf->error = -EOVERFLOW;
56304 return -EOVERFLOW;
56305 }
56306 +
56307 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56308 + return 0;
56309 +
56310 dirent = buf->previous;
56311 if (dirent) {
56312 if (__put_user(offset, &dirent->d_off))
56313 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56314 buf.previous = NULL;
56315 buf.count = count;
56316 buf.error = 0;
56317 + buf.file = f.file;
56318
56319 error = vfs_readdir(f.file, filldir, &buf);
56320 if (error >= 0)
56321 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56322 struct getdents_callback64 {
56323 struct linux_dirent64 __user * current_dir;
56324 struct linux_dirent64 __user * previous;
56325 + struct file *file;
56326 int count;
56327 int error;
56328 };
56329 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56330 buf->error = -EINVAL; /* only used if we fail.. */
56331 if (reclen > buf->count)
56332 return -EINVAL;
56333 +
56334 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56335 + return 0;
56336 +
56337 dirent = buf->previous;
56338 if (dirent) {
56339 if (__put_user(offset, &dirent->d_off))
56340 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56341
56342 buf.current_dir = dirent;
56343 buf.previous = NULL;
56344 + buf.file = f.file;
56345 buf.count = count;
56346 buf.error = 0;
56347
56348 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56349 error = buf.error;
56350 lastdirent = buf.previous;
56351 if (lastdirent) {
56352 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56353 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56354 if (__put_user(d_off, &lastdirent->d_off))
56355 error = -EFAULT;
56356 else
56357 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56358 index 2b7882b..1c5ef48 100644
56359 --- a/fs/reiserfs/do_balan.c
56360 +++ b/fs/reiserfs/do_balan.c
56361 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56362 return;
56363 }
56364
56365 - atomic_inc(&(fs_generation(tb->tb_sb)));
56366 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56367 do_balance_starts(tb);
56368
56369 /* balance leaf returns 0 except if combining L R and S into
56370 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56371 index e60e870..f40ac16 100644
56372 --- a/fs/reiserfs/procfs.c
56373 +++ b/fs/reiserfs/procfs.c
56374 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56375 "SMALL_TAILS " : "NO_TAILS ",
56376 replay_only(sb) ? "REPLAY_ONLY " : "",
56377 convert_reiserfs(sb) ? "CONV " : "",
56378 - atomic_read(&r->s_generation_counter),
56379 + atomic_read_unchecked(&r->s_generation_counter),
56380 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56381 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56382 SF(s_good_search_by_key_reada), SF(s_bmaps),
56383 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56384 index 157e474..65a6114 100644
56385 --- a/fs/reiserfs/reiserfs.h
56386 +++ b/fs/reiserfs/reiserfs.h
56387 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56388 /* Comment? -Hans */
56389 wait_queue_head_t s_wait;
56390 /* To be obsoleted soon by per buffer seals.. -Hans */
56391 - atomic_t s_generation_counter; // increased by one every time the
56392 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56393 // tree gets re-balanced
56394 unsigned long s_properties; /* File system properties. Currently holds
56395 on-disk FS format */
56396 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56397 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56398
56399 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56400 -#define get_generation(s) atomic_read (&fs_generation(s))
56401 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56402 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56403 #define __fs_changed(gen,s) (gen != get_generation (s))
56404 #define fs_changed(gen,s) \
56405 diff --git a/fs/select.c b/fs/select.c
56406 index 2ef72d9..f213b17 100644
56407 --- a/fs/select.c
56408 +++ b/fs/select.c
56409 @@ -20,6 +20,7 @@
56410 #include <linux/export.h>
56411 #include <linux/slab.h>
56412 #include <linux/poll.h>
56413 +#include <linux/security.h>
56414 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56415 #include <linux/file.h>
56416 #include <linux/fdtable.h>
56417 @@ -826,6 +827,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56418 struct poll_list *walk = head;
56419 unsigned long todo = nfds;
56420
56421 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56422 if (nfds > rlimit(RLIMIT_NOFILE))
56423 return -EINVAL;
56424
56425 diff --git a/fs/seq_file.c b/fs/seq_file.c
56426 index f2bc3df..239d4f6 100644
56427 --- a/fs/seq_file.c
56428 +++ b/fs/seq_file.c
56429 @@ -10,6 +10,7 @@
56430 #include <linux/seq_file.h>
56431 #include <linux/slab.h>
56432 #include <linux/cred.h>
56433 +#include <linux/sched.h>
56434
56435 #include <asm/uaccess.h>
56436 #include <asm/page.h>
56437 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56438 #ifdef CONFIG_USER_NS
56439 p->user_ns = file->f_cred->user_ns;
56440 #endif
56441 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56442 + p->exec_id = current->exec_id;
56443 +#endif
56444
56445 /*
56446 * Wrappers around seq_open(e.g. swaps_open) need to be
56447 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56448 return 0;
56449 }
56450 if (!m->buf) {
56451 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56452 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56453 if (!m->buf)
56454 return -ENOMEM;
56455 }
56456 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56457 Eoverflow:
56458 m->op->stop(m, p);
56459 kfree(m->buf);
56460 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56461 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56462 return !m->buf ? -ENOMEM : -EAGAIN;
56463 }
56464
56465 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56466
56467 /* grab buffer if we didn't have one */
56468 if (!m->buf) {
56469 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56470 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56471 if (!m->buf)
56472 goto Enomem;
56473 }
56474 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56475 goto Fill;
56476 m->op->stop(m, p);
56477 kfree(m->buf);
56478 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56479 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56480 if (!m->buf)
56481 goto Enomem;
56482 m->count = 0;
56483 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56484 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56485 void *data)
56486 {
56487 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56488 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56489 int res = -ENOMEM;
56490
56491 if (op) {
56492 diff --git a/fs/splice.c b/fs/splice.c
56493 index 6909d89..5b2e8f9 100644
56494 --- a/fs/splice.c
56495 +++ b/fs/splice.c
56496 @@ -194,7 +194,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56497 pipe_lock(pipe);
56498
56499 for (;;) {
56500 - if (!pipe->readers) {
56501 + if (!atomic_read(&pipe->readers)) {
56502 send_sig(SIGPIPE, current, 0);
56503 if (!ret)
56504 ret = -EPIPE;
56505 @@ -248,9 +248,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56506 do_wakeup = 0;
56507 }
56508
56509 - pipe->waiting_writers++;
56510 + atomic_inc(&pipe->waiting_writers);
56511 pipe_wait(pipe);
56512 - pipe->waiting_writers--;
56513 + atomic_dec(&pipe->waiting_writers);
56514 }
56515
56516 pipe_unlock(pipe);
56517 @@ -563,7 +563,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56518 old_fs = get_fs();
56519 set_fs(get_ds());
56520 /* The cast to a user pointer is valid due to the set_fs() */
56521 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56522 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56523 set_fs(old_fs);
56524
56525 return res;
56526 @@ -578,7 +578,7 @@ static ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56527 old_fs = get_fs();
56528 set_fs(get_ds());
56529 /* The cast to a user pointer is valid due to the set_fs() */
56530 - res = vfs_write(file, (const char __user *)buf, count, &pos);
56531 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56532 set_fs(old_fs);
56533
56534 return res;
56535 @@ -630,7 +630,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56536 goto err;
56537
56538 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56539 - vec[i].iov_base = (void __user *) page_address(page);
56540 + vec[i].iov_base = (void __force_user *) page_address(page);
56541 vec[i].iov_len = this_len;
56542 spd.pages[i] = page;
56543 spd.nr_pages++;
56544 @@ -851,10 +851,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56545 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56546 {
56547 while (!pipe->nrbufs) {
56548 - if (!pipe->writers)
56549 + if (!atomic_read(&pipe->writers))
56550 return 0;
56551
56552 - if (!pipe->waiting_writers && sd->num_spliced)
56553 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56554 return 0;
56555
56556 if (sd->flags & SPLICE_F_NONBLOCK)
56557 @@ -1189,7 +1189,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56558 * out of the pipe right after the splice_to_pipe(). So set
56559 * PIPE_READERS appropriately.
56560 */
56561 - pipe->readers = 1;
56562 + atomic_set(&pipe->readers, 1);
56563
56564 current->splice_pipe = pipe;
56565 }
56566 @@ -1738,9 +1738,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56567 ret = -ERESTARTSYS;
56568 break;
56569 }
56570 - if (!pipe->writers)
56571 + if (!atomic_read(&pipe->writers))
56572 break;
56573 - if (!pipe->waiting_writers) {
56574 + if (!atomic_read(&pipe->waiting_writers)) {
56575 if (flags & SPLICE_F_NONBLOCK) {
56576 ret = -EAGAIN;
56577 break;
56578 @@ -1772,7 +1772,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56579 pipe_lock(pipe);
56580
56581 while (pipe->nrbufs >= pipe->buffers) {
56582 - if (!pipe->readers) {
56583 + if (!atomic_read(&pipe->readers)) {
56584 send_sig(SIGPIPE, current, 0);
56585 ret = -EPIPE;
56586 break;
56587 @@ -1785,9 +1785,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56588 ret = -ERESTARTSYS;
56589 break;
56590 }
56591 - pipe->waiting_writers++;
56592 + atomic_inc(&pipe->waiting_writers);
56593 pipe_wait(pipe);
56594 - pipe->waiting_writers--;
56595 + atomic_dec(&pipe->waiting_writers);
56596 }
56597
56598 pipe_unlock(pipe);
56599 @@ -1823,14 +1823,14 @@ retry:
56600 pipe_double_lock(ipipe, opipe);
56601
56602 do {
56603 - if (!opipe->readers) {
56604 + if (!atomic_read(&opipe->readers)) {
56605 send_sig(SIGPIPE, current, 0);
56606 if (!ret)
56607 ret = -EPIPE;
56608 break;
56609 }
56610
56611 - if (!ipipe->nrbufs && !ipipe->writers)
56612 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56613 break;
56614
56615 /*
56616 @@ -1927,7 +1927,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56617 pipe_double_lock(ipipe, opipe);
56618
56619 do {
56620 - if (!opipe->readers) {
56621 + if (!atomic_read(&opipe->readers)) {
56622 send_sig(SIGPIPE, current, 0);
56623 if (!ret)
56624 ret = -EPIPE;
56625 @@ -1972,7 +1972,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56626 * return EAGAIN if we have the potential of some data in the
56627 * future, otherwise just return 0
56628 */
56629 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56630 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56631 ret = -EAGAIN;
56632
56633 pipe_unlock(ipipe);
56634 diff --git a/fs/stat.c b/fs/stat.c
56635 index 14f4545..9b7f55b 100644
56636 --- a/fs/stat.c
56637 +++ b/fs/stat.c
56638 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56639 stat->gid = inode->i_gid;
56640 stat->rdev = inode->i_rdev;
56641 stat->size = i_size_read(inode);
56642 - stat->atime = inode->i_atime;
56643 - stat->mtime = inode->i_mtime;
56644 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56645 + stat->atime = inode->i_ctime;
56646 + stat->mtime = inode->i_ctime;
56647 + } else {
56648 + stat->atime = inode->i_atime;
56649 + stat->mtime = inode->i_mtime;
56650 + }
56651 stat->ctime = inode->i_ctime;
56652 stat->blksize = (1 << inode->i_blkbits);
56653 stat->blocks = inode->i_blocks;
56654 @@ -46,8 +51,14 @@ int vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
56655 if (retval)
56656 return retval;
56657
56658 - if (inode->i_op->getattr)
56659 - return inode->i_op->getattr(mnt, dentry, stat);
56660 + if (inode->i_op->getattr) {
56661 + retval = inode->i_op->getattr(mnt, dentry, stat);
56662 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56663 + stat->atime = stat->ctime;
56664 + stat->mtime = stat->ctime;
56665 + }
56666 + return retval;
56667 + }
56668
56669 generic_fillattr(inode, stat);
56670 return 0;
56671 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56672 index 614b2b5..4d321e6 100644
56673 --- a/fs/sysfs/bin.c
56674 +++ b/fs/sysfs/bin.c
56675 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56676 return ret;
56677 }
56678
56679 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56680 - void *buf, int len, int write)
56681 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56682 + void *buf, size_t len, int write)
56683 {
56684 struct file *file = vma->vm_file;
56685 struct bin_buffer *bb = file->private_data;
56686 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56687 - int ret;
56688 + ssize_t ret;
56689
56690 if (!bb->vm_ops)
56691 return -EINVAL;
56692 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56693 index 1f8c823..ed57cfe 100644
56694 --- a/fs/sysfs/dir.c
56695 +++ b/fs/sysfs/dir.c
56696 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56697 *
56698 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56699 */
56700 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56701 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56702 {
56703 unsigned long hash = init_name_hash();
56704 unsigned int len = strlen(name);
56705 @@ -685,6 +685,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56706 struct sysfs_dirent *sd;
56707 int rc;
56708
56709 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56710 + const char *parent_name = parent_sd->s_name;
56711 +
56712 + mode = S_IFDIR | S_IRWXU;
56713 +
56714 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56715 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56716 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56717 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56718 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56719 +#endif
56720 +
56721 /* allocate */
56722 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56723 if (!sd)
56724 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56725 index 602f56d..6853db8 100644
56726 --- a/fs/sysfs/file.c
56727 +++ b/fs/sysfs/file.c
56728 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56729
56730 struct sysfs_open_dirent {
56731 atomic_t refcnt;
56732 - atomic_t event;
56733 + atomic_unchecked_t event;
56734 wait_queue_head_t poll;
56735 struct list_head buffers; /* goes through sysfs_buffer.list */
56736 };
56737 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56738 if (!sysfs_get_active(attr_sd))
56739 return -ENODEV;
56740
56741 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56742 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56743 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56744
56745 sysfs_put_active(attr_sd);
56746 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56747 return -ENOMEM;
56748
56749 atomic_set(&new_od->refcnt, 0);
56750 - atomic_set(&new_od->event, 1);
56751 + atomic_set_unchecked(&new_od->event, 1);
56752 init_waitqueue_head(&new_od->poll);
56753 INIT_LIST_HEAD(&new_od->buffers);
56754 goto retry;
56755 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56756
56757 sysfs_put_active(attr_sd);
56758
56759 - if (buffer->event != atomic_read(&od->event))
56760 + if (buffer->event != atomic_read_unchecked(&od->event))
56761 goto trigger;
56762
56763 return DEFAULT_POLLMASK;
56764 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56765
56766 od = sd->s_attr.open;
56767 if (od) {
56768 - atomic_inc(&od->event);
56769 + atomic_inc_unchecked(&od->event);
56770 wake_up_interruptible(&od->poll);
56771 }
56772
56773 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56774 index 3c9eb56..9dea5be 100644
56775 --- a/fs/sysfs/symlink.c
56776 +++ b/fs/sysfs/symlink.c
56777 @@ -286,7 +286,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56778
56779 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56780 {
56781 - char *page = nd_get_link(nd);
56782 + const char *page = nd_get_link(nd);
56783 if (!IS_ERR(page))
56784 free_page((unsigned long)page);
56785 }
56786 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56787 index 69d4889..a810bd4 100644
56788 --- a/fs/sysv/sysv.h
56789 +++ b/fs/sysv/sysv.h
56790 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56791 #endif
56792 }
56793
56794 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56795 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56796 {
56797 if (sbi->s_bytesex == BYTESEX_PDP)
56798 return PDP_swab((__force __u32)n);
56799 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56800 index e18b988..f1d4ad0f 100644
56801 --- a/fs/ubifs/io.c
56802 +++ b/fs/ubifs/io.c
56803 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56804 return err;
56805 }
56806
56807 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56808 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56809 {
56810 int err;
56811
56812 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56813 index c175b4d..8f36a16 100644
56814 --- a/fs/udf/misc.c
56815 +++ b/fs/udf/misc.c
56816 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56817
56818 u8 udf_tag_checksum(const struct tag *t)
56819 {
56820 - u8 *data = (u8 *)t;
56821 + const u8 *data = (const u8 *)t;
56822 u8 checksum = 0;
56823 int i;
56824 for (i = 0; i < sizeof(struct tag); ++i)
56825 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56826 index 8d974c4..b82f6ec 100644
56827 --- a/fs/ufs/swab.h
56828 +++ b/fs/ufs/swab.h
56829 @@ -22,7 +22,7 @@ enum {
56830 BYTESEX_BE
56831 };
56832
56833 -static inline u64
56834 +static inline u64 __intentional_overflow(-1)
56835 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56836 {
56837 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56838 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56839 return (__force __fs64)cpu_to_be64(n);
56840 }
56841
56842 -static inline u32
56843 +static inline u32 __intentional_overflow(-1)
56844 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56845 {
56846 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56847 diff --git a/fs/utimes.c b/fs/utimes.c
56848 index f4fb7ec..3fe03c0 100644
56849 --- a/fs/utimes.c
56850 +++ b/fs/utimes.c
56851 @@ -1,6 +1,7 @@
56852 #include <linux/compiler.h>
56853 #include <linux/file.h>
56854 #include <linux/fs.h>
56855 +#include <linux/security.h>
56856 #include <linux/linkage.h>
56857 #include <linux/mount.h>
56858 #include <linux/namei.h>
56859 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56860 goto mnt_drop_write_and_out;
56861 }
56862 }
56863 +
56864 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56865 + error = -EACCES;
56866 + goto mnt_drop_write_and_out;
56867 + }
56868 +
56869 mutex_lock(&inode->i_mutex);
56870 error = notify_change(path->dentry, &newattrs);
56871 mutex_unlock(&inode->i_mutex);
56872 diff --git a/fs/xattr.c b/fs/xattr.c
56873 index 3377dff..4feded6 100644
56874 --- a/fs/xattr.c
56875 +++ b/fs/xattr.c
56876 @@ -319,7 +319,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56877 * Extended attribute SET operations
56878 */
56879 static long
56880 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56881 +setxattr(struct path *path, const char __user *name, const void __user *value,
56882 size_t size, int flags)
56883 {
56884 int error;
56885 @@ -355,7 +355,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56886 posix_acl_fix_xattr_from_user(kvalue, size);
56887 }
56888
56889 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56890 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56891 + error = -EACCES;
56892 + goto out;
56893 + }
56894 +
56895 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56896 out:
56897 if (vvalue)
56898 vfree(vvalue);
56899 @@ -377,7 +382,7 @@ retry:
56900 return error;
56901 error = mnt_want_write(path.mnt);
56902 if (!error) {
56903 - error = setxattr(path.dentry, name, value, size, flags);
56904 + error = setxattr(&path, name, value, size, flags);
56905 mnt_drop_write(path.mnt);
56906 }
56907 path_put(&path);
56908 @@ -401,7 +406,7 @@ retry:
56909 return error;
56910 error = mnt_want_write(path.mnt);
56911 if (!error) {
56912 - error = setxattr(path.dentry, name, value, size, flags);
56913 + error = setxattr(&path, name, value, size, flags);
56914 mnt_drop_write(path.mnt);
56915 }
56916 path_put(&path);
56917 @@ -416,16 +421,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56918 const void __user *,value, size_t, size, int, flags)
56919 {
56920 struct fd f = fdget(fd);
56921 - struct dentry *dentry;
56922 int error = -EBADF;
56923
56924 if (!f.file)
56925 return error;
56926 - dentry = f.file->f_path.dentry;
56927 - audit_inode(NULL, dentry, 0);
56928 + audit_inode(NULL, f.file->f_path.dentry, 0);
56929 error = mnt_want_write_file(f.file);
56930 if (!error) {
56931 - error = setxattr(dentry, name, value, size, flags);
56932 + error = setxattr(&f.file->f_path, name, value, size, flags);
56933 mnt_drop_write_file(f.file);
56934 }
56935 fdput(f);
56936 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
56937 index 9fbea87..6b19972 100644
56938 --- a/fs/xattr_acl.c
56939 +++ b/fs/xattr_acl.c
56940 @@ -76,8 +76,8 @@ struct posix_acl *
56941 posix_acl_from_xattr(struct user_namespace *user_ns,
56942 const void *value, size_t size)
56943 {
56944 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
56945 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
56946 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
56947 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
56948 int count;
56949 struct posix_acl *acl;
56950 struct posix_acl_entry *acl_e;
56951 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
56952 index 572a858..12a9b0d 100644
56953 --- a/fs/xfs/xfs_bmap.c
56954 +++ b/fs/xfs/xfs_bmap.c
56955 @@ -192,7 +192,7 @@ xfs_bmap_validate_ret(
56956 int nmap,
56957 int ret_nmap);
56958 #else
56959 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
56960 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do {} while (0)
56961 #endif /* DEBUG */
56962
56963 STATIC int
56964 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
56965 index 1b9fc3e..e1bdde0 100644
56966 --- a/fs/xfs/xfs_dir2_sf.c
56967 +++ b/fs/xfs/xfs_dir2_sf.c
56968 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
56969 }
56970
56971 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
56972 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56973 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
56974 + char name[sfep->namelen];
56975 + memcpy(name, sfep->name, sfep->namelen);
56976 + if (filldir(dirent, name, sfep->namelen,
56977 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
56978 + *offset = off & 0x7fffffff;
56979 + return 0;
56980 + }
56981 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
56982 off & 0x7fffffff, ino, DT_UNKNOWN)) {
56983 *offset = off & 0x7fffffff;
56984 return 0;
56985 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
56986 index c1c3ef8..0952438 100644
56987 --- a/fs/xfs/xfs_ioctl.c
56988 +++ b/fs/xfs/xfs_ioctl.c
56989 @@ -127,7 +127,7 @@ xfs_find_handle(
56990 }
56991
56992 error = -EFAULT;
56993 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
56994 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
56995 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
56996 goto out_put;
56997
56998 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
56999 index d82efaa..0904a8e 100644
57000 --- a/fs/xfs/xfs_iops.c
57001 +++ b/fs/xfs/xfs_iops.c
57002 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57003 struct nameidata *nd,
57004 void *p)
57005 {
57006 - char *s = nd_get_link(nd);
57007 + const char *s = nd_get_link(nd);
57008
57009 if (!IS_ERR(s))
57010 kfree(s);
57011 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57012 new file mode 100644
57013 index 0000000..92247e4
57014 --- /dev/null
57015 +++ b/grsecurity/Kconfig
57016 @@ -0,0 +1,1021 @@
57017 +#
57018 +# grecurity configuration
57019 +#
57020 +menu "Memory Protections"
57021 +depends on GRKERNSEC
57022 +
57023 +config GRKERNSEC_KMEM
57024 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57025 + default y if GRKERNSEC_CONFIG_AUTO
57026 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57027 + help
57028 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57029 + be written to or read from to modify or leak the contents of the running
57030 + kernel. /dev/port will also not be allowed to be opened and support
57031 + for /dev/cpu/*/msr will be removed. If you have module
57032 + support disabled, enabling this will close up five ways that are
57033 + currently used to insert malicious code into the running kernel.
57034 +
57035 + Even with all these features enabled, we still highly recommend that
57036 + you use the RBAC system, as it is still possible for an attacker to
57037 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57038 +
57039 + If you are not using XFree86, you may be able to stop this additional
57040 + case by enabling the 'Disable privileged I/O' option. Though nothing
57041 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57042 + but only to video memory, which is the only writing we allow in this
57043 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57044 + not be allowed to mprotect it with PROT_WRITE later.
57045 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57046 + from working.
57047 +
57048 + It is highly recommended that you say Y here if you meet all the
57049 + conditions above.
57050 +
57051 +config GRKERNSEC_VM86
57052 + bool "Restrict VM86 mode"
57053 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57054 + depends on X86_32
57055 +
57056 + help
57057 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57058 + make use of a special execution mode on 32bit x86 processors called
57059 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57060 + video cards and will still work with this option enabled. The purpose
57061 + of the option is to prevent exploitation of emulation errors in
57062 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57063 + Nearly all users should be able to enable this option.
57064 +
57065 +config GRKERNSEC_IO
57066 + bool "Disable privileged I/O"
57067 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57068 + depends on X86
57069 + select RTC_CLASS
57070 + select RTC_INTF_DEV
57071 + select RTC_DRV_CMOS
57072 +
57073 + help
57074 + If you say Y here, all ioperm and iopl calls will return an error.
57075 + Ioperm and iopl can be used to modify the running kernel.
57076 + Unfortunately, some programs need this access to operate properly,
57077 + the most notable of which are XFree86 and hwclock. hwclock can be
57078 + remedied by having RTC support in the kernel, so real-time
57079 + clock support is enabled if this option is enabled, to ensure
57080 + that hwclock operates correctly. XFree86 still will not
57081 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57082 + IF YOU USE XFree86. If you use XFree86 and you still want to
57083 + protect your kernel against modification, use the RBAC system.
57084 +
57085 +config GRKERNSEC_JIT_HARDEN
57086 + bool "Harden BPF JIT against spray attacks"
57087 + default y if GRKERNSEC_CONFIG_AUTO
57088 + depends on BPF_JIT
57089 + help
57090 + If you say Y here, the native code generated by the kernel's Berkeley
57091 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57092 + attacks that attempt to fit attacker-beneficial instructions in
57093 + 32bit immediate fields of JIT-generated native instructions. The
57094 + attacker will generally aim to cause an unintended instruction sequence
57095 + of JIT-generated native code to execute by jumping into the middle of
57096 + a generated instruction. This feature effectively randomizes the 32bit
57097 + immediate constants present in the generated code to thwart such attacks.
57098 +
57099 + If you're using KERNEXEC, it's recommended that you enable this option
57100 + to supplement the hardening of the kernel.
57101 +
57102 +config GRKERNSEC_RAND_THREADSTACK
57103 + bool "Insert random gaps between thread stacks"
57104 + default y if GRKERNSEC_CONFIG_AUTO
57105 + depends on PAX_RANDMMAP && !PPC
57106 + help
57107 + If you say Y here, a random-sized gap will be enforced between allocated
57108 + thread stacks. Glibc's NPTL and other threading libraries that
57109 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57110 + The implementation currently provides 8 bits of entropy for the gap.
57111 +
57112 + Many distributions do not compile threaded remote services with the
57113 + -fstack-check argument to GCC, causing the variable-sized stack-based
57114 + allocator, alloca(), to not probe the stack on allocation. This
57115 + permits an unbounded alloca() to skip over any guard page and potentially
57116 + modify another thread's stack reliably. An enforced random gap
57117 + reduces the reliability of such an attack and increases the chance
57118 + that such a read/write to another thread's stack instead lands in
57119 + an unmapped area, causing a crash and triggering grsecurity's
57120 + anti-bruteforcing logic.
57121 +
57122 +config GRKERNSEC_PROC_MEMMAP
57123 + bool "Harden ASLR against information leaks and entropy reduction"
57124 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57125 + depends on PAX_NOEXEC || PAX_ASLR
57126 + help
57127 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57128 + give no information about the addresses of its mappings if
57129 + PaX features that rely on random addresses are enabled on the task.
57130 + In addition to sanitizing this information and disabling other
57131 + dangerous sources of information, this option causes reads of sensitive
57132 + /proc/<pid> entries where the file descriptor was opened in a different
57133 + task than the one performing the read. Such attempts are logged.
57134 + This option also limits argv/env strings for suid/sgid binaries
57135 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57136 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57137 + binaries to prevent alternative mmap layouts from being abused.
57138 +
57139 + If you use PaX it is essential that you say Y here as it closes up
57140 + several holes that make full ASLR useless locally.
57141 +
57142 +config GRKERNSEC_BRUTE
57143 + bool "Deter exploit bruteforcing"
57144 + default y if GRKERNSEC_CONFIG_AUTO
57145 + help
57146 + If you say Y here, attempts to bruteforce exploits against forking
57147 + daemons such as apache or sshd, as well as against suid/sgid binaries
57148 + will be deterred. When a child of a forking daemon is killed by PaX
57149 + or crashes due to an illegal instruction or other suspicious signal,
57150 + the parent process will be delayed 30 seconds upon every subsequent
57151 + fork until the administrator is able to assess the situation and
57152 + restart the daemon.
57153 + In the suid/sgid case, the attempt is logged, the user has all their
57154 + processes terminated, and they are prevented from executing any further
57155 + processes for 15 minutes.
57156 + It is recommended that you also enable signal logging in the auditing
57157 + section so that logs are generated when a process triggers a suspicious
57158 + signal.
57159 + If the sysctl option is enabled, a sysctl option with name
57160 + "deter_bruteforce" is created.
57161 +
57162 +
57163 +config GRKERNSEC_MODHARDEN
57164 + bool "Harden module auto-loading"
57165 + default y if GRKERNSEC_CONFIG_AUTO
57166 + depends on MODULES
57167 + help
57168 + If you say Y here, module auto-loading in response to use of some
57169 + feature implemented by an unloaded module will be restricted to
57170 + root users. Enabling this option helps defend against attacks
57171 + by unprivileged users who abuse the auto-loading behavior to
57172 + cause a vulnerable module to load that is then exploited.
57173 +
57174 + If this option prevents a legitimate use of auto-loading for a
57175 + non-root user, the administrator can execute modprobe manually
57176 + with the exact name of the module mentioned in the alert log.
57177 + Alternatively, the administrator can add the module to the list
57178 + of modules loaded at boot by modifying init scripts.
57179 +
57180 + Modification of init scripts will most likely be needed on
57181 + Ubuntu servers with encrypted home directory support enabled,
57182 + as the first non-root user logging in will cause the ecb(aes),
57183 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57184 +
57185 +config GRKERNSEC_HIDESYM
57186 + bool "Hide kernel symbols"
57187 + default y if GRKERNSEC_CONFIG_AUTO
57188 + select PAX_USERCOPY_SLABS
57189 + help
57190 + If you say Y here, getting information on loaded modules, and
57191 + displaying all kernel symbols through a syscall will be restricted
57192 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57193 + /proc/kallsyms will be restricted to the root user. The RBAC
57194 + system can hide that entry even from root.
57195 +
57196 + This option also prevents leaking of kernel addresses through
57197 + several /proc entries.
57198 +
57199 + Note that this option is only effective provided the following
57200 + conditions are met:
57201 + 1) The kernel using grsecurity is not precompiled by some distribution
57202 + 2) You have also enabled GRKERNSEC_DMESG
57203 + 3) You are using the RBAC system and hiding other files such as your
57204 + kernel image and System.map. Alternatively, enabling this option
57205 + causes the permissions on /boot, /lib/modules, and the kernel
57206 + source directory to change at compile time to prevent
57207 + reading by non-root users.
57208 + If the above conditions are met, this option will aid in providing a
57209 + useful protection against local kernel exploitation of overflows
57210 + and arbitrary read/write vulnerabilities.
57211 +
57212 +config GRKERNSEC_KERN_LOCKOUT
57213 + bool "Active kernel exploit response"
57214 + default y if GRKERNSEC_CONFIG_AUTO
57215 + depends on X86 || ARM || PPC || SPARC
57216 + help
57217 + If you say Y here, when a PaX alert is triggered due to suspicious
57218 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57219 + or an OOPS occurs due to bad memory accesses, instead of just
57220 + terminating the offending process (and potentially allowing
57221 + a subsequent exploit from the same user), we will take one of two
57222 + actions:
57223 + If the user was root, we will panic the system
57224 + If the user was non-root, we will log the attempt, terminate
57225 + all processes owned by the user, then prevent them from creating
57226 + any new processes until the system is restarted
57227 + This deters repeated kernel exploitation/bruteforcing attempts
57228 + and is useful for later forensics.
57229 +
57230 +endmenu
57231 +menu "Role Based Access Control Options"
57232 +depends on GRKERNSEC
57233 +
57234 +config GRKERNSEC_RBAC_DEBUG
57235 + bool
57236 +
57237 +config GRKERNSEC_NO_RBAC
57238 + bool "Disable RBAC system"
57239 + help
57240 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57241 + preventing the RBAC system from being enabled. You should only say Y
57242 + here if you have no intention of using the RBAC system, so as to prevent
57243 + an attacker with root access from misusing the RBAC system to hide files
57244 + and processes when loadable module support and /dev/[k]mem have been
57245 + locked down.
57246 +
57247 +config GRKERNSEC_ACL_HIDEKERN
57248 + bool "Hide kernel processes"
57249 + help
57250 + If you say Y here, all kernel threads will be hidden to all
57251 + processes but those whose subject has the "view hidden processes"
57252 + flag.
57253 +
57254 +config GRKERNSEC_ACL_MAXTRIES
57255 + int "Maximum tries before password lockout"
57256 + default 3
57257 + help
57258 + This option enforces the maximum number of times a user can attempt
57259 + to authorize themselves with the grsecurity RBAC system before being
57260 + denied the ability to attempt authorization again for a specified time.
57261 + The lower the number, the harder it will be to brute-force a password.
57262 +
57263 +config GRKERNSEC_ACL_TIMEOUT
57264 + int "Time to wait after max password tries, in seconds"
57265 + default 30
57266 + help
57267 + This option specifies the time the user must wait after attempting to
57268 + authorize to the RBAC system with the maximum number of invalid
57269 + passwords. The higher the number, the harder it will be to brute-force
57270 + a password.
57271 +
57272 +endmenu
57273 +menu "Filesystem Protections"
57274 +depends on GRKERNSEC
57275 +
57276 +config GRKERNSEC_PROC
57277 + bool "Proc restrictions"
57278 + default y if GRKERNSEC_CONFIG_AUTO
57279 + help
57280 + If you say Y here, the permissions of the /proc filesystem
57281 + will be altered to enhance system security and privacy. You MUST
57282 + choose either a user only restriction or a user and group restriction.
57283 + Depending upon the option you choose, you can either restrict users to
57284 + see only the processes they themselves run, or choose a group that can
57285 + view all processes and files normally restricted to root if you choose
57286 + the "restrict to user only" option. NOTE: If you're running identd or
57287 + ntpd as a non-root user, you will have to run it as the group you
57288 + specify here.
57289 +
57290 +config GRKERNSEC_PROC_USER
57291 + bool "Restrict /proc to user only"
57292 + depends on GRKERNSEC_PROC
57293 + help
57294 + If you say Y here, non-root users will only be able to view their own
57295 + processes, and restricts them from viewing network-related information,
57296 + and viewing kernel symbol and module information.
57297 +
57298 +config GRKERNSEC_PROC_USERGROUP
57299 + bool "Allow special group"
57300 + default y if GRKERNSEC_CONFIG_AUTO
57301 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57302 + help
57303 + If you say Y here, you will be able to select a group that will be
57304 + able to view all processes and network-related information. If you've
57305 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57306 + remain hidden. This option is useful if you want to run identd as
57307 + a non-root user. The group you select may also be chosen at boot time
57308 + via "grsec_proc_gid=" on the kernel commandline.
57309 +
57310 +config GRKERNSEC_PROC_GID
57311 + int "GID for special group"
57312 + depends on GRKERNSEC_PROC_USERGROUP
57313 + default 1001
57314 +
57315 +config GRKERNSEC_PROC_ADD
57316 + bool "Additional restrictions"
57317 + default y if GRKERNSEC_CONFIG_AUTO
57318 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57319 + help
57320 + If you say Y here, additional restrictions will be placed on
57321 + /proc that keep normal users from viewing device information and
57322 + slabinfo information that could be useful for exploits.
57323 +
57324 +config GRKERNSEC_LINK
57325 + bool "Linking restrictions"
57326 + default y if GRKERNSEC_CONFIG_AUTO
57327 + help
57328 + If you say Y here, /tmp race exploits will be prevented, since users
57329 + will no longer be able to follow symlinks owned by other users in
57330 + world-writable +t directories (e.g. /tmp), unless the owner of the
57331 + symlink is the owner of the directory. users will also not be
57332 + able to hardlink to files they do not own. If the sysctl option is
57333 + enabled, a sysctl option with name "linking_restrictions" is created.
57334 +
57335 +config GRKERNSEC_SYMLINKOWN
57336 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57337 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57338 + help
57339 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57340 + that prevents it from being used as a security feature. As Apache
57341 + verifies the symlink by performing a stat() against the target of
57342 + the symlink before it is followed, an attacker can setup a symlink
57343 + to point to a same-owned file, then replace the symlink with one
57344 + that targets another user's file just after Apache "validates" the
57345 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57346 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57347 + will be in place for the group you specify. If the sysctl option
57348 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57349 + created.
57350 +
57351 +config GRKERNSEC_SYMLINKOWN_GID
57352 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57353 + depends on GRKERNSEC_SYMLINKOWN
57354 + default 1006
57355 + help
57356 + Setting this GID determines what group kernel-enforced
57357 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57358 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57359 +
57360 +config GRKERNSEC_FIFO
57361 + bool "FIFO restrictions"
57362 + default y if GRKERNSEC_CONFIG_AUTO
57363 + help
57364 + If you say Y here, users will not be able to write to FIFOs they don't
57365 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57366 + the FIFO is the same owner of the directory it's held in. If the sysctl
57367 + option is enabled, a sysctl option with name "fifo_restrictions" is
57368 + created.
57369 +
57370 +config GRKERNSEC_SYSFS_RESTRICT
57371 + bool "Sysfs/debugfs restriction"
57372 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57373 + depends on SYSFS
57374 + help
57375 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57376 + any filesystem normally mounted under it (e.g. debugfs) will be
57377 + mostly accessible only by root. These filesystems generally provide access
57378 + to hardware and debug information that isn't appropriate for unprivileged
57379 + users of the system. Sysfs and debugfs have also become a large source
57380 + of new vulnerabilities, ranging from infoleaks to local compromise.
57381 + There has been very little oversight with an eye toward security involved
57382 + in adding new exporters of information to these filesystems, so their
57383 + use is discouraged.
57384 + For reasons of compatibility, a few directories have been whitelisted
57385 + for access by non-root users:
57386 + /sys/fs/selinux
57387 + /sys/fs/fuse
57388 + /sys/devices/system/cpu
57389 +
57390 +config GRKERNSEC_ROFS
57391 + bool "Runtime read-only mount protection"
57392 + help
57393 + If you say Y here, a sysctl option with name "romount_protect" will
57394 + be created. By setting this option to 1 at runtime, filesystems
57395 + will be protected in the following ways:
57396 + * No new writable mounts will be allowed
57397 + * Existing read-only mounts won't be able to be remounted read/write
57398 + * Write operations will be denied on all block devices
57399 + This option acts independently of grsec_lock: once it is set to 1,
57400 + it cannot be turned off. Therefore, please be mindful of the resulting
57401 + behavior if this option is enabled in an init script on a read-only
57402 + filesystem. This feature is mainly intended for secure embedded systems.
57403 +
57404 +config GRKERNSEC_DEVICE_SIDECHANNEL
57405 + bool "Eliminate stat/notify-based device sidechannels"
57406 + default y if GRKERNSEC_CONFIG_AUTO
57407 + help
57408 + If you say Y here, timing analyses on block or character
57409 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57410 + will be thwarted for unprivileged users. If a process without
57411 + CAP_MKNOD stats such a device, the last access and last modify times
57412 + will match the device's create time. No access or modify events
57413 + will be triggered through inotify/dnotify/fanotify for such devices.
57414 + This feature will prevent attacks that may at a minimum
57415 + allow an attacker to determine the administrator's password length.
57416 +
57417 +config GRKERNSEC_CHROOT
57418 + bool "Chroot jail restrictions"
57419 + default y if GRKERNSEC_CONFIG_AUTO
57420 + help
57421 + If you say Y here, you will be able to choose several options that will
57422 + make breaking out of a chrooted jail much more difficult. If you
57423 + encounter no software incompatibilities with the following options, it
57424 + is recommended that you enable each one.
57425 +
57426 +config GRKERNSEC_CHROOT_MOUNT
57427 + bool "Deny mounts"
57428 + default y if GRKERNSEC_CONFIG_AUTO
57429 + depends on GRKERNSEC_CHROOT
57430 + help
57431 + If you say Y here, processes inside a chroot will not be able to
57432 + mount or remount filesystems. If the sysctl option is enabled, a
57433 + sysctl option with name "chroot_deny_mount" is created.
57434 +
57435 +config GRKERNSEC_CHROOT_DOUBLE
57436 + bool "Deny double-chroots"
57437 + default y if GRKERNSEC_CONFIG_AUTO
57438 + depends on GRKERNSEC_CHROOT
57439 + help
57440 + If you say Y here, processes inside a chroot will not be able to chroot
57441 + again outside the chroot. This is a widely used method of breaking
57442 + out of a chroot jail and should not be allowed. If the sysctl
57443 + option is enabled, a sysctl option with name
57444 + "chroot_deny_chroot" is created.
57445 +
57446 +config GRKERNSEC_CHROOT_PIVOT
57447 + bool "Deny pivot_root in chroot"
57448 + default y if GRKERNSEC_CONFIG_AUTO
57449 + depends on GRKERNSEC_CHROOT
57450 + help
57451 + If you say Y here, processes inside a chroot will not be able to use
57452 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57453 + works similar to chroot in that it changes the root filesystem. This
57454 + function could be misused in a chrooted process to attempt to break out
57455 + of the chroot, and therefore should not be allowed. If the sysctl
57456 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57457 + created.
57458 +
57459 +config GRKERNSEC_CHROOT_CHDIR
57460 + bool "Enforce chdir(\"/\") on all chroots"
57461 + default y if GRKERNSEC_CONFIG_AUTO
57462 + depends on GRKERNSEC_CHROOT
57463 + help
57464 + If you say Y here, the current working directory of all newly-chrooted
57465 + applications will be set to the the root directory of the chroot.
57466 + The man page on chroot(2) states:
57467 + Note that this call does not change the current working
57468 + directory, so that `.' can be outside the tree rooted at
57469 + `/'. In particular, the super-user can escape from a
57470 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57471 +
57472 + It is recommended that you say Y here, since it's not known to break
57473 + any software. If the sysctl option is enabled, a sysctl option with
57474 + name "chroot_enforce_chdir" is created.
57475 +
57476 +config GRKERNSEC_CHROOT_CHMOD
57477 + bool "Deny (f)chmod +s"
57478 + default y if GRKERNSEC_CONFIG_AUTO
57479 + depends on GRKERNSEC_CHROOT
57480 + help
57481 + If you say Y here, processes inside a chroot will not be able to chmod
57482 + or fchmod files to make them have suid or sgid bits. This protects
57483 + against another published method of breaking a chroot. If the sysctl
57484 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57485 + created.
57486 +
57487 +config GRKERNSEC_CHROOT_FCHDIR
57488 + bool "Deny fchdir out of chroot"
57489 + default y if GRKERNSEC_CONFIG_AUTO
57490 + depends on GRKERNSEC_CHROOT
57491 + help
57492 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57493 + to a file descriptor of the chrooting process that points to a directory
57494 + outside the filesystem will be stopped. If the sysctl option
57495 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57496 +
57497 +config GRKERNSEC_CHROOT_MKNOD
57498 + bool "Deny mknod"
57499 + default y if GRKERNSEC_CONFIG_AUTO
57500 + depends on GRKERNSEC_CHROOT
57501 + help
57502 + If you say Y here, processes inside a chroot will not be allowed to
57503 + mknod. The problem with using mknod inside a chroot is that it
57504 + would allow an attacker to create a device entry that is the same
57505 + as one on the physical root of your system, which could range from
57506 + anything from the console device to a device for your harddrive (which
57507 + they could then use to wipe the drive or steal data). It is recommended
57508 + that you say Y here, unless you run into software incompatibilities.
57509 + If the sysctl option is enabled, a sysctl option with name
57510 + "chroot_deny_mknod" is created.
57511 +
57512 +config GRKERNSEC_CHROOT_SHMAT
57513 + bool "Deny shmat() out of chroot"
57514 + default y if GRKERNSEC_CONFIG_AUTO
57515 + depends on GRKERNSEC_CHROOT
57516 + help
57517 + If you say Y here, processes inside a chroot will not be able to attach
57518 + to shared memory segments that were created outside of the chroot jail.
57519 + It is recommended that you say Y here. If the sysctl option is enabled,
57520 + a sysctl option with name "chroot_deny_shmat" is created.
57521 +
57522 +config GRKERNSEC_CHROOT_UNIX
57523 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57524 + default y if GRKERNSEC_CONFIG_AUTO
57525 + depends on GRKERNSEC_CHROOT
57526 + help
57527 + If you say Y here, processes inside a chroot will not be able to
57528 + connect to abstract (meaning not belonging to a filesystem) Unix
57529 + domain sockets that were bound outside of a chroot. It is recommended
57530 + that you say Y here. If the sysctl option is enabled, a sysctl option
57531 + with name "chroot_deny_unix" is created.
57532 +
57533 +config GRKERNSEC_CHROOT_FINDTASK
57534 + bool "Protect outside processes"
57535 + default y if GRKERNSEC_CONFIG_AUTO
57536 + depends on GRKERNSEC_CHROOT
57537 + help
57538 + If you say Y here, processes inside a chroot will not be able to
57539 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57540 + getsid, or view any process outside of the chroot. If the sysctl
57541 + option is enabled, a sysctl option with name "chroot_findtask" is
57542 + created.
57543 +
57544 +config GRKERNSEC_CHROOT_NICE
57545 + bool "Restrict priority changes"
57546 + default y if GRKERNSEC_CONFIG_AUTO
57547 + depends on GRKERNSEC_CHROOT
57548 + help
57549 + If you say Y here, processes inside a chroot will not be able to raise
57550 + the priority of processes in the chroot, or alter the priority of
57551 + processes outside the chroot. This provides more security than simply
57552 + removing CAP_SYS_NICE from the process' capability set. If the
57553 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57554 + is created.
57555 +
57556 +config GRKERNSEC_CHROOT_SYSCTL
57557 + bool "Deny sysctl writes"
57558 + default y if GRKERNSEC_CONFIG_AUTO
57559 + depends on GRKERNSEC_CHROOT
57560 + help
57561 + If you say Y here, an attacker in a chroot will not be able to
57562 + write to sysctl entries, either by sysctl(2) or through a /proc
57563 + interface. It is strongly recommended that you say Y here. If the
57564 + sysctl option is enabled, a sysctl option with name
57565 + "chroot_deny_sysctl" is created.
57566 +
57567 +config GRKERNSEC_CHROOT_CAPS
57568 + bool "Capability restrictions"
57569 + default y if GRKERNSEC_CONFIG_AUTO
57570 + depends on GRKERNSEC_CHROOT
57571 + help
57572 + If you say Y here, the capabilities on all processes within a
57573 + chroot jail will be lowered to stop module insertion, raw i/o,
57574 + system and net admin tasks, rebooting the system, modifying immutable
57575 + files, modifying IPC owned by another, and changing the system time.
57576 + This is left an option because it can break some apps. Disable this
57577 + if your chrooted apps are having problems performing those kinds of
57578 + tasks. If the sysctl option is enabled, a sysctl option with
57579 + name "chroot_caps" is created.
57580 +
57581 +endmenu
57582 +menu "Kernel Auditing"
57583 +depends on GRKERNSEC
57584 +
57585 +config GRKERNSEC_AUDIT_GROUP
57586 + bool "Single group for auditing"
57587 + help
57588 + If you say Y here, the exec and chdir logging features will only operate
57589 + on a group you specify. This option is recommended if you only want to
57590 + watch certain users instead of having a large amount of logs from the
57591 + entire system. If the sysctl option is enabled, a sysctl option with
57592 + name "audit_group" is created.
57593 +
57594 +config GRKERNSEC_AUDIT_GID
57595 + int "GID for auditing"
57596 + depends on GRKERNSEC_AUDIT_GROUP
57597 + default 1007
57598 +
57599 +config GRKERNSEC_EXECLOG
57600 + bool "Exec logging"
57601 + help
57602 + If you say Y here, all execve() calls will be logged (since the
57603 + other exec*() calls are frontends to execve(), all execution
57604 + will be logged). Useful for shell-servers that like to keep track
57605 + of their users. If the sysctl option is enabled, a sysctl option with
57606 + name "exec_logging" is created.
57607 + WARNING: This option when enabled will produce a LOT of logs, especially
57608 + on an active system.
57609 +
57610 +config GRKERNSEC_RESLOG
57611 + bool "Resource logging"
57612 + default y if GRKERNSEC_CONFIG_AUTO
57613 + help
57614 + If you say Y here, all attempts to overstep resource limits will
57615 + be logged with the resource name, the requested size, and the current
57616 + limit. It is highly recommended that you say Y here. If the sysctl
57617 + option is enabled, a sysctl option with name "resource_logging" is
57618 + created. If the RBAC system is enabled, the sysctl value is ignored.
57619 +
57620 +config GRKERNSEC_CHROOT_EXECLOG
57621 + bool "Log execs within chroot"
57622 + help
57623 + If you say Y here, all executions inside a chroot jail will be logged
57624 + to syslog. This can cause a large amount of logs if certain
57625 + applications (eg. djb's daemontools) are installed on the system, and
57626 + is therefore left as an option. If the sysctl option is enabled, a
57627 + sysctl option with name "chroot_execlog" is created.
57628 +
57629 +config GRKERNSEC_AUDIT_PTRACE
57630 + bool "Ptrace logging"
57631 + help
57632 + If you say Y here, all attempts to attach to a process via ptrace
57633 + will be logged. If the sysctl option is enabled, a sysctl option
57634 + with name "audit_ptrace" is created.
57635 +
57636 +config GRKERNSEC_AUDIT_CHDIR
57637 + bool "Chdir logging"
57638 + help
57639 + If you say Y here, all chdir() calls will be logged. If the sysctl
57640 + option is enabled, a sysctl option with name "audit_chdir" is created.
57641 +
57642 +config GRKERNSEC_AUDIT_MOUNT
57643 + bool "(Un)Mount logging"
57644 + help
57645 + If you say Y here, all mounts and unmounts will be logged. If the
57646 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57647 + created.
57648 +
57649 +config GRKERNSEC_SIGNAL
57650 + bool "Signal logging"
57651 + default y if GRKERNSEC_CONFIG_AUTO
57652 + help
57653 + If you say Y here, certain important signals will be logged, such as
57654 + SIGSEGV, which will as a result inform you of when a error in a program
57655 + occurred, which in some cases could mean a possible exploit attempt.
57656 + If the sysctl option is enabled, a sysctl option with name
57657 + "signal_logging" is created.
57658 +
57659 +config GRKERNSEC_FORKFAIL
57660 + bool "Fork failure logging"
57661 + help
57662 + If you say Y here, all failed fork() attempts will be logged.
57663 + This could suggest a fork bomb, or someone attempting to overstep
57664 + their process limit. If the sysctl option is enabled, a sysctl option
57665 + with name "forkfail_logging" is created.
57666 +
57667 +config GRKERNSEC_TIME
57668 + bool "Time change logging"
57669 + default y if GRKERNSEC_CONFIG_AUTO
57670 + help
57671 + If you say Y here, any changes of the system clock will be logged.
57672 + If the sysctl option is enabled, a sysctl option with name
57673 + "timechange_logging" is created.
57674 +
57675 +config GRKERNSEC_PROC_IPADDR
57676 + bool "/proc/<pid>/ipaddr support"
57677 + default y if GRKERNSEC_CONFIG_AUTO
57678 + help
57679 + If you say Y here, a new entry will be added to each /proc/<pid>
57680 + directory that contains the IP address of the person using the task.
57681 + The IP is carried across local TCP and AF_UNIX stream sockets.
57682 + This information can be useful for IDS/IPSes to perform remote response
57683 + to a local attack. The entry is readable by only the owner of the
57684 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57685 + the RBAC system), and thus does not create privacy concerns.
57686 +
57687 +config GRKERNSEC_RWXMAP_LOG
57688 + bool 'Denied RWX mmap/mprotect logging'
57689 + default y if GRKERNSEC_CONFIG_AUTO
57690 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57691 + help
57692 + If you say Y here, calls to mmap() and mprotect() with explicit
57693 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57694 + denied by the PAX_MPROTECT feature. If the sysctl option is
57695 + enabled, a sysctl option with name "rwxmap_logging" is created.
57696 +
57697 +config GRKERNSEC_AUDIT_TEXTREL
57698 + bool 'ELF text relocations logging (READ HELP)'
57699 + depends on PAX_MPROTECT
57700 + help
57701 + If you say Y here, text relocations will be logged with the filename
57702 + of the offending library or binary. The purpose of the feature is
57703 + to help Linux distribution developers get rid of libraries and
57704 + binaries that need text relocations which hinder the future progress
57705 + of PaX. Only Linux distribution developers should say Y here, and
57706 + never on a production machine, as this option creates an information
57707 + leak that could aid an attacker in defeating the randomization of
57708 + a single memory region. If the sysctl option is enabled, a sysctl
57709 + option with name "audit_textrel" is created.
57710 +
57711 +endmenu
57712 +
57713 +menu "Executable Protections"
57714 +depends on GRKERNSEC
57715 +
57716 +config GRKERNSEC_DMESG
57717 + bool "Dmesg(8) restriction"
57718 + default y if GRKERNSEC_CONFIG_AUTO
57719 + help
57720 + If you say Y here, non-root users will not be able to use dmesg(8)
57721 + to view the contents of the kernel's circular log buffer.
57722 + The kernel's log buffer often contains kernel addresses and other
57723 + identifying information useful to an attacker in fingerprinting a
57724 + system for a targeted exploit.
57725 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57726 + created.
57727 +
57728 +config GRKERNSEC_HARDEN_PTRACE
57729 + bool "Deter ptrace-based process snooping"
57730 + default y if GRKERNSEC_CONFIG_AUTO
57731 + help
57732 + If you say Y here, TTY sniffers and other malicious monitoring
57733 + programs implemented through ptrace will be defeated. If you
57734 + have been using the RBAC system, this option has already been
57735 + enabled for several years for all users, with the ability to make
57736 + fine-grained exceptions.
57737 +
57738 + This option only affects the ability of non-root users to ptrace
57739 + processes that are not a descendent of the ptracing process.
57740 + This means that strace ./binary and gdb ./binary will still work,
57741 + but attaching to arbitrary processes will not. If the sysctl
57742 + option is enabled, a sysctl option with name "harden_ptrace" is
57743 + created.
57744 +
57745 +config GRKERNSEC_PTRACE_READEXEC
57746 + bool "Require read access to ptrace sensitive binaries"
57747 + default y if GRKERNSEC_CONFIG_AUTO
57748 + help
57749 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57750 + binaries. This option is useful in environments that
57751 + remove the read bits (e.g. file mode 4711) from suid binaries to
57752 + prevent infoleaking of their contents. This option adds
57753 + consistency to the use of that file mode, as the binary could normally
57754 + be read out when run without privileges while ptracing.
57755 +
57756 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57757 + is created.
57758 +
57759 +config GRKERNSEC_SETXID
57760 + bool "Enforce consistent multithreaded privileges"
57761 + default y if GRKERNSEC_CONFIG_AUTO
57762 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57763 + help
57764 + If you say Y here, a change from a root uid to a non-root uid
57765 + in a multithreaded application will cause the resulting uids,
57766 + gids, supplementary groups, and capabilities in that thread
57767 + to be propagated to the other threads of the process. In most
57768 + cases this is unnecessary, as glibc will emulate this behavior
57769 + on behalf of the application. Other libcs do not act in the
57770 + same way, allowing the other threads of the process to continue
57771 + running with root privileges. If the sysctl option is enabled,
57772 + a sysctl option with name "consistent_setxid" is created.
57773 +
57774 +config GRKERNSEC_TPE
57775 + bool "Trusted Path Execution (TPE)"
57776 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57777 + help
57778 + If you say Y here, you will be able to choose a gid to add to the
57779 + supplementary groups of users you want to mark as "untrusted."
57780 + These users will not be able to execute any files that are not in
57781 + root-owned directories writable only by root. If the sysctl option
57782 + is enabled, a sysctl option with name "tpe" is created.
57783 +
57784 +config GRKERNSEC_TPE_ALL
57785 + bool "Partially restrict all non-root users"
57786 + depends on GRKERNSEC_TPE
57787 + help
57788 + If you say Y here, all non-root users will be covered under
57789 + a weaker TPE restriction. This is separate from, and in addition to,
57790 + the main TPE options that you have selected elsewhere. Thus, if a
57791 + "trusted" GID is chosen, this restriction applies to even that GID.
57792 + Under this restriction, all non-root users will only be allowed to
57793 + execute files in directories they own that are not group or
57794 + world-writable, or in directories owned by root and writable only by
57795 + root. If the sysctl option is enabled, a sysctl option with name
57796 + "tpe_restrict_all" is created.
57797 +
57798 +config GRKERNSEC_TPE_INVERT
57799 + bool "Invert GID option"
57800 + depends on GRKERNSEC_TPE
57801 + help
57802 + If you say Y here, the group you specify in the TPE configuration will
57803 + decide what group TPE restrictions will be *disabled* for. This
57804 + option is useful if you want TPE restrictions to be applied to most
57805 + users on the system. If the sysctl option is enabled, a sysctl option
57806 + with name "tpe_invert" is created. Unlike other sysctl options, this
57807 + entry will default to on for backward-compatibility.
57808 +
57809 +config GRKERNSEC_TPE_GID
57810 + int
57811 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57812 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57813 +
57814 +config GRKERNSEC_TPE_UNTRUSTED_GID
57815 + int "GID for TPE-untrusted users"
57816 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57817 + default 1005
57818 + help
57819 + Setting this GID determines what group TPE restrictions will be
57820 + *enabled* for. If the sysctl option is enabled, a sysctl option
57821 + with name "tpe_gid" is created.
57822 +
57823 +config GRKERNSEC_TPE_TRUSTED_GID
57824 + int "GID for TPE-trusted users"
57825 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57826 + default 1005
57827 + help
57828 + Setting this GID determines what group TPE restrictions will be
57829 + *disabled* for. If the sysctl option is enabled, a sysctl option
57830 + with name "tpe_gid" is created.
57831 +
57832 +endmenu
57833 +menu "Network Protections"
57834 +depends on GRKERNSEC
57835 +
57836 +config GRKERNSEC_RANDNET
57837 + bool "Larger entropy pools"
57838 + default y if GRKERNSEC_CONFIG_AUTO
57839 + help
57840 + If you say Y here, the entropy pools used for many features of Linux
57841 + and grsecurity will be doubled in size. Since several grsecurity
57842 + features use additional randomness, it is recommended that you say Y
57843 + here. Saying Y here has a similar effect as modifying
57844 + /proc/sys/kernel/random/poolsize.
57845 +
57846 +config GRKERNSEC_BLACKHOLE
57847 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57848 + default y if GRKERNSEC_CONFIG_AUTO
57849 + depends on NET
57850 + help
57851 + If you say Y here, neither TCP resets nor ICMP
57852 + destination-unreachable packets will be sent in response to packets
57853 + sent to ports for which no associated listening process exists.
57854 + This feature supports both IPV4 and IPV6 and exempts the
57855 + loopback interface from blackholing. Enabling this feature
57856 + makes a host more resilient to DoS attacks and reduces network
57857 + visibility against scanners.
57858 +
57859 + The blackhole feature as-implemented is equivalent to the FreeBSD
57860 + blackhole feature, as it prevents RST responses to all packets, not
57861 + just SYNs. Under most application behavior this causes no
57862 + problems, but applications (like haproxy) may not close certain
57863 + connections in a way that cleanly terminates them on the remote
57864 + end, leaving the remote host in LAST_ACK state. Because of this
57865 + side-effect and to prevent intentional LAST_ACK DoSes, this
57866 + feature also adds automatic mitigation against such attacks.
57867 + The mitigation drastically reduces the amount of time a socket
57868 + can spend in LAST_ACK state. If you're using haproxy and not
57869 + all servers it connects to have this option enabled, consider
57870 + disabling this feature on the haproxy host.
57871 +
57872 + If the sysctl option is enabled, two sysctl options with names
57873 + "ip_blackhole" and "lastack_retries" will be created.
57874 + While "ip_blackhole" takes the standard zero/non-zero on/off
57875 + toggle, "lastack_retries" uses the same kinds of values as
57876 + "tcp_retries1" and "tcp_retries2". The default value of 4
57877 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57878 + state.
57879 +
57880 +config GRKERNSEC_NO_SIMULT_CONNECT
57881 + bool "Disable TCP Simultaneous Connect"
57882 + default y if GRKERNSEC_CONFIG_AUTO
57883 + depends on NET
57884 + help
57885 + If you say Y here, a feature by Willy Tarreau will be enabled that
57886 + removes a weakness in Linux's strict implementation of TCP that
57887 + allows two clients to connect to each other without either entering
57888 + a listening state. The weakness allows an attacker to easily prevent
57889 + a client from connecting to a known server provided the source port
57890 + for the connection is guessed correctly.
57891 +
57892 + As the weakness could be used to prevent an antivirus or IPS from
57893 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57894 + it should be eliminated by enabling this option. Though Linux is
57895 + one of few operating systems supporting simultaneous connect, it
57896 + has no legitimate use in practice and is rarely supported by firewalls.
57897 +
57898 +config GRKERNSEC_SOCKET
57899 + bool "Socket restrictions"
57900 + depends on NET
57901 + help
57902 + If you say Y here, you will be able to choose from several options.
57903 + If you assign a GID on your system and add it to the supplementary
57904 + groups of users you want to restrict socket access to, this patch
57905 + will perform up to three things, based on the option(s) you choose.
57906 +
57907 +config GRKERNSEC_SOCKET_ALL
57908 + bool "Deny any sockets to group"
57909 + depends on GRKERNSEC_SOCKET
57910 + help
57911 + If you say Y here, you will be able to choose a GID of whose users will
57912 + be unable to connect to other hosts from your machine or run server
57913 + applications from your machine. If the sysctl option is enabled, a
57914 + sysctl option with name "socket_all" is created.
57915 +
57916 +config GRKERNSEC_SOCKET_ALL_GID
57917 + int "GID to deny all sockets for"
57918 + depends on GRKERNSEC_SOCKET_ALL
57919 + default 1004
57920 + help
57921 + Here you can choose the GID to disable socket access for. Remember to
57922 + add the users you want socket access disabled for to the GID
57923 + specified here. If the sysctl option is enabled, a sysctl option
57924 + with name "socket_all_gid" is created.
57925 +
57926 +config GRKERNSEC_SOCKET_CLIENT
57927 + bool "Deny client sockets to group"
57928 + depends on GRKERNSEC_SOCKET
57929 + help
57930 + If you say Y here, you will be able to choose a GID of whose users will
57931 + be unable to connect to other hosts from your machine, but will be
57932 + able to run servers. If this option is enabled, all users in the group
57933 + you specify will have to use passive mode when initiating ftp transfers
57934 + from the shell on your machine. If the sysctl option is enabled, a
57935 + sysctl option with name "socket_client" is created.
57936 +
57937 +config GRKERNSEC_SOCKET_CLIENT_GID
57938 + int "GID to deny client sockets for"
57939 + depends on GRKERNSEC_SOCKET_CLIENT
57940 + default 1003
57941 + help
57942 + Here you can choose the GID to disable client socket access for.
57943 + Remember to add the users you want client socket access disabled for to
57944 + the GID specified here. If the sysctl option is enabled, a sysctl
57945 + option with name "socket_client_gid" is created.
57946 +
57947 +config GRKERNSEC_SOCKET_SERVER
57948 + bool "Deny server sockets to group"
57949 + depends on GRKERNSEC_SOCKET
57950 + help
57951 + If you say Y here, you will be able to choose a GID of whose users will
57952 + be unable to run server applications from your machine. If the sysctl
57953 + option is enabled, a sysctl option with name "socket_server" is created.
57954 +
57955 +config GRKERNSEC_SOCKET_SERVER_GID
57956 + int "GID to deny server sockets for"
57957 + depends on GRKERNSEC_SOCKET_SERVER
57958 + default 1002
57959 + help
57960 + Here you can choose the GID to disable server socket access for.
57961 + Remember to add the users you want server socket access disabled for to
57962 + the GID specified here. If the sysctl option is enabled, a sysctl
57963 + option with name "socket_server_gid" is created.
57964 +
57965 +endmenu
57966 +menu "Sysctl Support"
57967 +depends on GRKERNSEC && SYSCTL
57968 +
57969 +config GRKERNSEC_SYSCTL
57970 + bool "Sysctl support"
57971 + default y if GRKERNSEC_CONFIG_AUTO
57972 + help
57973 + If you say Y here, you will be able to change the options that
57974 + grsecurity runs with at bootup, without having to recompile your
57975 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
57976 + to enable (1) or disable (0) various features. All the sysctl entries
57977 + are mutable until the "grsec_lock" entry is set to a non-zero value.
57978 + All features enabled in the kernel configuration are disabled at boot
57979 + if you do not say Y to the "Turn on features by default" option.
57980 + All options should be set at startup, and the grsec_lock entry should
57981 + be set to a non-zero value after all the options are set.
57982 + *THIS IS EXTREMELY IMPORTANT*
57983 +
57984 +config GRKERNSEC_SYSCTL_DISTRO
57985 + bool "Extra sysctl support for distro makers (READ HELP)"
57986 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
57987 + help
57988 + If you say Y here, additional sysctl options will be created
57989 + for features that affect processes running as root. Therefore,
57990 + it is critical when using this option that the grsec_lock entry be
57991 + enabled after boot. Only distros with prebuilt kernel packages
57992 + with this option enabled that can ensure grsec_lock is enabled
57993 + after boot should use this option.
57994 + *Failure to set grsec_lock after boot makes all grsec features
57995 + this option covers useless*
57996 +
57997 + Currently this option creates the following sysctl entries:
57998 + "Disable Privileged I/O": "disable_priv_io"
57999 +
58000 +config GRKERNSEC_SYSCTL_ON
58001 + bool "Turn on features by default"
58002 + default y if GRKERNSEC_CONFIG_AUTO
58003 + depends on GRKERNSEC_SYSCTL
58004 + help
58005 + If you say Y here, instead of having all features enabled in the
58006 + kernel configuration disabled at boot time, the features will be
58007 + enabled at boot time. It is recommended you say Y here unless
58008 + there is some reason you would want all sysctl-tunable features to
58009 + be disabled by default. As mentioned elsewhere, it is important
58010 + to enable the grsec_lock entry once you have finished modifying
58011 + the sysctl entries.
58012 +
58013 +endmenu
58014 +menu "Logging Options"
58015 +depends on GRKERNSEC
58016 +
58017 +config GRKERNSEC_FLOODTIME
58018 + int "Seconds in between log messages (minimum)"
58019 + default 10
58020 + help
58021 + This option allows you to enforce the number of seconds between
58022 + grsecurity log messages. The default should be suitable for most
58023 + people, however, if you choose to change it, choose a value small enough
58024 + to allow informative logs to be produced, but large enough to
58025 + prevent flooding.
58026 +
58027 +config GRKERNSEC_FLOODBURST
58028 + int "Number of messages in a burst (maximum)"
58029 + default 6
58030 + help
58031 + This option allows you to choose the maximum number of messages allowed
58032 + within the flood time interval you chose in a separate option. The
58033 + default should be suitable for most people, however if you find that
58034 + many of your logs are being interpreted as flooding, you may want to
58035 + raise this value.
58036 +
58037 +endmenu
58038 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58039 new file mode 100644
58040 index 0000000..1b9afa9
58041 --- /dev/null
58042 +++ b/grsecurity/Makefile
58043 @@ -0,0 +1,38 @@
58044 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58045 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58046 +# into an RBAC system
58047 +#
58048 +# All code in this directory and various hooks inserted throughout the kernel
58049 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58050 +# under the GPL v2 or higher
58051 +
58052 +KBUILD_CFLAGS += -Werror
58053 +
58054 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58055 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58056 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58057 +
58058 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58059 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58060 + gracl_learn.o grsec_log.o
58061 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58062 +
58063 +ifdef CONFIG_NET
58064 +obj-y += grsec_sock.o
58065 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58066 +endif
58067 +
58068 +ifndef CONFIG_GRKERNSEC
58069 +obj-y += grsec_disabled.o
58070 +endif
58071 +
58072 +ifdef CONFIG_GRKERNSEC_HIDESYM
58073 +extra-y := grsec_hidesym.o
58074 +$(obj)/grsec_hidesym.o:
58075 + @-chmod -f 500 /boot
58076 + @-chmod -f 500 /lib/modules
58077 + @-chmod -f 500 /lib64/modules
58078 + @-chmod -f 500 /lib32/modules
58079 + @-chmod -f 700 .
58080 + @echo ' grsec: protected kernel image paths'
58081 +endif
58082 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58083 new file mode 100644
58084 index 0000000..b306b36
58085 --- /dev/null
58086 +++ b/grsecurity/gracl.c
58087 @@ -0,0 +1,4071 @@
58088 +#include <linux/kernel.h>
58089 +#include <linux/module.h>
58090 +#include <linux/sched.h>
58091 +#include <linux/mm.h>
58092 +#include <linux/file.h>
58093 +#include <linux/fs.h>
58094 +#include <linux/namei.h>
58095 +#include <linux/mount.h>
58096 +#include <linux/tty.h>
58097 +#include <linux/proc_fs.h>
58098 +#include <linux/lglock.h>
58099 +#include <linux/slab.h>
58100 +#include <linux/vmalloc.h>
58101 +#include <linux/types.h>
58102 +#include <linux/sysctl.h>
58103 +#include <linux/netdevice.h>
58104 +#include <linux/ptrace.h>
58105 +#include <linux/gracl.h>
58106 +#include <linux/gralloc.h>
58107 +#include <linux/security.h>
58108 +#include <linux/grinternal.h>
58109 +#include <linux/pid_namespace.h>
58110 +#include <linux/stop_machine.h>
58111 +#include <linux/fdtable.h>
58112 +#include <linux/percpu.h>
58113 +#include <linux/lglock.h>
58114 +#include <linux/hugetlb.h>
58115 +#include <linux/posix-timers.h>
58116 +#include "../fs/mount.h"
58117 +
58118 +#include <asm/uaccess.h>
58119 +#include <asm/errno.h>
58120 +#include <asm/mman.h>
58121 +
58122 +extern struct lglock vfsmount_lock;
58123 +
58124 +static struct acl_role_db acl_role_set;
58125 +static struct name_db name_set;
58126 +static struct inodev_db inodev_set;
58127 +
58128 +/* for keeping track of userspace pointers used for subjects, so we
58129 + can share references in the kernel as well
58130 +*/
58131 +
58132 +static struct path real_root;
58133 +
58134 +static struct acl_subj_map_db subj_map_set;
58135 +
58136 +static struct acl_role_label *default_role;
58137 +
58138 +static struct acl_role_label *role_list;
58139 +
58140 +static u16 acl_sp_role_value;
58141 +
58142 +extern char *gr_shared_page[4];
58143 +static DEFINE_MUTEX(gr_dev_mutex);
58144 +DEFINE_RWLOCK(gr_inode_lock);
58145 +
58146 +struct gr_arg *gr_usermode;
58147 +
58148 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58149 +
58150 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58151 +extern void gr_clear_learn_entries(void);
58152 +
58153 +unsigned char *gr_system_salt;
58154 +unsigned char *gr_system_sum;
58155 +
58156 +static struct sprole_pw **acl_special_roles = NULL;
58157 +static __u16 num_sprole_pws = 0;
58158 +
58159 +static struct acl_role_label *kernel_role = NULL;
58160 +
58161 +static unsigned int gr_auth_attempts = 0;
58162 +static unsigned long gr_auth_expires = 0UL;
58163 +
58164 +#ifdef CONFIG_NET
58165 +extern struct vfsmount *sock_mnt;
58166 +#endif
58167 +
58168 +extern struct vfsmount *pipe_mnt;
58169 +extern struct vfsmount *shm_mnt;
58170 +
58171 +#ifdef CONFIG_HUGETLBFS
58172 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58173 +#endif
58174 +
58175 +static struct acl_object_label *fakefs_obj_rw;
58176 +static struct acl_object_label *fakefs_obj_rwx;
58177 +
58178 +extern int gr_init_uidset(void);
58179 +extern void gr_free_uidset(void);
58180 +extern void gr_remove_uid(uid_t uid);
58181 +extern int gr_find_uid(uid_t uid);
58182 +
58183 +__inline__ int
58184 +gr_acl_is_enabled(void)
58185 +{
58186 + return (gr_status & GR_READY);
58187 +}
58188 +
58189 +#ifdef CONFIG_BTRFS_FS
58190 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
58191 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
58192 +#endif
58193 +
58194 +static inline dev_t __get_dev(const struct dentry *dentry)
58195 +{
58196 +#ifdef CONFIG_BTRFS_FS
58197 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
58198 + return get_btrfs_dev_from_inode(dentry->d_inode);
58199 + else
58200 +#endif
58201 + return dentry->d_inode->i_sb->s_dev;
58202 +}
58203 +
58204 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58205 +{
58206 + return __get_dev(dentry);
58207 +}
58208 +
58209 +static char gr_task_roletype_to_char(struct task_struct *task)
58210 +{
58211 + switch (task->role->roletype &
58212 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58213 + GR_ROLE_SPECIAL)) {
58214 + case GR_ROLE_DEFAULT:
58215 + return 'D';
58216 + case GR_ROLE_USER:
58217 + return 'U';
58218 + case GR_ROLE_GROUP:
58219 + return 'G';
58220 + case GR_ROLE_SPECIAL:
58221 + return 'S';
58222 + }
58223 +
58224 + return 'X';
58225 +}
58226 +
58227 +char gr_roletype_to_char(void)
58228 +{
58229 + return gr_task_roletype_to_char(current);
58230 +}
58231 +
58232 +__inline__ int
58233 +gr_acl_tpe_check(void)
58234 +{
58235 + if (unlikely(!(gr_status & GR_READY)))
58236 + return 0;
58237 + if (current->role->roletype & GR_ROLE_TPE)
58238 + return 1;
58239 + else
58240 + return 0;
58241 +}
58242 +
58243 +int
58244 +gr_handle_rawio(const struct inode *inode)
58245 +{
58246 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58247 + if (inode && S_ISBLK(inode->i_mode) &&
58248 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58249 + !capable(CAP_SYS_RAWIO))
58250 + return 1;
58251 +#endif
58252 + return 0;
58253 +}
58254 +
58255 +static int
58256 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58257 +{
58258 + if (likely(lena != lenb))
58259 + return 0;
58260 +
58261 + return !memcmp(a, b, lena);
58262 +}
58263 +
58264 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58265 +{
58266 + *buflen -= namelen;
58267 + if (*buflen < 0)
58268 + return -ENAMETOOLONG;
58269 + *buffer -= namelen;
58270 + memcpy(*buffer, str, namelen);
58271 + return 0;
58272 +}
58273 +
58274 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58275 +{
58276 + return prepend(buffer, buflen, name->name, name->len);
58277 +}
58278 +
58279 +static int prepend_path(const struct path *path, struct path *root,
58280 + char **buffer, int *buflen)
58281 +{
58282 + struct dentry *dentry = path->dentry;
58283 + struct vfsmount *vfsmnt = path->mnt;
58284 + struct mount *mnt = real_mount(vfsmnt);
58285 + bool slash = false;
58286 + int error = 0;
58287 +
58288 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58289 + struct dentry * parent;
58290 +
58291 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58292 + /* Global root? */
58293 + if (!mnt_has_parent(mnt)) {
58294 + goto out;
58295 + }
58296 + dentry = mnt->mnt_mountpoint;
58297 + mnt = mnt->mnt_parent;
58298 + vfsmnt = &mnt->mnt;
58299 + continue;
58300 + }
58301 + parent = dentry->d_parent;
58302 + prefetch(parent);
58303 + spin_lock(&dentry->d_lock);
58304 + error = prepend_name(buffer, buflen, &dentry->d_name);
58305 + spin_unlock(&dentry->d_lock);
58306 + if (!error)
58307 + error = prepend(buffer, buflen, "/", 1);
58308 + if (error)
58309 + break;
58310 +
58311 + slash = true;
58312 + dentry = parent;
58313 + }
58314 +
58315 +out:
58316 + if (!error && !slash)
58317 + error = prepend(buffer, buflen, "/", 1);
58318 +
58319 + return error;
58320 +}
58321 +
58322 +/* this must be called with vfsmount_lock and rename_lock held */
58323 +
58324 +static char *__our_d_path(const struct path *path, struct path *root,
58325 + char *buf, int buflen)
58326 +{
58327 + char *res = buf + buflen;
58328 + int error;
58329 +
58330 + prepend(&res, &buflen, "\0", 1);
58331 + error = prepend_path(path, root, &res, &buflen);
58332 + if (error)
58333 + return ERR_PTR(error);
58334 +
58335 + return res;
58336 +}
58337 +
58338 +static char *
58339 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58340 +{
58341 + char *retval;
58342 +
58343 + retval = __our_d_path(path, root, buf, buflen);
58344 + if (unlikely(IS_ERR(retval)))
58345 + retval = strcpy(buf, "<path too long>");
58346 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58347 + retval[1] = '\0';
58348 +
58349 + return retval;
58350 +}
58351 +
58352 +static char *
58353 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58354 + char *buf, int buflen)
58355 +{
58356 + struct path path;
58357 + char *res;
58358 +
58359 + path.dentry = (struct dentry *)dentry;
58360 + path.mnt = (struct vfsmount *)vfsmnt;
58361 +
58362 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58363 + by the RBAC system */
58364 + res = gen_full_path(&path, &real_root, buf, buflen);
58365 +
58366 + return res;
58367 +}
58368 +
58369 +static char *
58370 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58371 + char *buf, int buflen)
58372 +{
58373 + char *res;
58374 + struct path path;
58375 + struct path root;
58376 + struct task_struct *reaper = init_pid_ns.child_reaper;
58377 +
58378 + path.dentry = (struct dentry *)dentry;
58379 + path.mnt = (struct vfsmount *)vfsmnt;
58380 +
58381 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58382 + get_fs_root(reaper->fs, &root);
58383 +
58384 + br_read_lock(&vfsmount_lock);
58385 + write_seqlock(&rename_lock);
58386 + res = gen_full_path(&path, &root, buf, buflen);
58387 + write_sequnlock(&rename_lock);
58388 + br_read_unlock(&vfsmount_lock);
58389 +
58390 + path_put(&root);
58391 + return res;
58392 +}
58393 +
58394 +static char *
58395 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58396 +{
58397 + char *ret;
58398 + br_read_lock(&vfsmount_lock);
58399 + write_seqlock(&rename_lock);
58400 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58401 + PAGE_SIZE);
58402 + write_sequnlock(&rename_lock);
58403 + br_read_unlock(&vfsmount_lock);
58404 + return ret;
58405 +}
58406 +
58407 +static char *
58408 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58409 +{
58410 + char *ret;
58411 + char *buf;
58412 + int buflen;
58413 +
58414 + br_read_lock(&vfsmount_lock);
58415 + write_seqlock(&rename_lock);
58416 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58417 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58418 + buflen = (int)(ret - buf);
58419 + if (buflen >= 5)
58420 + prepend(&ret, &buflen, "/proc", 5);
58421 + else
58422 + ret = strcpy(buf, "<path too long>");
58423 + write_sequnlock(&rename_lock);
58424 + br_read_unlock(&vfsmount_lock);
58425 + return ret;
58426 +}
58427 +
58428 +char *
58429 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58430 +{
58431 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58432 + PAGE_SIZE);
58433 +}
58434 +
58435 +char *
58436 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58437 +{
58438 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58439 + PAGE_SIZE);
58440 +}
58441 +
58442 +char *
58443 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58444 +{
58445 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58446 + PAGE_SIZE);
58447 +}
58448 +
58449 +char *
58450 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58451 +{
58452 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58453 + PAGE_SIZE);
58454 +}
58455 +
58456 +char *
58457 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58458 +{
58459 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58460 + PAGE_SIZE);
58461 +}
58462 +
58463 +__inline__ __u32
58464 +to_gr_audit(const __u32 reqmode)
58465 +{
58466 + /* masks off auditable permission flags, then shifts them to create
58467 + auditing flags, and adds the special case of append auditing if
58468 + we're requesting write */
58469 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58470 +}
58471 +
58472 +struct acl_subject_label *
58473 +lookup_subject_map(const struct acl_subject_label *userp)
58474 +{
58475 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58476 + struct subject_map *match;
58477 +
58478 + match = subj_map_set.s_hash[index];
58479 +
58480 + while (match && match->user != userp)
58481 + match = match->next;
58482 +
58483 + if (match != NULL)
58484 + return match->kernel;
58485 + else
58486 + return NULL;
58487 +}
58488 +
58489 +static void
58490 +insert_subj_map_entry(struct subject_map *subjmap)
58491 +{
58492 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58493 + struct subject_map **curr;
58494 +
58495 + subjmap->prev = NULL;
58496 +
58497 + curr = &subj_map_set.s_hash[index];
58498 + if (*curr != NULL)
58499 + (*curr)->prev = subjmap;
58500 +
58501 + subjmap->next = *curr;
58502 + *curr = subjmap;
58503 +
58504 + return;
58505 +}
58506 +
58507 +static struct acl_role_label *
58508 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58509 + const gid_t gid)
58510 +{
58511 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58512 + struct acl_role_label *match;
58513 + struct role_allowed_ip *ipp;
58514 + unsigned int x;
58515 + u32 curr_ip = task->signal->curr_ip;
58516 +
58517 + task->signal->saved_ip = curr_ip;
58518 +
58519 + match = acl_role_set.r_hash[index];
58520 +
58521 + while (match) {
58522 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58523 + for (x = 0; x < match->domain_child_num; x++) {
58524 + if (match->domain_children[x] == uid)
58525 + goto found;
58526 + }
58527 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58528 + break;
58529 + match = match->next;
58530 + }
58531 +found:
58532 + if (match == NULL) {
58533 + try_group:
58534 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58535 + match = acl_role_set.r_hash[index];
58536 +
58537 + while (match) {
58538 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58539 + for (x = 0; x < match->domain_child_num; x++) {
58540 + if (match->domain_children[x] == gid)
58541 + goto found2;
58542 + }
58543 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58544 + break;
58545 + match = match->next;
58546 + }
58547 +found2:
58548 + if (match == NULL)
58549 + match = default_role;
58550 + if (match->allowed_ips == NULL)
58551 + return match;
58552 + else {
58553 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58554 + if (likely
58555 + ((ntohl(curr_ip) & ipp->netmask) ==
58556 + (ntohl(ipp->addr) & ipp->netmask)))
58557 + return match;
58558 + }
58559 + match = default_role;
58560 + }
58561 + } else if (match->allowed_ips == NULL) {
58562 + return match;
58563 + } else {
58564 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58565 + if (likely
58566 + ((ntohl(curr_ip) & ipp->netmask) ==
58567 + (ntohl(ipp->addr) & ipp->netmask)))
58568 + return match;
58569 + }
58570 + goto try_group;
58571 + }
58572 +
58573 + return match;
58574 +}
58575 +
58576 +struct acl_subject_label *
58577 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58578 + const struct acl_role_label *role)
58579 +{
58580 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58581 + struct acl_subject_label *match;
58582 +
58583 + match = role->subj_hash[index];
58584 +
58585 + while (match && (match->inode != ino || match->device != dev ||
58586 + (match->mode & GR_DELETED))) {
58587 + match = match->next;
58588 + }
58589 +
58590 + if (match && !(match->mode & GR_DELETED))
58591 + return match;
58592 + else
58593 + return NULL;
58594 +}
58595 +
58596 +struct acl_subject_label *
58597 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58598 + const struct acl_role_label *role)
58599 +{
58600 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58601 + struct acl_subject_label *match;
58602 +
58603 + match = role->subj_hash[index];
58604 +
58605 + while (match && (match->inode != ino || match->device != dev ||
58606 + !(match->mode & GR_DELETED))) {
58607 + match = match->next;
58608 + }
58609 +
58610 + if (match && (match->mode & GR_DELETED))
58611 + return match;
58612 + else
58613 + return NULL;
58614 +}
58615 +
58616 +static struct acl_object_label *
58617 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58618 + const struct acl_subject_label *subj)
58619 +{
58620 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58621 + struct acl_object_label *match;
58622 +
58623 + match = subj->obj_hash[index];
58624 +
58625 + while (match && (match->inode != ino || match->device != dev ||
58626 + (match->mode & GR_DELETED))) {
58627 + match = match->next;
58628 + }
58629 +
58630 + if (match && !(match->mode & GR_DELETED))
58631 + return match;
58632 + else
58633 + return NULL;
58634 +}
58635 +
58636 +static struct acl_object_label *
58637 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58638 + const struct acl_subject_label *subj)
58639 +{
58640 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58641 + struct acl_object_label *match;
58642 +
58643 + match = subj->obj_hash[index];
58644 +
58645 + while (match && (match->inode != ino || match->device != dev ||
58646 + !(match->mode & GR_DELETED))) {
58647 + match = match->next;
58648 + }
58649 +
58650 + if (match && (match->mode & GR_DELETED))
58651 + return match;
58652 +
58653 + match = subj->obj_hash[index];
58654 +
58655 + while (match && (match->inode != ino || match->device != dev ||
58656 + (match->mode & GR_DELETED))) {
58657 + match = match->next;
58658 + }
58659 +
58660 + if (match && !(match->mode & GR_DELETED))
58661 + return match;
58662 + else
58663 + return NULL;
58664 +}
58665 +
58666 +static struct name_entry *
58667 +lookup_name_entry(const char *name)
58668 +{
58669 + unsigned int len = strlen(name);
58670 + unsigned int key = full_name_hash(name, len);
58671 + unsigned int index = key % name_set.n_size;
58672 + struct name_entry *match;
58673 +
58674 + match = name_set.n_hash[index];
58675 +
58676 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58677 + match = match->next;
58678 +
58679 + return match;
58680 +}
58681 +
58682 +static struct name_entry *
58683 +lookup_name_entry_create(const char *name)
58684 +{
58685 + unsigned int len = strlen(name);
58686 + unsigned int key = full_name_hash(name, len);
58687 + unsigned int index = key % name_set.n_size;
58688 + struct name_entry *match;
58689 +
58690 + match = name_set.n_hash[index];
58691 +
58692 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58693 + !match->deleted))
58694 + match = match->next;
58695 +
58696 + if (match && match->deleted)
58697 + return match;
58698 +
58699 + match = name_set.n_hash[index];
58700 +
58701 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58702 + match->deleted))
58703 + match = match->next;
58704 +
58705 + if (match && !match->deleted)
58706 + return match;
58707 + else
58708 + return NULL;
58709 +}
58710 +
58711 +static struct inodev_entry *
58712 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58713 +{
58714 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58715 + struct inodev_entry *match;
58716 +
58717 + match = inodev_set.i_hash[index];
58718 +
58719 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58720 + match = match->next;
58721 +
58722 + return match;
58723 +}
58724 +
58725 +static void
58726 +insert_inodev_entry(struct inodev_entry *entry)
58727 +{
58728 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58729 + inodev_set.i_size);
58730 + struct inodev_entry **curr;
58731 +
58732 + entry->prev = NULL;
58733 +
58734 + curr = &inodev_set.i_hash[index];
58735 + if (*curr != NULL)
58736 + (*curr)->prev = entry;
58737 +
58738 + entry->next = *curr;
58739 + *curr = entry;
58740 +
58741 + return;
58742 +}
58743 +
58744 +static void
58745 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58746 +{
58747 + unsigned int index =
58748 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58749 + struct acl_role_label **curr;
58750 + struct acl_role_label *tmp, *tmp2;
58751 +
58752 + curr = &acl_role_set.r_hash[index];
58753 +
58754 + /* simple case, slot is empty, just set it to our role */
58755 + if (*curr == NULL) {
58756 + *curr = role;
58757 + } else {
58758 + /* example:
58759 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58760 + 2 -> 3
58761 + */
58762 + /* first check to see if we can already be reached via this slot */
58763 + tmp = *curr;
58764 + while (tmp && tmp != role)
58765 + tmp = tmp->next;
58766 + if (tmp == role) {
58767 + /* we don't need to add ourselves to this slot's chain */
58768 + return;
58769 + }
58770 + /* we need to add ourselves to this chain, two cases */
58771 + if (role->next == NULL) {
58772 + /* simple case, append the current chain to our role */
58773 + role->next = *curr;
58774 + *curr = role;
58775 + } else {
58776 + /* 1 -> 2 -> 3 -> 4
58777 + 2 -> 3 -> 4
58778 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58779 + */
58780 + /* trickier case: walk our role's chain until we find
58781 + the role for the start of the current slot's chain */
58782 + tmp = role;
58783 + tmp2 = *curr;
58784 + while (tmp->next && tmp->next != tmp2)
58785 + tmp = tmp->next;
58786 + if (tmp->next == tmp2) {
58787 + /* from example above, we found 3, so just
58788 + replace this slot's chain with ours */
58789 + *curr = role;
58790 + } else {
58791 + /* we didn't find a subset of our role's chain
58792 + in the current slot's chain, so append their
58793 + chain to ours, and set us as the first role in
58794 + the slot's chain
58795 +
58796 + we could fold this case with the case above,
58797 + but making it explicit for clarity
58798 + */
58799 + tmp->next = tmp2;
58800 + *curr = role;
58801 + }
58802 + }
58803 + }
58804 +
58805 + return;
58806 +}
58807 +
58808 +static void
58809 +insert_acl_role_label(struct acl_role_label *role)
58810 +{
58811 + int i;
58812 +
58813 + if (role_list == NULL) {
58814 + role_list = role;
58815 + role->prev = NULL;
58816 + } else {
58817 + role->prev = role_list;
58818 + role_list = role;
58819 + }
58820 +
58821 + /* used for hash chains */
58822 + role->next = NULL;
58823 +
58824 + if (role->roletype & GR_ROLE_DOMAIN) {
58825 + for (i = 0; i < role->domain_child_num; i++)
58826 + __insert_acl_role_label(role, role->domain_children[i]);
58827 + } else
58828 + __insert_acl_role_label(role, role->uidgid);
58829 +}
58830 +
58831 +static int
58832 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58833 +{
58834 + struct name_entry **curr, *nentry;
58835 + struct inodev_entry *ientry;
58836 + unsigned int len = strlen(name);
58837 + unsigned int key = full_name_hash(name, len);
58838 + unsigned int index = key % name_set.n_size;
58839 +
58840 + curr = &name_set.n_hash[index];
58841 +
58842 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58843 + curr = &((*curr)->next);
58844 +
58845 + if (*curr != NULL)
58846 + return 1;
58847 +
58848 + nentry = acl_alloc(sizeof (struct name_entry));
58849 + if (nentry == NULL)
58850 + return 0;
58851 + ientry = acl_alloc(sizeof (struct inodev_entry));
58852 + if (ientry == NULL)
58853 + return 0;
58854 + ientry->nentry = nentry;
58855 +
58856 + nentry->key = key;
58857 + nentry->name = name;
58858 + nentry->inode = inode;
58859 + nentry->device = device;
58860 + nentry->len = len;
58861 + nentry->deleted = deleted;
58862 +
58863 + nentry->prev = NULL;
58864 + curr = &name_set.n_hash[index];
58865 + if (*curr != NULL)
58866 + (*curr)->prev = nentry;
58867 + nentry->next = *curr;
58868 + *curr = nentry;
58869 +
58870 + /* insert us into the table searchable by inode/dev */
58871 + insert_inodev_entry(ientry);
58872 +
58873 + return 1;
58874 +}
58875 +
58876 +static void
58877 +insert_acl_obj_label(struct acl_object_label *obj,
58878 + struct acl_subject_label *subj)
58879 +{
58880 + unsigned int index =
58881 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58882 + struct acl_object_label **curr;
58883 +
58884 +
58885 + obj->prev = NULL;
58886 +
58887 + curr = &subj->obj_hash[index];
58888 + if (*curr != NULL)
58889 + (*curr)->prev = obj;
58890 +
58891 + obj->next = *curr;
58892 + *curr = obj;
58893 +
58894 + return;
58895 +}
58896 +
58897 +static void
58898 +insert_acl_subj_label(struct acl_subject_label *obj,
58899 + struct acl_role_label *role)
58900 +{
58901 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
58902 + struct acl_subject_label **curr;
58903 +
58904 + obj->prev = NULL;
58905 +
58906 + curr = &role->subj_hash[index];
58907 + if (*curr != NULL)
58908 + (*curr)->prev = obj;
58909 +
58910 + obj->next = *curr;
58911 + *curr = obj;
58912 +
58913 + return;
58914 +}
58915 +
58916 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
58917 +
58918 +static void *
58919 +create_table(__u32 * len, int elementsize)
58920 +{
58921 + unsigned int table_sizes[] = {
58922 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
58923 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
58924 + 4194301, 8388593, 16777213, 33554393, 67108859
58925 + };
58926 + void *newtable = NULL;
58927 + unsigned int pwr = 0;
58928 +
58929 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
58930 + table_sizes[pwr] <= *len)
58931 + pwr++;
58932 +
58933 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
58934 + return newtable;
58935 +
58936 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
58937 + newtable =
58938 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
58939 + else
58940 + newtable = vmalloc(table_sizes[pwr] * elementsize);
58941 +
58942 + *len = table_sizes[pwr];
58943 +
58944 + return newtable;
58945 +}
58946 +
58947 +static int
58948 +init_variables(const struct gr_arg *arg)
58949 +{
58950 + struct task_struct *reaper = init_pid_ns.child_reaper;
58951 + unsigned int stacksize;
58952 +
58953 + subj_map_set.s_size = arg->role_db.num_subjects;
58954 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
58955 + name_set.n_size = arg->role_db.num_objects;
58956 + inodev_set.i_size = arg->role_db.num_objects;
58957 +
58958 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
58959 + !name_set.n_size || !inodev_set.i_size)
58960 + return 1;
58961 +
58962 + if (!gr_init_uidset())
58963 + return 1;
58964 +
58965 + /* set up the stack that holds allocation info */
58966 +
58967 + stacksize = arg->role_db.num_pointers + 5;
58968 +
58969 + if (!acl_alloc_stack_init(stacksize))
58970 + return 1;
58971 +
58972 + /* grab reference for the real root dentry and vfsmount */
58973 + get_fs_root(reaper->fs, &real_root);
58974 +
58975 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
58976 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
58977 +#endif
58978 +
58979 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
58980 + if (fakefs_obj_rw == NULL)
58981 + return 1;
58982 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
58983 +
58984 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
58985 + if (fakefs_obj_rwx == NULL)
58986 + return 1;
58987 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
58988 +
58989 + subj_map_set.s_hash =
58990 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
58991 + acl_role_set.r_hash =
58992 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
58993 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
58994 + inodev_set.i_hash =
58995 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
58996 +
58997 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
58998 + !name_set.n_hash || !inodev_set.i_hash)
58999 + return 1;
59000 +
59001 + memset(subj_map_set.s_hash, 0,
59002 + sizeof(struct subject_map *) * subj_map_set.s_size);
59003 + memset(acl_role_set.r_hash, 0,
59004 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59005 + memset(name_set.n_hash, 0,
59006 + sizeof (struct name_entry *) * name_set.n_size);
59007 + memset(inodev_set.i_hash, 0,
59008 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59009 +
59010 + return 0;
59011 +}
59012 +
59013 +/* free information not needed after startup
59014 + currently contains user->kernel pointer mappings for subjects
59015 +*/
59016 +
59017 +static void
59018 +free_init_variables(void)
59019 +{
59020 + __u32 i;
59021 +
59022 + if (subj_map_set.s_hash) {
59023 + for (i = 0; i < subj_map_set.s_size; i++) {
59024 + if (subj_map_set.s_hash[i]) {
59025 + kfree(subj_map_set.s_hash[i]);
59026 + subj_map_set.s_hash[i] = NULL;
59027 + }
59028 + }
59029 +
59030 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59031 + PAGE_SIZE)
59032 + kfree(subj_map_set.s_hash);
59033 + else
59034 + vfree(subj_map_set.s_hash);
59035 + }
59036 +
59037 + return;
59038 +}
59039 +
59040 +static void
59041 +free_variables(void)
59042 +{
59043 + struct acl_subject_label *s;
59044 + struct acl_role_label *r;
59045 + struct task_struct *task, *task2;
59046 + unsigned int x;
59047 +
59048 + gr_clear_learn_entries();
59049 +
59050 + read_lock(&tasklist_lock);
59051 + do_each_thread(task2, task) {
59052 + task->acl_sp_role = 0;
59053 + task->acl_role_id = 0;
59054 + task->acl = NULL;
59055 + task->role = NULL;
59056 + } while_each_thread(task2, task);
59057 + read_unlock(&tasklist_lock);
59058 +
59059 + /* release the reference to the real root dentry and vfsmount */
59060 + path_put(&real_root);
59061 + memset(&real_root, 0, sizeof(real_root));
59062 +
59063 + /* free all object hash tables */
59064 +
59065 + FOR_EACH_ROLE_START(r)
59066 + if (r->subj_hash == NULL)
59067 + goto next_role;
59068 + FOR_EACH_SUBJECT_START(r, s, x)
59069 + if (s->obj_hash == NULL)
59070 + break;
59071 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59072 + kfree(s->obj_hash);
59073 + else
59074 + vfree(s->obj_hash);
59075 + FOR_EACH_SUBJECT_END(s, x)
59076 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59077 + if (s->obj_hash == NULL)
59078 + break;
59079 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59080 + kfree(s->obj_hash);
59081 + else
59082 + vfree(s->obj_hash);
59083 + FOR_EACH_NESTED_SUBJECT_END(s)
59084 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59085 + kfree(r->subj_hash);
59086 + else
59087 + vfree(r->subj_hash);
59088 + r->subj_hash = NULL;
59089 +next_role:
59090 + FOR_EACH_ROLE_END(r)
59091 +
59092 + acl_free_all();
59093 +
59094 + if (acl_role_set.r_hash) {
59095 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59096 + PAGE_SIZE)
59097 + kfree(acl_role_set.r_hash);
59098 + else
59099 + vfree(acl_role_set.r_hash);
59100 + }
59101 + if (name_set.n_hash) {
59102 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59103 + PAGE_SIZE)
59104 + kfree(name_set.n_hash);
59105 + else
59106 + vfree(name_set.n_hash);
59107 + }
59108 +
59109 + if (inodev_set.i_hash) {
59110 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59111 + PAGE_SIZE)
59112 + kfree(inodev_set.i_hash);
59113 + else
59114 + vfree(inodev_set.i_hash);
59115 + }
59116 +
59117 + gr_free_uidset();
59118 +
59119 + memset(&name_set, 0, sizeof (struct name_db));
59120 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59121 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59122 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59123 +
59124 + default_role = NULL;
59125 + kernel_role = NULL;
59126 + role_list = NULL;
59127 +
59128 + return;
59129 +}
59130 +
59131 +static __u32
59132 +count_user_objs(struct acl_object_label *userp)
59133 +{
59134 + struct acl_object_label o_tmp;
59135 + __u32 num = 0;
59136 +
59137 + while (userp) {
59138 + if (copy_from_user(&o_tmp, userp,
59139 + sizeof (struct acl_object_label)))
59140 + break;
59141 +
59142 + userp = o_tmp.prev;
59143 + num++;
59144 + }
59145 +
59146 + return num;
59147 +}
59148 +
59149 +static struct acl_subject_label *
59150 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59151 +
59152 +static int
59153 +copy_user_glob(struct acl_object_label *obj)
59154 +{
59155 + struct acl_object_label *g_tmp, **guser;
59156 + unsigned int len;
59157 + char *tmp;
59158 +
59159 + if (obj->globbed == NULL)
59160 + return 0;
59161 +
59162 + guser = &obj->globbed;
59163 + while (*guser) {
59164 + g_tmp = (struct acl_object_label *)
59165 + acl_alloc(sizeof (struct acl_object_label));
59166 + if (g_tmp == NULL)
59167 + return -ENOMEM;
59168 +
59169 + if (copy_from_user(g_tmp, *guser,
59170 + sizeof (struct acl_object_label)))
59171 + return -EFAULT;
59172 +
59173 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59174 +
59175 + if (!len || len >= PATH_MAX)
59176 + return -EINVAL;
59177 +
59178 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59179 + return -ENOMEM;
59180 +
59181 + if (copy_from_user(tmp, g_tmp->filename, len))
59182 + return -EFAULT;
59183 + tmp[len-1] = '\0';
59184 + g_tmp->filename = tmp;
59185 +
59186 + *guser = g_tmp;
59187 + guser = &(g_tmp->next);
59188 + }
59189 +
59190 + return 0;
59191 +}
59192 +
59193 +static int
59194 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59195 + struct acl_role_label *role)
59196 +{
59197 + struct acl_object_label *o_tmp;
59198 + unsigned int len;
59199 + int ret;
59200 + char *tmp;
59201 +
59202 + while (userp) {
59203 + if ((o_tmp = (struct acl_object_label *)
59204 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59205 + return -ENOMEM;
59206 +
59207 + if (copy_from_user(o_tmp, userp,
59208 + sizeof (struct acl_object_label)))
59209 + return -EFAULT;
59210 +
59211 + userp = o_tmp->prev;
59212 +
59213 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59214 +
59215 + if (!len || len >= PATH_MAX)
59216 + return -EINVAL;
59217 +
59218 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59219 + return -ENOMEM;
59220 +
59221 + if (copy_from_user(tmp, o_tmp->filename, len))
59222 + return -EFAULT;
59223 + tmp[len-1] = '\0';
59224 + o_tmp->filename = tmp;
59225 +
59226 + insert_acl_obj_label(o_tmp, subj);
59227 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59228 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59229 + return -ENOMEM;
59230 +
59231 + ret = copy_user_glob(o_tmp);
59232 + if (ret)
59233 + return ret;
59234 +
59235 + if (o_tmp->nested) {
59236 + int already_copied;
59237 +
59238 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59239 + if (IS_ERR(o_tmp->nested))
59240 + return PTR_ERR(o_tmp->nested);
59241 +
59242 + /* insert into nested subject list if we haven't copied this one yet
59243 + to prevent duplicate entries */
59244 + if (!already_copied) {
59245 + o_tmp->nested->next = role->hash->first;
59246 + role->hash->first = o_tmp->nested;
59247 + }
59248 + }
59249 + }
59250 +
59251 + return 0;
59252 +}
59253 +
59254 +static __u32
59255 +count_user_subjs(struct acl_subject_label *userp)
59256 +{
59257 + struct acl_subject_label s_tmp;
59258 + __u32 num = 0;
59259 +
59260 + while (userp) {
59261 + if (copy_from_user(&s_tmp, userp,
59262 + sizeof (struct acl_subject_label)))
59263 + break;
59264 +
59265 + userp = s_tmp.prev;
59266 + }
59267 +
59268 + return num;
59269 +}
59270 +
59271 +static int
59272 +copy_user_allowedips(struct acl_role_label *rolep)
59273 +{
59274 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59275 +
59276 + ruserip = rolep->allowed_ips;
59277 +
59278 + while (ruserip) {
59279 + rlast = rtmp;
59280 +
59281 + if ((rtmp = (struct role_allowed_ip *)
59282 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59283 + return -ENOMEM;
59284 +
59285 + if (copy_from_user(rtmp, ruserip,
59286 + sizeof (struct role_allowed_ip)))
59287 + return -EFAULT;
59288 +
59289 + ruserip = rtmp->prev;
59290 +
59291 + if (!rlast) {
59292 + rtmp->prev = NULL;
59293 + rolep->allowed_ips = rtmp;
59294 + } else {
59295 + rlast->next = rtmp;
59296 + rtmp->prev = rlast;
59297 + }
59298 +
59299 + if (!ruserip)
59300 + rtmp->next = NULL;
59301 + }
59302 +
59303 + return 0;
59304 +}
59305 +
59306 +static int
59307 +copy_user_transitions(struct acl_role_label *rolep)
59308 +{
59309 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59310 +
59311 + unsigned int len;
59312 + char *tmp;
59313 +
59314 + rusertp = rolep->transitions;
59315 +
59316 + while (rusertp) {
59317 + rlast = rtmp;
59318 +
59319 + if ((rtmp = (struct role_transition *)
59320 + acl_alloc(sizeof (struct role_transition))) == NULL)
59321 + return -ENOMEM;
59322 +
59323 + if (copy_from_user(rtmp, rusertp,
59324 + sizeof (struct role_transition)))
59325 + return -EFAULT;
59326 +
59327 + rusertp = rtmp->prev;
59328 +
59329 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59330 +
59331 + if (!len || len >= GR_SPROLE_LEN)
59332 + return -EINVAL;
59333 +
59334 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59335 + return -ENOMEM;
59336 +
59337 + if (copy_from_user(tmp, rtmp->rolename, len))
59338 + return -EFAULT;
59339 + tmp[len-1] = '\0';
59340 + rtmp->rolename = tmp;
59341 +
59342 + if (!rlast) {
59343 + rtmp->prev = NULL;
59344 + rolep->transitions = rtmp;
59345 + } else {
59346 + rlast->next = rtmp;
59347 + rtmp->prev = rlast;
59348 + }
59349 +
59350 + if (!rusertp)
59351 + rtmp->next = NULL;
59352 + }
59353 +
59354 + return 0;
59355 +}
59356 +
59357 +static struct acl_subject_label *
59358 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59359 +{
59360 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59361 + unsigned int len;
59362 + char *tmp;
59363 + __u32 num_objs;
59364 + struct acl_ip_label **i_tmp, *i_utmp2;
59365 + struct gr_hash_struct ghash;
59366 + struct subject_map *subjmap;
59367 + unsigned int i_num;
59368 + int err;
59369 +
59370 + if (already_copied != NULL)
59371 + *already_copied = 0;
59372 +
59373 + s_tmp = lookup_subject_map(userp);
59374 +
59375 + /* we've already copied this subject into the kernel, just return
59376 + the reference to it, and don't copy it over again
59377 + */
59378 + if (s_tmp) {
59379 + if (already_copied != NULL)
59380 + *already_copied = 1;
59381 + return(s_tmp);
59382 + }
59383 +
59384 + if ((s_tmp = (struct acl_subject_label *)
59385 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59386 + return ERR_PTR(-ENOMEM);
59387 +
59388 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59389 + if (subjmap == NULL)
59390 + return ERR_PTR(-ENOMEM);
59391 +
59392 + subjmap->user = userp;
59393 + subjmap->kernel = s_tmp;
59394 + insert_subj_map_entry(subjmap);
59395 +
59396 + if (copy_from_user(s_tmp, userp,
59397 + sizeof (struct acl_subject_label)))
59398 + return ERR_PTR(-EFAULT);
59399 +
59400 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59401 +
59402 + if (!len || len >= PATH_MAX)
59403 + return ERR_PTR(-EINVAL);
59404 +
59405 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59406 + return ERR_PTR(-ENOMEM);
59407 +
59408 + if (copy_from_user(tmp, s_tmp->filename, len))
59409 + return ERR_PTR(-EFAULT);
59410 + tmp[len-1] = '\0';
59411 + s_tmp->filename = tmp;
59412 +
59413 + if (!strcmp(s_tmp->filename, "/"))
59414 + role->root_label = s_tmp;
59415 +
59416 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59417 + return ERR_PTR(-EFAULT);
59418 +
59419 + /* copy user and group transition tables */
59420 +
59421 + if (s_tmp->user_trans_num) {
59422 + uid_t *uidlist;
59423 +
59424 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59425 + if (uidlist == NULL)
59426 + return ERR_PTR(-ENOMEM);
59427 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59428 + return ERR_PTR(-EFAULT);
59429 +
59430 + s_tmp->user_transitions = uidlist;
59431 + }
59432 +
59433 + if (s_tmp->group_trans_num) {
59434 + gid_t *gidlist;
59435 +
59436 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59437 + if (gidlist == NULL)
59438 + return ERR_PTR(-ENOMEM);
59439 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59440 + return ERR_PTR(-EFAULT);
59441 +
59442 + s_tmp->group_transitions = gidlist;
59443 + }
59444 +
59445 + /* set up object hash table */
59446 + num_objs = count_user_objs(ghash.first);
59447 +
59448 + s_tmp->obj_hash_size = num_objs;
59449 + s_tmp->obj_hash =
59450 + (struct acl_object_label **)
59451 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59452 +
59453 + if (!s_tmp->obj_hash)
59454 + return ERR_PTR(-ENOMEM);
59455 +
59456 + memset(s_tmp->obj_hash, 0,
59457 + s_tmp->obj_hash_size *
59458 + sizeof (struct acl_object_label *));
59459 +
59460 + /* add in objects */
59461 + err = copy_user_objs(ghash.first, s_tmp, role);
59462 +
59463 + if (err)
59464 + return ERR_PTR(err);
59465 +
59466 + /* set pointer for parent subject */
59467 + if (s_tmp->parent_subject) {
59468 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59469 +
59470 + if (IS_ERR(s_tmp2))
59471 + return s_tmp2;
59472 +
59473 + s_tmp->parent_subject = s_tmp2;
59474 + }
59475 +
59476 + /* add in ip acls */
59477 +
59478 + if (!s_tmp->ip_num) {
59479 + s_tmp->ips = NULL;
59480 + goto insert;
59481 + }
59482 +
59483 + i_tmp =
59484 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59485 + sizeof (struct acl_ip_label *));
59486 +
59487 + if (!i_tmp)
59488 + return ERR_PTR(-ENOMEM);
59489 +
59490 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59491 + *(i_tmp + i_num) =
59492 + (struct acl_ip_label *)
59493 + acl_alloc(sizeof (struct acl_ip_label));
59494 + if (!*(i_tmp + i_num))
59495 + return ERR_PTR(-ENOMEM);
59496 +
59497 + if (copy_from_user
59498 + (&i_utmp2, s_tmp->ips + i_num,
59499 + sizeof (struct acl_ip_label *)))
59500 + return ERR_PTR(-EFAULT);
59501 +
59502 + if (copy_from_user
59503 + (*(i_tmp + i_num), i_utmp2,
59504 + sizeof (struct acl_ip_label)))
59505 + return ERR_PTR(-EFAULT);
59506 +
59507 + if ((*(i_tmp + i_num))->iface == NULL)
59508 + continue;
59509 +
59510 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59511 + if (!len || len >= IFNAMSIZ)
59512 + return ERR_PTR(-EINVAL);
59513 + tmp = acl_alloc(len);
59514 + if (tmp == NULL)
59515 + return ERR_PTR(-ENOMEM);
59516 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59517 + return ERR_PTR(-EFAULT);
59518 + (*(i_tmp + i_num))->iface = tmp;
59519 + }
59520 +
59521 + s_tmp->ips = i_tmp;
59522 +
59523 +insert:
59524 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59525 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59526 + return ERR_PTR(-ENOMEM);
59527 +
59528 + return s_tmp;
59529 +}
59530 +
59531 +static int
59532 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59533 +{
59534 + struct acl_subject_label s_pre;
59535 + struct acl_subject_label * ret;
59536 + int err;
59537 +
59538 + while (userp) {
59539 + if (copy_from_user(&s_pre, userp,
59540 + sizeof (struct acl_subject_label)))
59541 + return -EFAULT;
59542 +
59543 + ret = do_copy_user_subj(userp, role, NULL);
59544 +
59545 + err = PTR_ERR(ret);
59546 + if (IS_ERR(ret))
59547 + return err;
59548 +
59549 + insert_acl_subj_label(ret, role);
59550 +
59551 + userp = s_pre.prev;
59552 + }
59553 +
59554 + return 0;
59555 +}
59556 +
59557 +static int
59558 +copy_user_acl(struct gr_arg *arg)
59559 +{
59560 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59561 + struct acl_subject_label *subj_list;
59562 + struct sprole_pw *sptmp;
59563 + struct gr_hash_struct *ghash;
59564 + uid_t *domainlist;
59565 + unsigned int r_num;
59566 + unsigned int len;
59567 + char *tmp;
59568 + int err = 0;
59569 + __u16 i;
59570 + __u32 num_subjs;
59571 +
59572 + /* we need a default and kernel role */
59573 + if (arg->role_db.num_roles < 2)
59574 + return -EINVAL;
59575 +
59576 + /* copy special role authentication info from userspace */
59577 +
59578 + num_sprole_pws = arg->num_sprole_pws;
59579 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59580 +
59581 + if (!acl_special_roles && num_sprole_pws)
59582 + return -ENOMEM;
59583 +
59584 + for (i = 0; i < num_sprole_pws; i++) {
59585 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59586 + if (!sptmp)
59587 + return -ENOMEM;
59588 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59589 + sizeof (struct sprole_pw)))
59590 + return -EFAULT;
59591 +
59592 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59593 +
59594 + if (!len || len >= GR_SPROLE_LEN)
59595 + return -EINVAL;
59596 +
59597 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59598 + return -ENOMEM;
59599 +
59600 + if (copy_from_user(tmp, sptmp->rolename, len))
59601 + return -EFAULT;
59602 +
59603 + tmp[len-1] = '\0';
59604 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59605 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59606 +#endif
59607 + sptmp->rolename = tmp;
59608 + acl_special_roles[i] = sptmp;
59609 + }
59610 +
59611 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59612 +
59613 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59614 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59615 +
59616 + if (!r_tmp)
59617 + return -ENOMEM;
59618 +
59619 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59620 + sizeof (struct acl_role_label *)))
59621 + return -EFAULT;
59622 +
59623 + if (copy_from_user(r_tmp, r_utmp2,
59624 + sizeof (struct acl_role_label)))
59625 + return -EFAULT;
59626 +
59627 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59628 +
59629 + if (!len || len >= PATH_MAX)
59630 + return -EINVAL;
59631 +
59632 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59633 + return -ENOMEM;
59634 +
59635 + if (copy_from_user(tmp, r_tmp->rolename, len))
59636 + return -EFAULT;
59637 +
59638 + tmp[len-1] = '\0';
59639 + r_tmp->rolename = tmp;
59640 +
59641 + if (!strcmp(r_tmp->rolename, "default")
59642 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59643 + default_role = r_tmp;
59644 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59645 + kernel_role = r_tmp;
59646 + }
59647 +
59648 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59649 + return -ENOMEM;
59650 +
59651 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59652 + return -EFAULT;
59653 +
59654 + r_tmp->hash = ghash;
59655 +
59656 + num_subjs = count_user_subjs(r_tmp->hash->first);
59657 +
59658 + r_tmp->subj_hash_size = num_subjs;
59659 + r_tmp->subj_hash =
59660 + (struct acl_subject_label **)
59661 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59662 +
59663 + if (!r_tmp->subj_hash)
59664 + return -ENOMEM;
59665 +
59666 + err = copy_user_allowedips(r_tmp);
59667 + if (err)
59668 + return err;
59669 +
59670 + /* copy domain info */
59671 + if (r_tmp->domain_children != NULL) {
59672 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59673 + if (domainlist == NULL)
59674 + return -ENOMEM;
59675 +
59676 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59677 + return -EFAULT;
59678 +
59679 + r_tmp->domain_children = domainlist;
59680 + }
59681 +
59682 + err = copy_user_transitions(r_tmp);
59683 + if (err)
59684 + return err;
59685 +
59686 + memset(r_tmp->subj_hash, 0,
59687 + r_tmp->subj_hash_size *
59688 + sizeof (struct acl_subject_label *));
59689 +
59690 + /* acquire the list of subjects, then NULL out
59691 + the list prior to parsing the subjects for this role,
59692 + as during this parsing the list is replaced with a list
59693 + of *nested* subjects for the role
59694 + */
59695 + subj_list = r_tmp->hash->first;
59696 +
59697 + /* set nested subject list to null */
59698 + r_tmp->hash->first = NULL;
59699 +
59700 + err = copy_user_subjs(subj_list, r_tmp);
59701 +
59702 + if (err)
59703 + return err;
59704 +
59705 + insert_acl_role_label(r_tmp);
59706 + }
59707 +
59708 + if (default_role == NULL || kernel_role == NULL)
59709 + return -EINVAL;
59710 +
59711 + return err;
59712 +}
59713 +
59714 +static int
59715 +gracl_init(struct gr_arg *args)
59716 +{
59717 + int error = 0;
59718 +
59719 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59720 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59721 +
59722 + if (init_variables(args)) {
59723 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59724 + error = -ENOMEM;
59725 + free_variables();
59726 + goto out;
59727 + }
59728 +
59729 + error = copy_user_acl(args);
59730 + free_init_variables();
59731 + if (error) {
59732 + free_variables();
59733 + goto out;
59734 + }
59735 +
59736 + if ((error = gr_set_acls(0))) {
59737 + free_variables();
59738 + goto out;
59739 + }
59740 +
59741 + pax_open_kernel();
59742 + gr_status |= GR_READY;
59743 + pax_close_kernel();
59744 +
59745 + out:
59746 + return error;
59747 +}
59748 +
59749 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59750 +
59751 +static int
59752 +glob_match(const char *p, const char *n)
59753 +{
59754 + char c;
59755 +
59756 + while ((c = *p++) != '\0') {
59757 + switch (c) {
59758 + case '?':
59759 + if (*n == '\0')
59760 + return 1;
59761 + else if (*n == '/')
59762 + return 1;
59763 + break;
59764 + case '\\':
59765 + if (*n != c)
59766 + return 1;
59767 + break;
59768 + case '*':
59769 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59770 + if (*n == '/')
59771 + return 1;
59772 + else if (c == '?') {
59773 + if (*n == '\0')
59774 + return 1;
59775 + else
59776 + ++n;
59777 + }
59778 + }
59779 + if (c == '\0') {
59780 + return 0;
59781 + } else {
59782 + const char *endp;
59783 +
59784 + if ((endp = strchr(n, '/')) == NULL)
59785 + endp = n + strlen(n);
59786 +
59787 + if (c == '[') {
59788 + for (--p; n < endp; ++n)
59789 + if (!glob_match(p, n))
59790 + return 0;
59791 + } else if (c == '/') {
59792 + while (*n != '\0' && *n != '/')
59793 + ++n;
59794 + if (*n == '/' && !glob_match(p, n + 1))
59795 + return 0;
59796 + } else {
59797 + for (--p; n < endp; ++n)
59798 + if (*n == c && !glob_match(p, n))
59799 + return 0;
59800 + }
59801 +
59802 + return 1;
59803 + }
59804 + case '[':
59805 + {
59806 + int not;
59807 + char cold;
59808 +
59809 + if (*n == '\0' || *n == '/')
59810 + return 1;
59811 +
59812 + not = (*p == '!' || *p == '^');
59813 + if (not)
59814 + ++p;
59815 +
59816 + c = *p++;
59817 + for (;;) {
59818 + unsigned char fn = (unsigned char)*n;
59819 +
59820 + if (c == '\0')
59821 + return 1;
59822 + else {
59823 + if (c == fn)
59824 + goto matched;
59825 + cold = c;
59826 + c = *p++;
59827 +
59828 + if (c == '-' && *p != ']') {
59829 + unsigned char cend = *p++;
59830 +
59831 + if (cend == '\0')
59832 + return 1;
59833 +
59834 + if (cold <= fn && fn <= cend)
59835 + goto matched;
59836 +
59837 + c = *p++;
59838 + }
59839 + }
59840 +
59841 + if (c == ']')
59842 + break;
59843 + }
59844 + if (!not)
59845 + return 1;
59846 + break;
59847 + matched:
59848 + while (c != ']') {
59849 + if (c == '\0')
59850 + return 1;
59851 +
59852 + c = *p++;
59853 + }
59854 + if (not)
59855 + return 1;
59856 + }
59857 + break;
59858 + default:
59859 + if (c != *n)
59860 + return 1;
59861 + }
59862 +
59863 + ++n;
59864 + }
59865 +
59866 + if (*n == '\0')
59867 + return 0;
59868 +
59869 + if (*n == '/')
59870 + return 0;
59871 +
59872 + return 1;
59873 +}
59874 +
59875 +static struct acl_object_label *
59876 +chk_glob_label(struct acl_object_label *globbed,
59877 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59878 +{
59879 + struct acl_object_label *tmp;
59880 +
59881 + if (*path == NULL)
59882 + *path = gr_to_filename_nolock(dentry, mnt);
59883 +
59884 + tmp = globbed;
59885 +
59886 + while (tmp) {
59887 + if (!glob_match(tmp->filename, *path))
59888 + return tmp;
59889 + tmp = tmp->next;
59890 + }
59891 +
59892 + return NULL;
59893 +}
59894 +
59895 +static struct acl_object_label *
59896 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59897 + const ino_t curr_ino, const dev_t curr_dev,
59898 + const struct acl_subject_label *subj, char **path, const int checkglob)
59899 +{
59900 + struct acl_subject_label *tmpsubj;
59901 + struct acl_object_label *retval;
59902 + struct acl_object_label *retval2;
59903 +
59904 + tmpsubj = (struct acl_subject_label *) subj;
59905 + read_lock(&gr_inode_lock);
59906 + do {
59907 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
59908 + if (retval) {
59909 + if (checkglob && retval->globbed) {
59910 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
59911 + if (retval2)
59912 + retval = retval2;
59913 + }
59914 + break;
59915 + }
59916 + } while ((tmpsubj = tmpsubj->parent_subject));
59917 + read_unlock(&gr_inode_lock);
59918 +
59919 + return retval;
59920 +}
59921 +
59922 +static __inline__ struct acl_object_label *
59923 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59924 + struct dentry *curr_dentry,
59925 + const struct acl_subject_label *subj, char **path, const int checkglob)
59926 +{
59927 + int newglob = checkglob;
59928 + ino_t inode;
59929 + dev_t device;
59930 +
59931 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
59932 + as we don't want a / * rule to match instead of the / object
59933 + don't do this for create lookups that call this function though, since they're looking up
59934 + on the parent and thus need globbing checks on all paths
59935 + */
59936 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
59937 + newglob = GR_NO_GLOB;
59938 +
59939 + spin_lock(&curr_dentry->d_lock);
59940 + inode = curr_dentry->d_inode->i_ino;
59941 + device = __get_dev(curr_dentry);
59942 + spin_unlock(&curr_dentry->d_lock);
59943 +
59944 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
59945 +}
59946 +
59947 +#ifdef CONFIG_HUGETLBFS
59948 +static inline bool
59949 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
59950 +{
59951 + int i;
59952 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
59953 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
59954 + return true;
59955 + }
59956 +
59957 + return false;
59958 +}
59959 +#endif
59960 +
59961 +static struct acl_object_label *
59962 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
59963 + const struct acl_subject_label *subj, char *path, const int checkglob)
59964 +{
59965 + struct dentry *dentry = (struct dentry *) l_dentry;
59966 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
59967 + struct mount *real_mnt = real_mount(mnt);
59968 + struct acl_object_label *retval;
59969 + struct dentry *parent;
59970 +
59971 + br_read_lock(&vfsmount_lock);
59972 + write_seqlock(&rename_lock);
59973 +
59974 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
59975 +#ifdef CONFIG_NET
59976 + mnt == sock_mnt ||
59977 +#endif
59978 +#ifdef CONFIG_HUGETLBFS
59979 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
59980 +#endif
59981 + /* ignore Eric Biederman */
59982 + IS_PRIVATE(l_dentry->d_inode))) {
59983 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
59984 + goto out;
59985 + }
59986 +
59987 + for (;;) {
59988 + if (dentry == real_root.dentry && mnt == real_root.mnt)
59989 + break;
59990 +
59991 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
59992 + if (!mnt_has_parent(real_mnt))
59993 + break;
59994 +
59995 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
59996 + if (retval != NULL)
59997 + goto out;
59998 +
59999 + dentry = real_mnt->mnt_mountpoint;
60000 + real_mnt = real_mnt->mnt_parent;
60001 + mnt = &real_mnt->mnt;
60002 + continue;
60003 + }
60004 +
60005 + parent = dentry->d_parent;
60006 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60007 + if (retval != NULL)
60008 + goto out;
60009 +
60010 + dentry = parent;
60011 + }
60012 +
60013 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60014 +
60015 + /* real_root is pinned so we don't have to hold a reference */
60016 + if (retval == NULL)
60017 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60018 +out:
60019 + write_sequnlock(&rename_lock);
60020 + br_read_unlock(&vfsmount_lock);
60021 +
60022 + BUG_ON(retval == NULL);
60023 +
60024 + return retval;
60025 +}
60026 +
60027 +static __inline__ struct acl_object_label *
60028 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60029 + const struct acl_subject_label *subj)
60030 +{
60031 + char *path = NULL;
60032 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60033 +}
60034 +
60035 +static __inline__ struct acl_object_label *
60036 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60037 + const struct acl_subject_label *subj)
60038 +{
60039 + char *path = NULL;
60040 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60041 +}
60042 +
60043 +static __inline__ struct acl_object_label *
60044 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60045 + const struct acl_subject_label *subj, char *path)
60046 +{
60047 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60048 +}
60049 +
60050 +static struct acl_subject_label *
60051 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60052 + const struct acl_role_label *role)
60053 +{
60054 + struct dentry *dentry = (struct dentry *) l_dentry;
60055 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60056 + struct mount *real_mnt = real_mount(mnt);
60057 + struct acl_subject_label *retval;
60058 + struct dentry *parent;
60059 +
60060 + br_read_lock(&vfsmount_lock);
60061 + write_seqlock(&rename_lock);
60062 +
60063 + for (;;) {
60064 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60065 + break;
60066 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60067 + if (!mnt_has_parent(real_mnt))
60068 + break;
60069 +
60070 + spin_lock(&dentry->d_lock);
60071 + read_lock(&gr_inode_lock);
60072 + retval =
60073 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60074 + __get_dev(dentry), role);
60075 + read_unlock(&gr_inode_lock);
60076 + spin_unlock(&dentry->d_lock);
60077 + if (retval != NULL)
60078 + goto out;
60079 +
60080 + dentry = real_mnt->mnt_mountpoint;
60081 + real_mnt = real_mnt->mnt_parent;
60082 + mnt = &real_mnt->mnt;
60083 + continue;
60084 + }
60085 +
60086 + spin_lock(&dentry->d_lock);
60087 + read_lock(&gr_inode_lock);
60088 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60089 + __get_dev(dentry), role);
60090 + read_unlock(&gr_inode_lock);
60091 + parent = dentry->d_parent;
60092 + spin_unlock(&dentry->d_lock);
60093 +
60094 + if (retval != NULL)
60095 + goto out;
60096 +
60097 + dentry = parent;
60098 + }
60099 +
60100 + spin_lock(&dentry->d_lock);
60101 + read_lock(&gr_inode_lock);
60102 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60103 + __get_dev(dentry), role);
60104 + read_unlock(&gr_inode_lock);
60105 + spin_unlock(&dentry->d_lock);
60106 +
60107 + if (unlikely(retval == NULL)) {
60108 + /* real_root is pinned, we don't need to hold a reference */
60109 + read_lock(&gr_inode_lock);
60110 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60111 + __get_dev(real_root.dentry), role);
60112 + read_unlock(&gr_inode_lock);
60113 + }
60114 +out:
60115 + write_sequnlock(&rename_lock);
60116 + br_read_unlock(&vfsmount_lock);
60117 +
60118 + BUG_ON(retval == NULL);
60119 +
60120 + return retval;
60121 +}
60122 +
60123 +static void
60124 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60125 +{
60126 + struct task_struct *task = current;
60127 + const struct cred *cred = current_cred();
60128 +
60129 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60130 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60131 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60132 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60133 +
60134 + return;
60135 +}
60136 +
60137 +static void
60138 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60139 +{
60140 + struct task_struct *task = current;
60141 + const struct cred *cred = current_cred();
60142 +
60143 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60144 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60145 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60146 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60147 +
60148 + return;
60149 +}
60150 +
60151 +static void
60152 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60153 +{
60154 + struct task_struct *task = current;
60155 + const struct cred *cred = current_cred();
60156 +
60157 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60158 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60159 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60160 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60161 +
60162 + return;
60163 +}
60164 +
60165 +__u32
60166 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60167 + const struct vfsmount * mnt)
60168 +{
60169 + __u32 retval = mode;
60170 + struct acl_subject_label *curracl;
60171 + struct acl_object_label *currobj;
60172 +
60173 + if (unlikely(!(gr_status & GR_READY)))
60174 + return (mode & ~GR_AUDITS);
60175 +
60176 + curracl = current->acl;
60177 +
60178 + currobj = chk_obj_label(dentry, mnt, curracl);
60179 + retval = currobj->mode & mode;
60180 +
60181 + /* if we're opening a specified transfer file for writing
60182 + (e.g. /dev/initctl), then transfer our role to init
60183 + */
60184 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60185 + current->role->roletype & GR_ROLE_PERSIST)) {
60186 + struct task_struct *task = init_pid_ns.child_reaper;
60187 +
60188 + if (task->role != current->role) {
60189 + task->acl_sp_role = 0;
60190 + task->acl_role_id = current->acl_role_id;
60191 + task->role = current->role;
60192 + rcu_read_lock();
60193 + read_lock(&grsec_exec_file_lock);
60194 + gr_apply_subject_to_task(task);
60195 + read_unlock(&grsec_exec_file_lock);
60196 + rcu_read_unlock();
60197 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60198 + }
60199 + }
60200 +
60201 + if (unlikely
60202 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60203 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60204 + __u32 new_mode = mode;
60205 +
60206 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60207 +
60208 + retval = new_mode;
60209 +
60210 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60211 + new_mode |= GR_INHERIT;
60212 +
60213 + if (!(mode & GR_NOLEARN))
60214 + gr_log_learn(dentry, mnt, new_mode);
60215 + }
60216 +
60217 + return retval;
60218 +}
60219 +
60220 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60221 + const struct dentry *parent,
60222 + const struct vfsmount *mnt)
60223 +{
60224 + struct name_entry *match;
60225 + struct acl_object_label *matchpo;
60226 + struct acl_subject_label *curracl;
60227 + char *path;
60228 +
60229 + if (unlikely(!(gr_status & GR_READY)))
60230 + return NULL;
60231 +
60232 + preempt_disable();
60233 + path = gr_to_filename_rbac(new_dentry, mnt);
60234 + match = lookup_name_entry_create(path);
60235 +
60236 + curracl = current->acl;
60237 +
60238 + if (match) {
60239 + read_lock(&gr_inode_lock);
60240 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60241 + read_unlock(&gr_inode_lock);
60242 +
60243 + if (matchpo) {
60244 + preempt_enable();
60245 + return matchpo;
60246 + }
60247 + }
60248 +
60249 + // lookup parent
60250 +
60251 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60252 +
60253 + preempt_enable();
60254 + return matchpo;
60255 +}
60256 +
60257 +__u32
60258 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60259 + const struct vfsmount * mnt, const __u32 mode)
60260 +{
60261 + struct acl_object_label *matchpo;
60262 + __u32 retval;
60263 +
60264 + if (unlikely(!(gr_status & GR_READY)))
60265 + return (mode & ~GR_AUDITS);
60266 +
60267 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60268 +
60269 + retval = matchpo->mode & mode;
60270 +
60271 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60272 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60273 + __u32 new_mode = mode;
60274 +
60275 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60276 +
60277 + gr_log_learn(new_dentry, mnt, new_mode);
60278 + return new_mode;
60279 + }
60280 +
60281 + return retval;
60282 +}
60283 +
60284 +__u32
60285 +gr_check_link(const struct dentry * new_dentry,
60286 + const struct dentry * parent_dentry,
60287 + const struct vfsmount * parent_mnt,
60288 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60289 +{
60290 + struct acl_object_label *obj;
60291 + __u32 oldmode, newmode;
60292 + __u32 needmode;
60293 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60294 + GR_DELETE | GR_INHERIT;
60295 +
60296 + if (unlikely(!(gr_status & GR_READY)))
60297 + return (GR_CREATE | GR_LINK);
60298 +
60299 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60300 + oldmode = obj->mode;
60301 +
60302 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60303 + newmode = obj->mode;
60304 +
60305 + needmode = newmode & checkmodes;
60306 +
60307 + // old name for hardlink must have at least the permissions of the new name
60308 + if ((oldmode & needmode) != needmode)
60309 + goto bad;
60310 +
60311 + // if old name had restrictions/auditing, make sure the new name does as well
60312 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60313 +
60314 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60315 + if (is_privileged_binary(old_dentry))
60316 + needmode |= GR_SETID;
60317 +
60318 + if ((newmode & needmode) != needmode)
60319 + goto bad;
60320 +
60321 + // enforce minimum permissions
60322 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60323 + return newmode;
60324 +bad:
60325 + needmode = oldmode;
60326 + if (is_privileged_binary(old_dentry))
60327 + needmode |= GR_SETID;
60328 +
60329 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60330 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60331 + return (GR_CREATE | GR_LINK);
60332 + } else if (newmode & GR_SUPPRESS)
60333 + return GR_SUPPRESS;
60334 + else
60335 + return 0;
60336 +}
60337 +
60338 +int
60339 +gr_check_hidden_task(const struct task_struct *task)
60340 +{
60341 + if (unlikely(!(gr_status & GR_READY)))
60342 + return 0;
60343 +
60344 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60345 + return 1;
60346 +
60347 + return 0;
60348 +}
60349 +
60350 +int
60351 +gr_check_protected_task(const struct task_struct *task)
60352 +{
60353 + if (unlikely(!(gr_status & GR_READY) || !task))
60354 + return 0;
60355 +
60356 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60357 + task->acl != current->acl)
60358 + return 1;
60359 +
60360 + return 0;
60361 +}
60362 +
60363 +int
60364 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60365 +{
60366 + struct task_struct *p;
60367 + int ret = 0;
60368 +
60369 + if (unlikely(!(gr_status & GR_READY) || !pid))
60370 + return ret;
60371 +
60372 + read_lock(&tasklist_lock);
60373 + do_each_pid_task(pid, type, p) {
60374 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60375 + p->acl != current->acl) {
60376 + ret = 1;
60377 + goto out;
60378 + }
60379 + } while_each_pid_task(pid, type, p);
60380 +out:
60381 + read_unlock(&tasklist_lock);
60382 +
60383 + return ret;
60384 +}
60385 +
60386 +void
60387 +gr_copy_label(struct task_struct *tsk)
60388 +{
60389 + tsk->signal->used_accept = 0;
60390 + tsk->acl_sp_role = 0;
60391 + tsk->acl_role_id = current->acl_role_id;
60392 + tsk->acl = current->acl;
60393 + tsk->role = current->role;
60394 + tsk->signal->curr_ip = current->signal->curr_ip;
60395 + tsk->signal->saved_ip = current->signal->saved_ip;
60396 + if (current->exec_file)
60397 + get_file(current->exec_file);
60398 + tsk->exec_file = current->exec_file;
60399 + tsk->is_writable = current->is_writable;
60400 + if (unlikely(current->signal->used_accept)) {
60401 + current->signal->curr_ip = 0;
60402 + current->signal->saved_ip = 0;
60403 + }
60404 +
60405 + return;
60406 +}
60407 +
60408 +static void
60409 +gr_set_proc_res(struct task_struct *task)
60410 +{
60411 + struct acl_subject_label *proc;
60412 + unsigned short i;
60413 +
60414 + proc = task->acl;
60415 +
60416 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60417 + return;
60418 +
60419 + for (i = 0; i < RLIM_NLIMITS; i++) {
60420 + if (!(proc->resmask & (1U << i)))
60421 + continue;
60422 +
60423 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60424 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60425 +
60426 + if (i == RLIMIT_CPU)
60427 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60428 + }
60429 +
60430 + return;
60431 +}
60432 +
60433 +extern int __gr_process_user_ban(struct user_struct *user);
60434 +
60435 +int
60436 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60437 +{
60438 + unsigned int i;
60439 + __u16 num;
60440 + uid_t *uidlist;
60441 + uid_t curuid;
60442 + int realok = 0;
60443 + int effectiveok = 0;
60444 + int fsok = 0;
60445 + uid_t globalreal, globaleffective, globalfs;
60446 +
60447 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
60448 + struct user_struct *user;
60449 +
60450 + if (!uid_valid(real))
60451 + goto skipit;
60452 +
60453 + /* find user based on global namespace */
60454 +
60455 + globalreal = GR_GLOBAL_UID(real);
60456 +
60457 + user = find_user(make_kuid(&init_user_ns, globalreal));
60458 + if (user == NULL)
60459 + goto skipit;
60460 +
60461 + if (__gr_process_user_ban(user)) {
60462 + /* for find_user */
60463 + free_uid(user);
60464 + return 1;
60465 + }
60466 +
60467 + /* for find_user */
60468 + free_uid(user);
60469 +
60470 +skipit:
60471 +#endif
60472 +
60473 + if (unlikely(!(gr_status & GR_READY)))
60474 + return 0;
60475 +
60476 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60477 + gr_log_learn_uid_change(real, effective, fs);
60478 +
60479 + num = current->acl->user_trans_num;
60480 + uidlist = current->acl->user_transitions;
60481 +
60482 + if (uidlist == NULL)
60483 + return 0;
60484 +
60485 + if (!uid_valid(real)) {
60486 + realok = 1;
60487 + globalreal = (uid_t)-1;
60488 + } else {
60489 + globalreal = GR_GLOBAL_UID(real);
60490 + }
60491 + if (!uid_valid(effective)) {
60492 + effectiveok = 1;
60493 + globaleffective = (uid_t)-1;
60494 + } else {
60495 + globaleffective = GR_GLOBAL_UID(effective);
60496 + }
60497 + if (!uid_valid(fs)) {
60498 + fsok = 1;
60499 + globalfs = (uid_t)-1;
60500 + } else {
60501 + globalfs = GR_GLOBAL_UID(fs);
60502 + }
60503 +
60504 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60505 + for (i = 0; i < num; i++) {
60506 + curuid = uidlist[i];
60507 + if (globalreal == curuid)
60508 + realok = 1;
60509 + if (globaleffective == curuid)
60510 + effectiveok = 1;
60511 + if (globalfs == curuid)
60512 + fsok = 1;
60513 + }
60514 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60515 + for (i = 0; i < num; i++) {
60516 + curuid = uidlist[i];
60517 + if (globalreal == curuid)
60518 + break;
60519 + if (globaleffective == curuid)
60520 + break;
60521 + if (globalfs == curuid)
60522 + break;
60523 + }
60524 + /* not in deny list */
60525 + if (i == num) {
60526 + realok = 1;
60527 + effectiveok = 1;
60528 + fsok = 1;
60529 + }
60530 + }
60531 +
60532 + if (realok && effectiveok && fsok)
60533 + return 0;
60534 + else {
60535 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60536 + return 1;
60537 + }
60538 +}
60539 +
60540 +int
60541 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60542 +{
60543 + unsigned int i;
60544 + __u16 num;
60545 + gid_t *gidlist;
60546 + gid_t curgid;
60547 + int realok = 0;
60548 + int effectiveok = 0;
60549 + int fsok = 0;
60550 + gid_t globalreal, globaleffective, globalfs;
60551 +
60552 + if (unlikely(!(gr_status & GR_READY)))
60553 + return 0;
60554 +
60555 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60556 + gr_log_learn_gid_change(real, effective, fs);
60557 +
60558 + num = current->acl->group_trans_num;
60559 + gidlist = current->acl->group_transitions;
60560 +
60561 + if (gidlist == NULL)
60562 + return 0;
60563 +
60564 + if (!gid_valid(real)) {
60565 + realok = 1;
60566 + globalreal = (gid_t)-1;
60567 + } else {
60568 + globalreal = GR_GLOBAL_GID(real);
60569 + }
60570 + if (!gid_valid(effective)) {
60571 + effectiveok = 1;
60572 + globaleffective = (gid_t)-1;
60573 + } else {
60574 + globaleffective = GR_GLOBAL_GID(effective);
60575 + }
60576 + if (!gid_valid(fs)) {
60577 + fsok = 1;
60578 + globalfs = (gid_t)-1;
60579 + } else {
60580 + globalfs = GR_GLOBAL_GID(fs);
60581 + }
60582 +
60583 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60584 + for (i = 0; i < num; i++) {
60585 + curgid = gidlist[i];
60586 + if (globalreal == curgid)
60587 + realok = 1;
60588 + if (globaleffective == curgid)
60589 + effectiveok = 1;
60590 + if (globalfs == curgid)
60591 + fsok = 1;
60592 + }
60593 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60594 + for (i = 0; i < num; i++) {
60595 + curgid = gidlist[i];
60596 + if (globalreal == curgid)
60597 + break;
60598 + if (globaleffective == curgid)
60599 + break;
60600 + if (globalfs == curgid)
60601 + break;
60602 + }
60603 + /* not in deny list */
60604 + if (i == num) {
60605 + realok = 1;
60606 + effectiveok = 1;
60607 + fsok = 1;
60608 + }
60609 + }
60610 +
60611 + if (realok && effectiveok && fsok)
60612 + return 0;
60613 + else {
60614 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60615 + return 1;
60616 + }
60617 +}
60618 +
60619 +extern int gr_acl_is_capable(const int cap);
60620 +
60621 +void
60622 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60623 +{
60624 + struct acl_role_label *role = task->role;
60625 + struct acl_subject_label *subj = NULL;
60626 + struct acl_object_label *obj;
60627 + struct file *filp;
60628 + uid_t uid;
60629 + gid_t gid;
60630 +
60631 + if (unlikely(!(gr_status & GR_READY)))
60632 + return;
60633 +
60634 + uid = GR_GLOBAL_UID(kuid);
60635 + gid = GR_GLOBAL_GID(kgid);
60636 +
60637 + filp = task->exec_file;
60638 +
60639 + /* kernel process, we'll give them the kernel role */
60640 + if (unlikely(!filp)) {
60641 + task->role = kernel_role;
60642 + task->acl = kernel_role->root_label;
60643 + return;
60644 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60645 + role = lookup_acl_role_label(task, uid, gid);
60646 +
60647 + /* don't change the role if we're not a privileged process */
60648 + if (role && task->role != role &&
60649 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60650 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60651 + return;
60652 +
60653 + /* perform subject lookup in possibly new role
60654 + we can use this result below in the case where role == task->role
60655 + */
60656 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60657 +
60658 + /* if we changed uid/gid, but result in the same role
60659 + and are using inheritance, don't lose the inherited subject
60660 + if current subject is other than what normal lookup
60661 + would result in, we arrived via inheritance, don't
60662 + lose subject
60663 + */
60664 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60665 + (subj == task->acl)))
60666 + task->acl = subj;
60667 +
60668 + task->role = role;
60669 +
60670 + task->is_writable = 0;
60671 +
60672 + /* ignore additional mmap checks for processes that are writable
60673 + by the default ACL */
60674 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60675 + if (unlikely(obj->mode & GR_WRITE))
60676 + task->is_writable = 1;
60677 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60678 + if (unlikely(obj->mode & GR_WRITE))
60679 + task->is_writable = 1;
60680 +
60681 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60682 + 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);
60683 +#endif
60684 +
60685 + gr_set_proc_res(task);
60686 +
60687 + return;
60688 +}
60689 +
60690 +int
60691 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60692 + const int unsafe_flags)
60693 +{
60694 + struct task_struct *task = current;
60695 + struct acl_subject_label *newacl;
60696 + struct acl_object_label *obj;
60697 + __u32 retmode;
60698 +
60699 + if (unlikely(!(gr_status & GR_READY)))
60700 + return 0;
60701 +
60702 + newacl = chk_subj_label(dentry, mnt, task->role);
60703 +
60704 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60705 + did an exec
60706 + */
60707 + rcu_read_lock();
60708 + read_lock(&tasklist_lock);
60709 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60710 + (task->parent->acl->mode & GR_POVERRIDE))) {
60711 + read_unlock(&tasklist_lock);
60712 + rcu_read_unlock();
60713 + goto skip_check;
60714 + }
60715 + read_unlock(&tasklist_lock);
60716 + rcu_read_unlock();
60717 +
60718 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60719 + !(task->role->roletype & GR_ROLE_GOD) &&
60720 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60721 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60722 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60723 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60724 + else
60725 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60726 + return -EACCES;
60727 + }
60728 +
60729 +skip_check:
60730 +
60731 + obj = chk_obj_label(dentry, mnt, task->acl);
60732 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60733 +
60734 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60735 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60736 + if (obj->nested)
60737 + task->acl = obj->nested;
60738 + else
60739 + task->acl = newacl;
60740 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60741 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60742 +
60743 + task->is_writable = 0;
60744 +
60745 + /* ignore additional mmap checks for processes that are writable
60746 + by the default ACL */
60747 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60748 + if (unlikely(obj->mode & GR_WRITE))
60749 + task->is_writable = 1;
60750 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60751 + if (unlikely(obj->mode & GR_WRITE))
60752 + task->is_writable = 1;
60753 +
60754 + gr_set_proc_res(task);
60755 +
60756 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60757 + 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);
60758 +#endif
60759 + return 0;
60760 +}
60761 +
60762 +/* always called with valid inodev ptr */
60763 +static void
60764 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60765 +{
60766 + struct acl_object_label *matchpo;
60767 + struct acl_subject_label *matchps;
60768 + struct acl_subject_label *subj;
60769 + struct acl_role_label *role;
60770 + unsigned int x;
60771 +
60772 + FOR_EACH_ROLE_START(role)
60773 + FOR_EACH_SUBJECT_START(role, subj, x)
60774 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60775 + matchpo->mode |= GR_DELETED;
60776 + FOR_EACH_SUBJECT_END(subj,x)
60777 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60778 + /* nested subjects aren't in the role's subj_hash table */
60779 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60780 + matchpo->mode |= GR_DELETED;
60781 + FOR_EACH_NESTED_SUBJECT_END(subj)
60782 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60783 + matchps->mode |= GR_DELETED;
60784 + FOR_EACH_ROLE_END(role)
60785 +
60786 + inodev->nentry->deleted = 1;
60787 +
60788 + return;
60789 +}
60790 +
60791 +void
60792 +gr_handle_delete(const ino_t ino, const dev_t dev)
60793 +{
60794 + struct inodev_entry *inodev;
60795 +
60796 + if (unlikely(!(gr_status & GR_READY)))
60797 + return;
60798 +
60799 + write_lock(&gr_inode_lock);
60800 + inodev = lookup_inodev_entry(ino, dev);
60801 + if (inodev != NULL)
60802 + do_handle_delete(inodev, ino, dev);
60803 + write_unlock(&gr_inode_lock);
60804 +
60805 + return;
60806 +}
60807 +
60808 +static void
60809 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60810 + const ino_t newinode, const dev_t newdevice,
60811 + struct acl_subject_label *subj)
60812 +{
60813 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60814 + struct acl_object_label *match;
60815 +
60816 + match = subj->obj_hash[index];
60817 +
60818 + while (match && (match->inode != oldinode ||
60819 + match->device != olddevice ||
60820 + !(match->mode & GR_DELETED)))
60821 + match = match->next;
60822 +
60823 + if (match && (match->inode == oldinode)
60824 + && (match->device == olddevice)
60825 + && (match->mode & GR_DELETED)) {
60826 + if (match->prev == NULL) {
60827 + subj->obj_hash[index] = match->next;
60828 + if (match->next != NULL)
60829 + match->next->prev = NULL;
60830 + } else {
60831 + match->prev->next = match->next;
60832 + if (match->next != NULL)
60833 + match->next->prev = match->prev;
60834 + }
60835 + match->prev = NULL;
60836 + match->next = NULL;
60837 + match->inode = newinode;
60838 + match->device = newdevice;
60839 + match->mode &= ~GR_DELETED;
60840 +
60841 + insert_acl_obj_label(match, subj);
60842 + }
60843 +
60844 + return;
60845 +}
60846 +
60847 +static void
60848 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60849 + const ino_t newinode, const dev_t newdevice,
60850 + struct acl_role_label *role)
60851 +{
60852 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60853 + struct acl_subject_label *match;
60854 +
60855 + match = role->subj_hash[index];
60856 +
60857 + while (match && (match->inode != oldinode ||
60858 + match->device != olddevice ||
60859 + !(match->mode & GR_DELETED)))
60860 + match = match->next;
60861 +
60862 + if (match && (match->inode == oldinode)
60863 + && (match->device == olddevice)
60864 + && (match->mode & GR_DELETED)) {
60865 + if (match->prev == NULL) {
60866 + role->subj_hash[index] = match->next;
60867 + if (match->next != NULL)
60868 + match->next->prev = NULL;
60869 + } else {
60870 + match->prev->next = match->next;
60871 + if (match->next != NULL)
60872 + match->next->prev = match->prev;
60873 + }
60874 + match->prev = NULL;
60875 + match->next = NULL;
60876 + match->inode = newinode;
60877 + match->device = newdevice;
60878 + match->mode &= ~GR_DELETED;
60879 +
60880 + insert_acl_subj_label(match, role);
60881 + }
60882 +
60883 + return;
60884 +}
60885 +
60886 +static void
60887 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60888 + const ino_t newinode, const dev_t newdevice)
60889 +{
60890 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60891 + struct inodev_entry *match;
60892 +
60893 + match = inodev_set.i_hash[index];
60894 +
60895 + while (match && (match->nentry->inode != oldinode ||
60896 + match->nentry->device != olddevice || !match->nentry->deleted))
60897 + match = match->next;
60898 +
60899 + if (match && (match->nentry->inode == oldinode)
60900 + && (match->nentry->device == olddevice) &&
60901 + match->nentry->deleted) {
60902 + if (match->prev == NULL) {
60903 + inodev_set.i_hash[index] = match->next;
60904 + if (match->next != NULL)
60905 + match->next->prev = NULL;
60906 + } else {
60907 + match->prev->next = match->next;
60908 + if (match->next != NULL)
60909 + match->next->prev = match->prev;
60910 + }
60911 + match->prev = NULL;
60912 + match->next = NULL;
60913 + match->nentry->inode = newinode;
60914 + match->nentry->device = newdevice;
60915 + match->nentry->deleted = 0;
60916 +
60917 + insert_inodev_entry(match);
60918 + }
60919 +
60920 + return;
60921 +}
60922 +
60923 +static void
60924 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
60925 +{
60926 + struct acl_subject_label *subj;
60927 + struct acl_role_label *role;
60928 + unsigned int x;
60929 +
60930 + FOR_EACH_ROLE_START(role)
60931 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
60932 +
60933 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60934 + if ((subj->inode == ino) && (subj->device == dev)) {
60935 + subj->inode = ino;
60936 + subj->device = dev;
60937 + }
60938 + /* nested subjects aren't in the role's subj_hash table */
60939 + update_acl_obj_label(matchn->inode, matchn->device,
60940 + ino, dev, subj);
60941 + FOR_EACH_NESTED_SUBJECT_END(subj)
60942 + FOR_EACH_SUBJECT_START(role, subj, x)
60943 + update_acl_obj_label(matchn->inode, matchn->device,
60944 + ino, dev, subj);
60945 + FOR_EACH_SUBJECT_END(subj,x)
60946 + FOR_EACH_ROLE_END(role)
60947 +
60948 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
60949 +
60950 + return;
60951 +}
60952 +
60953 +static void
60954 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
60955 + const struct vfsmount *mnt)
60956 +{
60957 + ino_t ino = dentry->d_inode->i_ino;
60958 + dev_t dev = __get_dev(dentry);
60959 +
60960 + __do_handle_create(matchn, ino, dev);
60961 +
60962 + return;
60963 +}
60964 +
60965 +void
60966 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
60967 +{
60968 + struct name_entry *matchn;
60969 +
60970 + if (unlikely(!(gr_status & GR_READY)))
60971 + return;
60972 +
60973 + preempt_disable();
60974 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
60975 +
60976 + if (unlikely((unsigned long)matchn)) {
60977 + write_lock(&gr_inode_lock);
60978 + do_handle_create(matchn, dentry, mnt);
60979 + write_unlock(&gr_inode_lock);
60980 + }
60981 + preempt_enable();
60982 +
60983 + return;
60984 +}
60985 +
60986 +void
60987 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
60988 +{
60989 + struct name_entry *matchn;
60990 +
60991 + if (unlikely(!(gr_status & GR_READY)))
60992 + return;
60993 +
60994 + preempt_disable();
60995 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
60996 +
60997 + if (unlikely((unsigned long)matchn)) {
60998 + write_lock(&gr_inode_lock);
60999 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61000 + write_unlock(&gr_inode_lock);
61001 + }
61002 + preempt_enable();
61003 +
61004 + return;
61005 +}
61006 +
61007 +void
61008 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61009 + struct dentry *old_dentry,
61010 + struct dentry *new_dentry,
61011 + struct vfsmount *mnt, const __u8 replace)
61012 +{
61013 + struct name_entry *matchn;
61014 + struct inodev_entry *inodev;
61015 + struct inode *inode = new_dentry->d_inode;
61016 + ino_t old_ino = old_dentry->d_inode->i_ino;
61017 + dev_t old_dev = __get_dev(old_dentry);
61018 +
61019 + /* vfs_rename swaps the name and parent link for old_dentry and
61020 + new_dentry
61021 + at this point, old_dentry has the new name, parent link, and inode
61022 + for the renamed file
61023 + if a file is being replaced by a rename, new_dentry has the inode
61024 + and name for the replaced file
61025 + */
61026 +
61027 + if (unlikely(!(gr_status & GR_READY)))
61028 + return;
61029 +
61030 + preempt_disable();
61031 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61032 +
61033 + /* we wouldn't have to check d_inode if it weren't for
61034 + NFS silly-renaming
61035 + */
61036 +
61037 + write_lock(&gr_inode_lock);
61038 + if (unlikely(replace && inode)) {
61039 + ino_t new_ino = inode->i_ino;
61040 + dev_t new_dev = __get_dev(new_dentry);
61041 +
61042 + inodev = lookup_inodev_entry(new_ino, new_dev);
61043 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61044 + do_handle_delete(inodev, new_ino, new_dev);
61045 + }
61046 +
61047 + inodev = lookup_inodev_entry(old_ino, old_dev);
61048 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61049 + do_handle_delete(inodev, old_ino, old_dev);
61050 +
61051 + if (unlikely((unsigned long)matchn))
61052 + do_handle_create(matchn, old_dentry, mnt);
61053 +
61054 + write_unlock(&gr_inode_lock);
61055 + preempt_enable();
61056 +
61057 + return;
61058 +}
61059 +
61060 +static int
61061 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61062 + unsigned char **sum)
61063 +{
61064 + struct acl_role_label *r;
61065 + struct role_allowed_ip *ipp;
61066 + struct role_transition *trans;
61067 + unsigned int i;
61068 + int found = 0;
61069 + u32 curr_ip = current->signal->curr_ip;
61070 +
61071 + current->signal->saved_ip = curr_ip;
61072 +
61073 + /* check transition table */
61074 +
61075 + for (trans = current->role->transitions; trans; trans = trans->next) {
61076 + if (!strcmp(rolename, trans->rolename)) {
61077 + found = 1;
61078 + break;
61079 + }
61080 + }
61081 +
61082 + if (!found)
61083 + return 0;
61084 +
61085 + /* handle special roles that do not require authentication
61086 + and check ip */
61087 +
61088 + FOR_EACH_ROLE_START(r)
61089 + if (!strcmp(rolename, r->rolename) &&
61090 + (r->roletype & GR_ROLE_SPECIAL)) {
61091 + found = 0;
61092 + if (r->allowed_ips != NULL) {
61093 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61094 + if ((ntohl(curr_ip) & ipp->netmask) ==
61095 + (ntohl(ipp->addr) & ipp->netmask))
61096 + found = 1;
61097 + }
61098 + } else
61099 + found = 2;
61100 + if (!found)
61101 + return 0;
61102 +
61103 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61104 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61105 + *salt = NULL;
61106 + *sum = NULL;
61107 + return 1;
61108 + }
61109 + }
61110 + FOR_EACH_ROLE_END(r)
61111 +
61112 + for (i = 0; i < num_sprole_pws; i++) {
61113 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61114 + *salt = acl_special_roles[i]->salt;
61115 + *sum = acl_special_roles[i]->sum;
61116 + return 1;
61117 + }
61118 + }
61119 +
61120 + return 0;
61121 +}
61122 +
61123 +static void
61124 +assign_special_role(char *rolename)
61125 +{
61126 + struct acl_object_label *obj;
61127 + struct acl_role_label *r;
61128 + struct acl_role_label *assigned = NULL;
61129 + struct task_struct *tsk;
61130 + struct file *filp;
61131 +
61132 + FOR_EACH_ROLE_START(r)
61133 + if (!strcmp(rolename, r->rolename) &&
61134 + (r->roletype & GR_ROLE_SPECIAL)) {
61135 + assigned = r;
61136 + break;
61137 + }
61138 + FOR_EACH_ROLE_END(r)
61139 +
61140 + if (!assigned)
61141 + return;
61142 +
61143 + read_lock(&tasklist_lock);
61144 + read_lock(&grsec_exec_file_lock);
61145 +
61146 + tsk = current->real_parent;
61147 + if (tsk == NULL)
61148 + goto out_unlock;
61149 +
61150 + filp = tsk->exec_file;
61151 + if (filp == NULL)
61152 + goto out_unlock;
61153 +
61154 + tsk->is_writable = 0;
61155 +
61156 + tsk->acl_sp_role = 1;
61157 + tsk->acl_role_id = ++acl_sp_role_value;
61158 + tsk->role = assigned;
61159 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61160 +
61161 + /* ignore additional mmap checks for processes that are writable
61162 + by the default ACL */
61163 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61164 + if (unlikely(obj->mode & GR_WRITE))
61165 + tsk->is_writable = 1;
61166 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61167 + if (unlikely(obj->mode & GR_WRITE))
61168 + tsk->is_writable = 1;
61169 +
61170 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61171 + 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));
61172 +#endif
61173 +
61174 +out_unlock:
61175 + read_unlock(&grsec_exec_file_lock);
61176 + read_unlock(&tasklist_lock);
61177 + return;
61178 +}
61179 +
61180 +int gr_check_secure_terminal(struct task_struct *task)
61181 +{
61182 + struct task_struct *p, *p2, *p3;
61183 + struct files_struct *files;
61184 + struct fdtable *fdt;
61185 + struct file *our_file = NULL, *file;
61186 + int i;
61187 +
61188 + if (task->signal->tty == NULL)
61189 + return 1;
61190 +
61191 + files = get_files_struct(task);
61192 + if (files != NULL) {
61193 + rcu_read_lock();
61194 + fdt = files_fdtable(files);
61195 + for (i=0; i < fdt->max_fds; i++) {
61196 + file = fcheck_files(files, i);
61197 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61198 + get_file(file);
61199 + our_file = file;
61200 + }
61201 + }
61202 + rcu_read_unlock();
61203 + put_files_struct(files);
61204 + }
61205 +
61206 + if (our_file == NULL)
61207 + return 1;
61208 +
61209 + read_lock(&tasklist_lock);
61210 + do_each_thread(p2, p) {
61211 + files = get_files_struct(p);
61212 + if (files == NULL ||
61213 + (p->signal && p->signal->tty == task->signal->tty)) {
61214 + if (files != NULL)
61215 + put_files_struct(files);
61216 + continue;
61217 + }
61218 + rcu_read_lock();
61219 + fdt = files_fdtable(files);
61220 + for (i=0; i < fdt->max_fds; i++) {
61221 + file = fcheck_files(files, i);
61222 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61223 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61224 + p3 = task;
61225 + while (task_pid_nr(p3) > 0) {
61226 + if (p3 == p)
61227 + break;
61228 + p3 = p3->real_parent;
61229 + }
61230 + if (p3 == p)
61231 + break;
61232 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61233 + gr_handle_alertkill(p);
61234 + rcu_read_unlock();
61235 + put_files_struct(files);
61236 + read_unlock(&tasklist_lock);
61237 + fput(our_file);
61238 + return 0;
61239 + }
61240 + }
61241 + rcu_read_unlock();
61242 + put_files_struct(files);
61243 + } while_each_thread(p2, p);
61244 + read_unlock(&tasklist_lock);
61245 +
61246 + fput(our_file);
61247 + return 1;
61248 +}
61249 +
61250 +static int gr_rbac_disable(void *unused)
61251 +{
61252 + pax_open_kernel();
61253 + gr_status &= ~GR_READY;
61254 + pax_close_kernel();
61255 +
61256 + return 0;
61257 +}
61258 +
61259 +ssize_t
61260 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61261 +{
61262 + struct gr_arg_wrapper uwrap;
61263 + unsigned char *sprole_salt = NULL;
61264 + unsigned char *sprole_sum = NULL;
61265 + int error = sizeof (struct gr_arg_wrapper);
61266 + int error2 = 0;
61267 +
61268 + mutex_lock(&gr_dev_mutex);
61269 +
61270 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61271 + error = -EPERM;
61272 + goto out;
61273 + }
61274 +
61275 + if (count != sizeof (struct gr_arg_wrapper)) {
61276 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61277 + error = -EINVAL;
61278 + goto out;
61279 + }
61280 +
61281 +
61282 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61283 + gr_auth_expires = 0;
61284 + gr_auth_attempts = 0;
61285 + }
61286 +
61287 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61288 + error = -EFAULT;
61289 + goto out;
61290 + }
61291 +
61292 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61293 + error = -EINVAL;
61294 + goto out;
61295 + }
61296 +
61297 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61298 + error = -EFAULT;
61299 + goto out;
61300 + }
61301 +
61302 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61303 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61304 + time_after(gr_auth_expires, get_seconds())) {
61305 + error = -EBUSY;
61306 + goto out;
61307 + }
61308 +
61309 + /* if non-root trying to do anything other than use a special role,
61310 + do not attempt authentication, do not count towards authentication
61311 + locking
61312 + */
61313 +
61314 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61315 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61316 + gr_is_global_nonroot(current_uid())) {
61317 + error = -EPERM;
61318 + goto out;
61319 + }
61320 +
61321 + /* ensure pw and special role name are null terminated */
61322 +
61323 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61324 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61325 +
61326 + /* Okay.
61327 + * We have our enough of the argument structure..(we have yet
61328 + * to copy_from_user the tables themselves) . Copy the tables
61329 + * only if we need them, i.e. for loading operations. */
61330 +
61331 + switch (gr_usermode->mode) {
61332 + case GR_STATUS:
61333 + if (gr_status & GR_READY) {
61334 + error = 1;
61335 + if (!gr_check_secure_terminal(current))
61336 + error = 3;
61337 + } else
61338 + error = 2;
61339 + goto out;
61340 + case GR_SHUTDOWN:
61341 + if ((gr_status & GR_READY)
61342 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61343 + stop_machine(gr_rbac_disable, NULL, NULL);
61344 + free_variables();
61345 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61346 + memset(gr_system_salt, 0, GR_SALT_LEN);
61347 + memset(gr_system_sum, 0, GR_SHA_LEN);
61348 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61349 + } else if (gr_status & GR_READY) {
61350 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61351 + error = -EPERM;
61352 + } else {
61353 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61354 + error = -EAGAIN;
61355 + }
61356 + break;
61357 + case GR_ENABLE:
61358 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61359 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61360 + else {
61361 + if (gr_status & GR_READY)
61362 + error = -EAGAIN;
61363 + else
61364 + error = error2;
61365 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61366 + }
61367 + break;
61368 + case GR_RELOAD:
61369 + if (!(gr_status & GR_READY)) {
61370 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61371 + error = -EAGAIN;
61372 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61373 + stop_machine(gr_rbac_disable, NULL, NULL);
61374 + free_variables();
61375 + error2 = gracl_init(gr_usermode);
61376 + if (!error2)
61377 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61378 + else {
61379 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61380 + error = error2;
61381 + }
61382 + } else {
61383 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61384 + error = -EPERM;
61385 + }
61386 + break;
61387 + case GR_SEGVMOD:
61388 + if (unlikely(!(gr_status & GR_READY))) {
61389 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61390 + error = -EAGAIN;
61391 + break;
61392 + }
61393 +
61394 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61395 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61396 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61397 + struct acl_subject_label *segvacl;
61398 + segvacl =
61399 + lookup_acl_subj_label(gr_usermode->segv_inode,
61400 + gr_usermode->segv_device,
61401 + current->role);
61402 + if (segvacl) {
61403 + segvacl->crashes = 0;
61404 + segvacl->expires = 0;
61405 + }
61406 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61407 + gr_remove_uid(gr_usermode->segv_uid);
61408 + }
61409 + } else {
61410 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61411 + error = -EPERM;
61412 + }
61413 + break;
61414 + case GR_SPROLE:
61415 + case GR_SPROLEPAM:
61416 + if (unlikely(!(gr_status & GR_READY))) {
61417 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61418 + error = -EAGAIN;
61419 + break;
61420 + }
61421 +
61422 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61423 + current->role->expires = 0;
61424 + current->role->auth_attempts = 0;
61425 + }
61426 +
61427 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61428 + time_after(current->role->expires, get_seconds())) {
61429 + error = -EBUSY;
61430 + goto out;
61431 + }
61432 +
61433 + if (lookup_special_role_auth
61434 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61435 + && ((!sprole_salt && !sprole_sum)
61436 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61437 + char *p = "";
61438 + assign_special_role(gr_usermode->sp_role);
61439 + read_lock(&tasklist_lock);
61440 + if (current->real_parent)
61441 + p = current->real_parent->role->rolename;
61442 + read_unlock(&tasklist_lock);
61443 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61444 + p, acl_sp_role_value);
61445 + } else {
61446 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61447 + error = -EPERM;
61448 + if(!(current->role->auth_attempts++))
61449 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61450 +
61451 + goto out;
61452 + }
61453 + break;
61454 + case GR_UNSPROLE:
61455 + if (unlikely(!(gr_status & GR_READY))) {
61456 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61457 + error = -EAGAIN;
61458 + break;
61459 + }
61460 +
61461 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61462 + char *p = "";
61463 + int i = 0;
61464 +
61465 + read_lock(&tasklist_lock);
61466 + if (current->real_parent) {
61467 + p = current->real_parent->role->rolename;
61468 + i = current->real_parent->acl_role_id;
61469 + }
61470 + read_unlock(&tasklist_lock);
61471 +
61472 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61473 + gr_set_acls(1);
61474 + } else {
61475 + error = -EPERM;
61476 + goto out;
61477 + }
61478 + break;
61479 + default:
61480 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61481 + error = -EINVAL;
61482 + break;
61483 + }
61484 +
61485 + if (error != -EPERM)
61486 + goto out;
61487 +
61488 + if(!(gr_auth_attempts++))
61489 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61490 +
61491 + out:
61492 + mutex_unlock(&gr_dev_mutex);
61493 + return error;
61494 +}
61495 +
61496 +/* must be called with
61497 + rcu_read_lock();
61498 + read_lock(&tasklist_lock);
61499 + read_lock(&grsec_exec_file_lock);
61500 +*/
61501 +int gr_apply_subject_to_task(struct task_struct *task)
61502 +{
61503 + struct acl_object_label *obj;
61504 + char *tmpname;
61505 + struct acl_subject_label *tmpsubj;
61506 + struct file *filp;
61507 + struct name_entry *nmatch;
61508 +
61509 + filp = task->exec_file;
61510 + if (filp == NULL)
61511 + return 0;
61512 +
61513 + /* the following is to apply the correct subject
61514 + on binaries running when the RBAC system
61515 + is enabled, when the binaries have been
61516 + replaced or deleted since their execution
61517 + -----
61518 + when the RBAC system starts, the inode/dev
61519 + from exec_file will be one the RBAC system
61520 + is unaware of. It only knows the inode/dev
61521 + of the present file on disk, or the absence
61522 + of it.
61523 + */
61524 + preempt_disable();
61525 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61526 +
61527 + nmatch = lookup_name_entry(tmpname);
61528 + preempt_enable();
61529 + tmpsubj = NULL;
61530 + if (nmatch) {
61531 + if (nmatch->deleted)
61532 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61533 + else
61534 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61535 + if (tmpsubj != NULL)
61536 + task->acl = tmpsubj;
61537 + }
61538 + if (tmpsubj == NULL)
61539 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61540 + task->role);
61541 + if (task->acl) {
61542 + task->is_writable = 0;
61543 + /* ignore additional mmap checks for processes that are writable
61544 + by the default ACL */
61545 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61546 + if (unlikely(obj->mode & GR_WRITE))
61547 + task->is_writable = 1;
61548 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61549 + if (unlikely(obj->mode & GR_WRITE))
61550 + task->is_writable = 1;
61551 +
61552 + gr_set_proc_res(task);
61553 +
61554 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61555 + 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);
61556 +#endif
61557 + } else {
61558 + return 1;
61559 + }
61560 +
61561 + return 0;
61562 +}
61563 +
61564 +int
61565 +gr_set_acls(const int type)
61566 +{
61567 + struct task_struct *task, *task2;
61568 + struct acl_role_label *role = current->role;
61569 + __u16 acl_role_id = current->acl_role_id;
61570 + const struct cred *cred;
61571 + int ret;
61572 +
61573 + rcu_read_lock();
61574 + read_lock(&tasklist_lock);
61575 + read_lock(&grsec_exec_file_lock);
61576 + do_each_thread(task2, task) {
61577 + /* check to see if we're called from the exit handler,
61578 + if so, only replace ACLs that have inherited the admin
61579 + ACL */
61580 +
61581 + if (type && (task->role != role ||
61582 + task->acl_role_id != acl_role_id))
61583 + continue;
61584 +
61585 + task->acl_role_id = 0;
61586 + task->acl_sp_role = 0;
61587 +
61588 + if (task->exec_file) {
61589 + cred = __task_cred(task);
61590 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61591 + ret = gr_apply_subject_to_task(task);
61592 + if (ret) {
61593 + read_unlock(&grsec_exec_file_lock);
61594 + read_unlock(&tasklist_lock);
61595 + rcu_read_unlock();
61596 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61597 + return ret;
61598 + }
61599 + } else {
61600 + // it's a kernel process
61601 + task->role = kernel_role;
61602 + task->acl = kernel_role->root_label;
61603 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61604 + task->acl->mode &= ~GR_PROCFIND;
61605 +#endif
61606 + }
61607 + } while_each_thread(task2, task);
61608 + read_unlock(&grsec_exec_file_lock);
61609 + read_unlock(&tasklist_lock);
61610 + rcu_read_unlock();
61611 +
61612 + return 0;
61613 +}
61614 +
61615 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61616 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61617 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61618 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61619 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61620 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61621 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61622 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61623 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61624 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61625 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61626 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61627 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61628 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61629 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61630 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61631 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61632 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61633 +};
61634 +
61635 +void
61636 +gr_learn_resource(const struct task_struct *task,
61637 + const int res, const unsigned long wanted, const int gt)
61638 +{
61639 + struct acl_subject_label *acl;
61640 + const struct cred *cred;
61641 +
61642 + if (unlikely((gr_status & GR_READY) &&
61643 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61644 + goto skip_reslog;
61645 +
61646 + gr_log_resource(task, res, wanted, gt);
61647 +skip_reslog:
61648 +
61649 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61650 + return;
61651 +
61652 + acl = task->acl;
61653 +
61654 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61655 + !(acl->resmask & (1U << (unsigned short) res))))
61656 + return;
61657 +
61658 + if (wanted >= acl->res[res].rlim_cur) {
61659 + unsigned long res_add;
61660 +
61661 + res_add = wanted + res_learn_bumps[res];
61662 +
61663 + acl->res[res].rlim_cur = res_add;
61664 +
61665 + if (wanted > acl->res[res].rlim_max)
61666 + acl->res[res].rlim_max = res_add;
61667 +
61668 + /* only log the subject filename, since resource logging is supported for
61669 + single-subject learning only */
61670 + rcu_read_lock();
61671 + cred = __task_cred(task);
61672 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61673 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61674 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61675 + "", (unsigned long) res, &task->signal->saved_ip);
61676 + rcu_read_unlock();
61677 + }
61678 +
61679 + return;
61680 +}
61681 +EXPORT_SYMBOL(gr_learn_resource);
61682 +#endif
61683 +
61684 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61685 +void
61686 +pax_set_initial_flags(struct linux_binprm *bprm)
61687 +{
61688 + struct task_struct *task = current;
61689 + struct acl_subject_label *proc;
61690 + unsigned long flags;
61691 +
61692 + if (unlikely(!(gr_status & GR_READY)))
61693 + return;
61694 +
61695 + flags = pax_get_flags(task);
61696 +
61697 + proc = task->acl;
61698 +
61699 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61700 + flags &= ~MF_PAX_PAGEEXEC;
61701 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61702 + flags &= ~MF_PAX_SEGMEXEC;
61703 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61704 + flags &= ~MF_PAX_RANDMMAP;
61705 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61706 + flags &= ~MF_PAX_EMUTRAMP;
61707 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61708 + flags &= ~MF_PAX_MPROTECT;
61709 +
61710 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61711 + flags |= MF_PAX_PAGEEXEC;
61712 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61713 + flags |= MF_PAX_SEGMEXEC;
61714 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61715 + flags |= MF_PAX_RANDMMAP;
61716 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61717 + flags |= MF_PAX_EMUTRAMP;
61718 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61719 + flags |= MF_PAX_MPROTECT;
61720 +
61721 + pax_set_flags(task, flags);
61722 +
61723 + return;
61724 +}
61725 +#endif
61726 +
61727 +int
61728 +gr_handle_proc_ptrace(struct task_struct *task)
61729 +{
61730 + struct file *filp;
61731 + struct task_struct *tmp = task;
61732 + struct task_struct *curtemp = current;
61733 + __u32 retmode;
61734 +
61735 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61736 + if (unlikely(!(gr_status & GR_READY)))
61737 + return 0;
61738 +#endif
61739 +
61740 + read_lock(&tasklist_lock);
61741 + read_lock(&grsec_exec_file_lock);
61742 + filp = task->exec_file;
61743 +
61744 + while (task_pid_nr(tmp) > 0) {
61745 + if (tmp == curtemp)
61746 + break;
61747 + tmp = tmp->real_parent;
61748 + }
61749 +
61750 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61751 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61752 + read_unlock(&grsec_exec_file_lock);
61753 + read_unlock(&tasklist_lock);
61754 + return 1;
61755 + }
61756 +
61757 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61758 + if (!(gr_status & GR_READY)) {
61759 + read_unlock(&grsec_exec_file_lock);
61760 + read_unlock(&tasklist_lock);
61761 + return 0;
61762 + }
61763 +#endif
61764 +
61765 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61766 + read_unlock(&grsec_exec_file_lock);
61767 + read_unlock(&tasklist_lock);
61768 +
61769 + if (retmode & GR_NOPTRACE)
61770 + return 1;
61771 +
61772 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61773 + && (current->acl != task->acl || (current->acl != current->role->root_label
61774 + && task_pid_nr(current) != task_pid_nr(task))))
61775 + return 1;
61776 +
61777 + return 0;
61778 +}
61779 +
61780 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61781 +{
61782 + if (unlikely(!(gr_status & GR_READY)))
61783 + return;
61784 +
61785 + if (!(current->role->roletype & GR_ROLE_GOD))
61786 + return;
61787 +
61788 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61789 + p->role->rolename, gr_task_roletype_to_char(p),
61790 + p->acl->filename);
61791 +}
61792 +
61793 +int
61794 +gr_handle_ptrace(struct task_struct *task, const long request)
61795 +{
61796 + struct task_struct *tmp = task;
61797 + struct task_struct *curtemp = current;
61798 + __u32 retmode;
61799 +
61800 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61801 + if (unlikely(!(gr_status & GR_READY)))
61802 + return 0;
61803 +#endif
61804 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61805 + read_lock(&tasklist_lock);
61806 + while (task_pid_nr(tmp) > 0) {
61807 + if (tmp == curtemp)
61808 + break;
61809 + tmp = tmp->real_parent;
61810 + }
61811 +
61812 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61813 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61814 + read_unlock(&tasklist_lock);
61815 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61816 + return 1;
61817 + }
61818 + read_unlock(&tasklist_lock);
61819 + }
61820 +
61821 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61822 + if (!(gr_status & GR_READY))
61823 + return 0;
61824 +#endif
61825 +
61826 + read_lock(&grsec_exec_file_lock);
61827 + if (unlikely(!task->exec_file)) {
61828 + read_unlock(&grsec_exec_file_lock);
61829 + return 0;
61830 + }
61831 +
61832 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61833 + read_unlock(&grsec_exec_file_lock);
61834 +
61835 + if (retmode & GR_NOPTRACE) {
61836 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61837 + return 1;
61838 + }
61839 +
61840 + if (retmode & GR_PTRACERD) {
61841 + switch (request) {
61842 + case PTRACE_SEIZE:
61843 + case PTRACE_POKETEXT:
61844 + case PTRACE_POKEDATA:
61845 + case PTRACE_POKEUSR:
61846 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61847 + case PTRACE_SETREGS:
61848 + case PTRACE_SETFPREGS:
61849 +#endif
61850 +#ifdef CONFIG_X86
61851 + case PTRACE_SETFPXREGS:
61852 +#endif
61853 +#ifdef CONFIG_ALTIVEC
61854 + case PTRACE_SETVRREGS:
61855 +#endif
61856 + return 1;
61857 + default:
61858 + return 0;
61859 + }
61860 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61861 + !(current->role->roletype & GR_ROLE_GOD) &&
61862 + (current->acl != task->acl)) {
61863 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61864 + return 1;
61865 + }
61866 +
61867 + return 0;
61868 +}
61869 +
61870 +static int is_writable_mmap(const struct file *filp)
61871 +{
61872 + struct task_struct *task = current;
61873 + struct acl_object_label *obj, *obj2;
61874 +
61875 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61876 + !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))) {
61877 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61878 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61879 + task->role->root_label);
61880 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61881 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61882 + return 1;
61883 + }
61884 + }
61885 + return 0;
61886 +}
61887 +
61888 +int
61889 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61890 +{
61891 + __u32 mode;
61892 +
61893 + if (unlikely(!file || !(prot & PROT_EXEC)))
61894 + return 1;
61895 +
61896 + if (is_writable_mmap(file))
61897 + return 0;
61898 +
61899 + mode =
61900 + gr_search_file(file->f_path.dentry,
61901 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61902 + file->f_path.mnt);
61903 +
61904 + if (!gr_tpe_allow(file))
61905 + return 0;
61906 +
61907 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61908 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61909 + return 0;
61910 + } else if (unlikely(!(mode & GR_EXEC))) {
61911 + return 0;
61912 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61913 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61914 + return 1;
61915 + }
61916 +
61917 + return 1;
61918 +}
61919 +
61920 +int
61921 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
61922 +{
61923 + __u32 mode;
61924 +
61925 + if (unlikely(!file || !(prot & PROT_EXEC)))
61926 + return 1;
61927 +
61928 + if (is_writable_mmap(file))
61929 + return 0;
61930 +
61931 + mode =
61932 + gr_search_file(file->f_path.dentry,
61933 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
61934 + file->f_path.mnt);
61935 +
61936 + if (!gr_tpe_allow(file))
61937 + return 0;
61938 +
61939 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
61940 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61941 + return 0;
61942 + } else if (unlikely(!(mode & GR_EXEC))) {
61943 + return 0;
61944 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
61945 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
61946 + return 1;
61947 + }
61948 +
61949 + return 1;
61950 +}
61951 +
61952 +void
61953 +gr_acl_handle_psacct(struct task_struct *task, const long code)
61954 +{
61955 + unsigned long runtime;
61956 + unsigned long cputime;
61957 + unsigned int wday, cday;
61958 + __u8 whr, chr;
61959 + __u8 wmin, cmin;
61960 + __u8 wsec, csec;
61961 + struct timespec timeval;
61962 +
61963 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
61964 + !(task->acl->mode & GR_PROCACCT)))
61965 + return;
61966 +
61967 + do_posix_clock_monotonic_gettime(&timeval);
61968 + runtime = timeval.tv_sec - task->start_time.tv_sec;
61969 + wday = runtime / (3600 * 24);
61970 + runtime -= wday * (3600 * 24);
61971 + whr = runtime / 3600;
61972 + runtime -= whr * 3600;
61973 + wmin = runtime / 60;
61974 + runtime -= wmin * 60;
61975 + wsec = runtime;
61976 +
61977 + cputime = (task->utime + task->stime) / HZ;
61978 + cday = cputime / (3600 * 24);
61979 + cputime -= cday * (3600 * 24);
61980 + chr = cputime / 3600;
61981 + cputime -= chr * 3600;
61982 + cmin = cputime / 60;
61983 + cputime -= cmin * 60;
61984 + csec = cputime;
61985 +
61986 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
61987 +
61988 + return;
61989 +}
61990 +
61991 +void gr_set_kernel_label(struct task_struct *task)
61992 +{
61993 + if (gr_status & GR_READY) {
61994 + task->role = kernel_role;
61995 + task->acl = kernel_role->root_label;
61996 + }
61997 + return;
61998 +}
61999 +
62000 +#ifdef CONFIG_TASKSTATS
62001 +int gr_is_taskstats_denied(int pid)
62002 +{
62003 + struct task_struct *task;
62004 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62005 + const struct cred *cred;
62006 +#endif
62007 + int ret = 0;
62008 +
62009 + /* restrict taskstats viewing to un-chrooted root users
62010 + who have the 'view' subject flag if the RBAC system is enabled
62011 + */
62012 +
62013 + rcu_read_lock();
62014 + read_lock(&tasklist_lock);
62015 + task = find_task_by_vpid(pid);
62016 + if (task) {
62017 +#ifdef CONFIG_GRKERNSEC_CHROOT
62018 + if (proc_is_chrooted(task))
62019 + ret = -EACCES;
62020 +#endif
62021 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62022 + cred = __task_cred(task);
62023 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62024 + if (gr_is_global_nonroot(cred->uid))
62025 + ret = -EACCES;
62026 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62027 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62028 + ret = -EACCES;
62029 +#endif
62030 +#endif
62031 + if (gr_status & GR_READY) {
62032 + if (!(task->acl->mode & GR_VIEW))
62033 + ret = -EACCES;
62034 + }
62035 + } else
62036 + ret = -ENOENT;
62037 +
62038 + read_unlock(&tasklist_lock);
62039 + rcu_read_unlock();
62040 +
62041 + return ret;
62042 +}
62043 +#endif
62044 +
62045 +/* AUXV entries are filled via a descendant of search_binary_handler
62046 + after we've already applied the subject for the target
62047 +*/
62048 +int gr_acl_enable_at_secure(void)
62049 +{
62050 + if (unlikely(!(gr_status & GR_READY)))
62051 + return 0;
62052 +
62053 + if (current->acl->mode & GR_ATSECURE)
62054 + return 1;
62055 +
62056 + return 0;
62057 +}
62058 +
62059 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62060 +{
62061 + struct task_struct *task = current;
62062 + struct dentry *dentry = file->f_path.dentry;
62063 + struct vfsmount *mnt = file->f_path.mnt;
62064 + struct acl_object_label *obj, *tmp;
62065 + struct acl_subject_label *subj;
62066 + unsigned int bufsize;
62067 + int is_not_root;
62068 + char *path;
62069 + dev_t dev = __get_dev(dentry);
62070 +
62071 + if (unlikely(!(gr_status & GR_READY)))
62072 + return 1;
62073 +
62074 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62075 + return 1;
62076 +
62077 + /* ignore Eric Biederman */
62078 + if (IS_PRIVATE(dentry->d_inode))
62079 + return 1;
62080 +
62081 + subj = task->acl;
62082 + read_lock(&gr_inode_lock);
62083 + do {
62084 + obj = lookup_acl_obj_label(ino, dev, subj);
62085 + if (obj != NULL) {
62086 + read_unlock(&gr_inode_lock);
62087 + return (obj->mode & GR_FIND) ? 1 : 0;
62088 + }
62089 + } while ((subj = subj->parent_subject));
62090 + read_unlock(&gr_inode_lock);
62091 +
62092 + /* this is purely an optimization since we're looking for an object
62093 + for the directory we're doing a readdir on
62094 + if it's possible for any globbed object to match the entry we're
62095 + filling into the directory, then the object we find here will be
62096 + an anchor point with attached globbed objects
62097 + */
62098 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62099 + if (obj->globbed == NULL)
62100 + return (obj->mode & GR_FIND) ? 1 : 0;
62101 +
62102 + is_not_root = ((obj->filename[0] == '/') &&
62103 + (obj->filename[1] == '\0')) ? 0 : 1;
62104 + bufsize = PAGE_SIZE - namelen - is_not_root;
62105 +
62106 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62107 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62108 + return 1;
62109 +
62110 + preempt_disable();
62111 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62112 + bufsize);
62113 +
62114 + bufsize = strlen(path);
62115 +
62116 + /* if base is "/", don't append an additional slash */
62117 + if (is_not_root)
62118 + *(path + bufsize) = '/';
62119 + memcpy(path + bufsize + is_not_root, name, namelen);
62120 + *(path + bufsize + namelen + is_not_root) = '\0';
62121 +
62122 + tmp = obj->globbed;
62123 + while (tmp) {
62124 + if (!glob_match(tmp->filename, path)) {
62125 + preempt_enable();
62126 + return (tmp->mode & GR_FIND) ? 1 : 0;
62127 + }
62128 + tmp = tmp->next;
62129 + }
62130 + preempt_enable();
62131 + return (obj->mode & GR_FIND) ? 1 : 0;
62132 +}
62133 +
62134 +void gr_put_exec_file(struct task_struct *task)
62135 +{
62136 + struct file *filp;
62137 +
62138 + write_lock(&grsec_exec_file_lock);
62139 + filp = task->exec_file;
62140 + task->exec_file = NULL;
62141 + write_unlock(&grsec_exec_file_lock);
62142 +
62143 + if (filp)
62144 + fput(filp);
62145 +
62146 + return;
62147 +}
62148 +
62149 +
62150 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62151 +EXPORT_SYMBOL(gr_acl_is_enabled);
62152 +#endif
62153 +EXPORT_SYMBOL(gr_set_kernel_label);
62154 +#ifdef CONFIG_SECURITY
62155 +EXPORT_SYMBOL(gr_check_user_change);
62156 +EXPORT_SYMBOL(gr_check_group_change);
62157 +#endif
62158 +
62159 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62160 new file mode 100644
62161 index 0000000..34fefda
62162 --- /dev/null
62163 +++ b/grsecurity/gracl_alloc.c
62164 @@ -0,0 +1,105 @@
62165 +#include <linux/kernel.h>
62166 +#include <linux/mm.h>
62167 +#include <linux/slab.h>
62168 +#include <linux/vmalloc.h>
62169 +#include <linux/gracl.h>
62170 +#include <linux/grsecurity.h>
62171 +
62172 +static unsigned long alloc_stack_next = 1;
62173 +static unsigned long alloc_stack_size = 1;
62174 +static void **alloc_stack;
62175 +
62176 +static __inline__ int
62177 +alloc_pop(void)
62178 +{
62179 + if (alloc_stack_next == 1)
62180 + return 0;
62181 +
62182 + kfree(alloc_stack[alloc_stack_next - 2]);
62183 +
62184 + alloc_stack_next--;
62185 +
62186 + return 1;
62187 +}
62188 +
62189 +static __inline__ int
62190 +alloc_push(void *buf)
62191 +{
62192 + if (alloc_stack_next >= alloc_stack_size)
62193 + return 1;
62194 +
62195 + alloc_stack[alloc_stack_next - 1] = buf;
62196 +
62197 + alloc_stack_next++;
62198 +
62199 + return 0;
62200 +}
62201 +
62202 +void *
62203 +acl_alloc(unsigned long len)
62204 +{
62205 + void *ret = NULL;
62206 +
62207 + if (!len || len > PAGE_SIZE)
62208 + goto out;
62209 +
62210 + ret = kmalloc(len, GFP_KERNEL);
62211 +
62212 + if (ret) {
62213 + if (alloc_push(ret)) {
62214 + kfree(ret);
62215 + ret = NULL;
62216 + }
62217 + }
62218 +
62219 +out:
62220 + return ret;
62221 +}
62222 +
62223 +void *
62224 +acl_alloc_num(unsigned long num, unsigned long len)
62225 +{
62226 + if (!len || (num > (PAGE_SIZE / len)))
62227 + return NULL;
62228 +
62229 + return acl_alloc(num * len);
62230 +}
62231 +
62232 +void
62233 +acl_free_all(void)
62234 +{
62235 + if (gr_acl_is_enabled() || !alloc_stack)
62236 + return;
62237 +
62238 + while (alloc_pop()) ;
62239 +
62240 + if (alloc_stack) {
62241 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62242 + kfree(alloc_stack);
62243 + else
62244 + vfree(alloc_stack);
62245 + }
62246 +
62247 + alloc_stack = NULL;
62248 + alloc_stack_size = 1;
62249 + alloc_stack_next = 1;
62250 +
62251 + return;
62252 +}
62253 +
62254 +int
62255 +acl_alloc_stack_init(unsigned long size)
62256 +{
62257 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62258 + alloc_stack =
62259 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62260 + else
62261 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62262 +
62263 + alloc_stack_size = size;
62264 +
62265 + if (!alloc_stack)
62266 + return 0;
62267 + else
62268 + return 1;
62269 +}
62270 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62271 new file mode 100644
62272 index 0000000..bdd51ea
62273 --- /dev/null
62274 +++ b/grsecurity/gracl_cap.c
62275 @@ -0,0 +1,110 @@
62276 +#include <linux/kernel.h>
62277 +#include <linux/module.h>
62278 +#include <linux/sched.h>
62279 +#include <linux/gracl.h>
62280 +#include <linux/grsecurity.h>
62281 +#include <linux/grinternal.h>
62282 +
62283 +extern const char *captab_log[];
62284 +extern int captab_log_entries;
62285 +
62286 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62287 +{
62288 + struct acl_subject_label *curracl;
62289 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62290 + kernel_cap_t cap_audit = __cap_empty_set;
62291 +
62292 + if (!gr_acl_is_enabled())
62293 + return 1;
62294 +
62295 + curracl = task->acl;
62296 +
62297 + cap_drop = curracl->cap_lower;
62298 + cap_mask = curracl->cap_mask;
62299 + cap_audit = curracl->cap_invert_audit;
62300 +
62301 + while ((curracl = curracl->parent_subject)) {
62302 + /* if the cap isn't specified in the current computed mask but is specified in the
62303 + current level subject, and is lowered in the current level subject, then add
62304 + it to the set of dropped capabilities
62305 + otherwise, add the current level subject's mask to the current computed mask
62306 + */
62307 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62308 + cap_raise(cap_mask, cap);
62309 + if (cap_raised(curracl->cap_lower, cap))
62310 + cap_raise(cap_drop, cap);
62311 + if (cap_raised(curracl->cap_invert_audit, cap))
62312 + cap_raise(cap_audit, cap);
62313 + }
62314 + }
62315 +
62316 + if (!cap_raised(cap_drop, cap)) {
62317 + if (cap_raised(cap_audit, cap))
62318 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62319 + return 1;
62320 + }
62321 +
62322 + curracl = task->acl;
62323 +
62324 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62325 + && cap_raised(cred->cap_effective, cap)) {
62326 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62327 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62328 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62329 + gr_to_filename(task->exec_file->f_path.dentry,
62330 + task->exec_file->f_path.mnt) : curracl->filename,
62331 + curracl->filename, 0UL,
62332 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62333 + return 1;
62334 + }
62335 +
62336 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62337 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62338 +
62339 + return 0;
62340 +}
62341 +
62342 +int
62343 +gr_acl_is_capable(const int cap)
62344 +{
62345 + return gr_task_acl_is_capable(current, current_cred(), cap);
62346 +}
62347 +
62348 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62349 +{
62350 + struct acl_subject_label *curracl;
62351 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62352 +
62353 + if (!gr_acl_is_enabled())
62354 + return 1;
62355 +
62356 + curracl = task->acl;
62357 +
62358 + cap_drop = curracl->cap_lower;
62359 + cap_mask = curracl->cap_mask;
62360 +
62361 + while ((curracl = curracl->parent_subject)) {
62362 + /* if the cap isn't specified in the current computed mask but is specified in the
62363 + current level subject, and is lowered in the current level subject, then add
62364 + it to the set of dropped capabilities
62365 + otherwise, add the current level subject's mask to the current computed mask
62366 + */
62367 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62368 + cap_raise(cap_mask, cap);
62369 + if (cap_raised(curracl->cap_lower, cap))
62370 + cap_raise(cap_drop, cap);
62371 + }
62372 + }
62373 +
62374 + if (!cap_raised(cap_drop, cap))
62375 + return 1;
62376 +
62377 + return 0;
62378 +}
62379 +
62380 +int
62381 +gr_acl_is_capable_nolog(const int cap)
62382 +{
62383 + return gr_task_acl_is_capable_nolog(current, cap);
62384 +}
62385 +
62386 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62387 new file mode 100644
62388 index 0000000..a340c17
62389 --- /dev/null
62390 +++ b/grsecurity/gracl_fs.c
62391 @@ -0,0 +1,431 @@
62392 +#include <linux/kernel.h>
62393 +#include <linux/sched.h>
62394 +#include <linux/types.h>
62395 +#include <linux/fs.h>
62396 +#include <linux/file.h>
62397 +#include <linux/stat.h>
62398 +#include <linux/grsecurity.h>
62399 +#include <linux/grinternal.h>
62400 +#include <linux/gracl.h>
62401 +
62402 +umode_t
62403 +gr_acl_umask(void)
62404 +{
62405 + if (unlikely(!gr_acl_is_enabled()))
62406 + return 0;
62407 +
62408 + return current->role->umask;
62409 +}
62410 +
62411 +__u32
62412 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62413 + const struct vfsmount * mnt)
62414 +{
62415 + __u32 mode;
62416 +
62417 + if (unlikely(!dentry->d_inode))
62418 + return GR_FIND;
62419 +
62420 + mode =
62421 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62422 +
62423 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62424 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62425 + return mode;
62426 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62427 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62428 + return 0;
62429 + } else if (unlikely(!(mode & GR_FIND)))
62430 + return 0;
62431 +
62432 + return GR_FIND;
62433 +}
62434 +
62435 +__u32
62436 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62437 + int acc_mode)
62438 +{
62439 + __u32 reqmode = GR_FIND;
62440 + __u32 mode;
62441 +
62442 + if (unlikely(!dentry->d_inode))
62443 + return reqmode;
62444 +
62445 + if (acc_mode & MAY_APPEND)
62446 + reqmode |= GR_APPEND;
62447 + else if (acc_mode & MAY_WRITE)
62448 + reqmode |= GR_WRITE;
62449 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62450 + reqmode |= GR_READ;
62451 +
62452 + mode =
62453 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62454 + mnt);
62455 +
62456 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62457 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62458 + reqmode & GR_READ ? " reading" : "",
62459 + reqmode & GR_WRITE ? " writing" : reqmode &
62460 + GR_APPEND ? " appending" : "");
62461 + return reqmode;
62462 + } else
62463 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62464 + {
62465 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62466 + reqmode & GR_READ ? " reading" : "",
62467 + reqmode & GR_WRITE ? " writing" : reqmode &
62468 + GR_APPEND ? " appending" : "");
62469 + return 0;
62470 + } else if (unlikely((mode & reqmode) != reqmode))
62471 + return 0;
62472 +
62473 + return reqmode;
62474 +}
62475 +
62476 +__u32
62477 +gr_acl_handle_creat(const struct dentry * dentry,
62478 + const struct dentry * p_dentry,
62479 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62480 + const int imode)
62481 +{
62482 + __u32 reqmode = GR_WRITE | GR_CREATE;
62483 + __u32 mode;
62484 +
62485 + if (acc_mode & MAY_APPEND)
62486 + reqmode |= GR_APPEND;
62487 + // if a directory was required or the directory already exists, then
62488 + // don't count this open as a read
62489 + if ((acc_mode & MAY_READ) &&
62490 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62491 + reqmode |= GR_READ;
62492 + if ((open_flags & O_CREAT) &&
62493 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62494 + reqmode |= GR_SETID;
62495 +
62496 + mode =
62497 + gr_check_create(dentry, p_dentry, p_mnt,
62498 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62499 +
62500 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62501 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62502 + reqmode & GR_READ ? " reading" : "",
62503 + reqmode & GR_WRITE ? " writing" : reqmode &
62504 + GR_APPEND ? " appending" : "");
62505 + return reqmode;
62506 + } else
62507 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62508 + {
62509 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62510 + reqmode & GR_READ ? " reading" : "",
62511 + reqmode & GR_WRITE ? " writing" : reqmode &
62512 + GR_APPEND ? " appending" : "");
62513 + return 0;
62514 + } else if (unlikely((mode & reqmode) != reqmode))
62515 + return 0;
62516 +
62517 + return reqmode;
62518 +}
62519 +
62520 +__u32
62521 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62522 + const int fmode)
62523 +{
62524 + __u32 mode, reqmode = GR_FIND;
62525 +
62526 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62527 + reqmode |= GR_EXEC;
62528 + if (fmode & S_IWOTH)
62529 + reqmode |= GR_WRITE;
62530 + if (fmode & S_IROTH)
62531 + reqmode |= GR_READ;
62532 +
62533 + mode =
62534 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62535 + mnt);
62536 +
62537 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62538 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62539 + reqmode & GR_READ ? " reading" : "",
62540 + reqmode & GR_WRITE ? " writing" : "",
62541 + reqmode & GR_EXEC ? " executing" : "");
62542 + return reqmode;
62543 + } else
62544 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62545 + {
62546 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62547 + reqmode & GR_READ ? " reading" : "",
62548 + reqmode & GR_WRITE ? " writing" : "",
62549 + reqmode & GR_EXEC ? " executing" : "");
62550 + return 0;
62551 + } else if (unlikely((mode & reqmode) != reqmode))
62552 + return 0;
62553 +
62554 + return reqmode;
62555 +}
62556 +
62557 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62558 +{
62559 + __u32 mode;
62560 +
62561 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62562 +
62563 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62564 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62565 + return mode;
62566 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62567 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62568 + return 0;
62569 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62570 + return 0;
62571 +
62572 + return (reqmode);
62573 +}
62574 +
62575 +__u32
62576 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62577 +{
62578 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62579 +}
62580 +
62581 +__u32
62582 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62583 +{
62584 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62585 +}
62586 +
62587 +__u32
62588 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62589 +{
62590 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62591 +}
62592 +
62593 +__u32
62594 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62595 +{
62596 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62597 +}
62598 +
62599 +__u32
62600 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62601 + umode_t *modeptr)
62602 +{
62603 + umode_t mode;
62604 +
62605 + *modeptr &= ~gr_acl_umask();
62606 + mode = *modeptr;
62607 +
62608 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62609 + return 1;
62610 +
62611 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62612 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62613 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62614 + GR_CHMOD_ACL_MSG);
62615 + } else {
62616 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62617 + }
62618 +}
62619 +
62620 +__u32
62621 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62622 +{
62623 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62624 +}
62625 +
62626 +__u32
62627 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62628 +{
62629 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62630 +}
62631 +
62632 +__u32
62633 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62634 +{
62635 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62636 +}
62637 +
62638 +__u32
62639 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62640 +{
62641 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62642 + GR_UNIXCONNECT_ACL_MSG);
62643 +}
62644 +
62645 +/* hardlinks require at minimum create and link permission,
62646 + any additional privilege required is based on the
62647 + privilege of the file being linked to
62648 +*/
62649 +__u32
62650 +gr_acl_handle_link(const struct dentry * new_dentry,
62651 + const struct dentry * parent_dentry,
62652 + const struct vfsmount * parent_mnt,
62653 + const struct dentry * old_dentry,
62654 + const struct vfsmount * old_mnt, const struct filename *to)
62655 +{
62656 + __u32 mode;
62657 + __u32 needmode = GR_CREATE | GR_LINK;
62658 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62659 +
62660 + mode =
62661 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62662 + old_mnt);
62663 +
62664 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62665 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62666 + return mode;
62667 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62668 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62669 + return 0;
62670 + } else if (unlikely((mode & needmode) != needmode))
62671 + return 0;
62672 +
62673 + return 1;
62674 +}
62675 +
62676 +__u32
62677 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62678 + const struct dentry * parent_dentry,
62679 + const struct vfsmount * parent_mnt, const struct filename *from)
62680 +{
62681 + __u32 needmode = GR_WRITE | GR_CREATE;
62682 + __u32 mode;
62683 +
62684 + mode =
62685 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62686 + GR_CREATE | GR_AUDIT_CREATE |
62687 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62688 +
62689 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62690 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62691 + return mode;
62692 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62693 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62694 + return 0;
62695 + } else if (unlikely((mode & needmode) != needmode))
62696 + return 0;
62697 +
62698 + return (GR_WRITE | GR_CREATE);
62699 +}
62700 +
62701 +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)
62702 +{
62703 + __u32 mode;
62704 +
62705 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62706 +
62707 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62708 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62709 + return mode;
62710 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62711 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62712 + return 0;
62713 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62714 + return 0;
62715 +
62716 + return (reqmode);
62717 +}
62718 +
62719 +__u32
62720 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62721 + const struct dentry * parent_dentry,
62722 + const struct vfsmount * parent_mnt,
62723 + const int mode)
62724 +{
62725 + __u32 reqmode = GR_WRITE | GR_CREATE;
62726 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62727 + reqmode |= GR_SETID;
62728 +
62729 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62730 + reqmode, GR_MKNOD_ACL_MSG);
62731 +}
62732 +
62733 +__u32
62734 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62735 + const struct dentry *parent_dentry,
62736 + const struct vfsmount *parent_mnt)
62737 +{
62738 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62739 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62740 +}
62741 +
62742 +#define RENAME_CHECK_SUCCESS(old, new) \
62743 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62744 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62745 +
62746 +int
62747 +gr_acl_handle_rename(struct dentry *new_dentry,
62748 + struct dentry *parent_dentry,
62749 + const struct vfsmount *parent_mnt,
62750 + struct dentry *old_dentry,
62751 + struct inode *old_parent_inode,
62752 + struct vfsmount *old_mnt, const struct filename *newname)
62753 +{
62754 + __u32 comp1, comp2;
62755 + int error = 0;
62756 +
62757 + if (unlikely(!gr_acl_is_enabled()))
62758 + return 0;
62759 +
62760 + if (!new_dentry->d_inode) {
62761 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62762 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62763 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62764 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62765 + GR_DELETE | GR_AUDIT_DELETE |
62766 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62767 + GR_SUPPRESS, old_mnt);
62768 + } else {
62769 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62770 + GR_CREATE | GR_DELETE |
62771 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62772 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62773 + GR_SUPPRESS, parent_mnt);
62774 + comp2 =
62775 + gr_search_file(old_dentry,
62776 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62777 + GR_DELETE | GR_AUDIT_DELETE |
62778 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62779 + }
62780 +
62781 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62782 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62783 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62784 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62785 + && !(comp2 & GR_SUPPRESS)) {
62786 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62787 + error = -EACCES;
62788 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62789 + error = -EACCES;
62790 +
62791 + return error;
62792 +}
62793 +
62794 +void
62795 +gr_acl_handle_exit(void)
62796 +{
62797 + u16 id;
62798 + char *rolename;
62799 +
62800 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62801 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62802 + id = current->acl_role_id;
62803 + rolename = current->role->rolename;
62804 + gr_set_acls(1);
62805 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62806 + }
62807 +
62808 + gr_put_exec_file(current);
62809 + return;
62810 +}
62811 +
62812 +int
62813 +gr_acl_handle_procpidmem(const struct task_struct *task)
62814 +{
62815 + if (unlikely(!gr_acl_is_enabled()))
62816 + return 0;
62817 +
62818 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62819 + return -EACCES;
62820 +
62821 + return 0;
62822 +}
62823 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62824 new file mode 100644
62825 index 0000000..8132048
62826 --- /dev/null
62827 +++ b/grsecurity/gracl_ip.c
62828 @@ -0,0 +1,387 @@
62829 +#include <linux/kernel.h>
62830 +#include <asm/uaccess.h>
62831 +#include <asm/errno.h>
62832 +#include <net/sock.h>
62833 +#include <linux/file.h>
62834 +#include <linux/fs.h>
62835 +#include <linux/net.h>
62836 +#include <linux/in.h>
62837 +#include <linux/skbuff.h>
62838 +#include <linux/ip.h>
62839 +#include <linux/udp.h>
62840 +#include <linux/types.h>
62841 +#include <linux/sched.h>
62842 +#include <linux/netdevice.h>
62843 +#include <linux/inetdevice.h>
62844 +#include <linux/gracl.h>
62845 +#include <linux/grsecurity.h>
62846 +#include <linux/grinternal.h>
62847 +
62848 +#define GR_BIND 0x01
62849 +#define GR_CONNECT 0x02
62850 +#define GR_INVERT 0x04
62851 +#define GR_BINDOVERRIDE 0x08
62852 +#define GR_CONNECTOVERRIDE 0x10
62853 +#define GR_SOCK_FAMILY 0x20
62854 +
62855 +static const char * gr_protocols[IPPROTO_MAX] = {
62856 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62857 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62858 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62859 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62860 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62861 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62862 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62863 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62864 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62865 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62866 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62867 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62868 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62869 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62870 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62871 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62872 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62873 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62874 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62875 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62876 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62877 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62878 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62879 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62880 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62881 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62882 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62883 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62884 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62885 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62886 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62887 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62888 + };
62889 +
62890 +static const char * gr_socktypes[SOCK_MAX] = {
62891 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62892 + "unknown:7", "unknown:8", "unknown:9", "packet"
62893 + };
62894 +
62895 +static const char * gr_sockfamilies[AF_MAX+1] = {
62896 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62897 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
62898 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
62899 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
62900 + };
62901 +
62902 +const char *
62903 +gr_proto_to_name(unsigned char proto)
62904 +{
62905 + return gr_protocols[proto];
62906 +}
62907 +
62908 +const char *
62909 +gr_socktype_to_name(unsigned char type)
62910 +{
62911 + return gr_socktypes[type];
62912 +}
62913 +
62914 +const char *
62915 +gr_sockfamily_to_name(unsigned char family)
62916 +{
62917 + return gr_sockfamilies[family];
62918 +}
62919 +
62920 +int
62921 +gr_search_socket(const int domain, const int type, const int protocol)
62922 +{
62923 + struct acl_subject_label *curr;
62924 + const struct cred *cred = current_cred();
62925 +
62926 + if (unlikely(!gr_acl_is_enabled()))
62927 + goto exit;
62928 +
62929 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
62930 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
62931 + goto exit; // let the kernel handle it
62932 +
62933 + curr = current->acl;
62934 +
62935 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
62936 + /* the family is allowed, if this is PF_INET allow it only if
62937 + the extra sock type/protocol checks pass */
62938 + if (domain == PF_INET)
62939 + goto inet_check;
62940 + goto exit;
62941 + } else {
62942 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62943 + __u32 fakeip = 0;
62944 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62945 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62946 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62947 + gr_to_filename(current->exec_file->f_path.dentry,
62948 + current->exec_file->f_path.mnt) :
62949 + curr->filename, curr->filename,
62950 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
62951 + &current->signal->saved_ip);
62952 + goto exit;
62953 + }
62954 + goto exit_fail;
62955 + }
62956 +
62957 +inet_check:
62958 + /* the rest of this checking is for IPv4 only */
62959 + if (!curr->ips)
62960 + goto exit;
62961 +
62962 + if ((curr->ip_type & (1U << type)) &&
62963 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
62964 + goto exit;
62965 +
62966 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
62967 + /* we don't place acls on raw sockets , and sometimes
62968 + dgram/ip sockets are opened for ioctl and not
62969 + bind/connect, so we'll fake a bind learn log */
62970 + if (type == SOCK_RAW || type == SOCK_PACKET) {
62971 + __u32 fakeip = 0;
62972 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62973 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62974 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62975 + gr_to_filename(current->exec_file->f_path.dentry,
62976 + current->exec_file->f_path.mnt) :
62977 + curr->filename, curr->filename,
62978 + &fakeip, 0, type,
62979 + protocol, GR_CONNECT, &current->signal->saved_ip);
62980 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
62981 + __u32 fakeip = 0;
62982 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
62983 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
62984 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
62985 + gr_to_filename(current->exec_file->f_path.dentry,
62986 + current->exec_file->f_path.mnt) :
62987 + curr->filename, curr->filename,
62988 + &fakeip, 0, type,
62989 + protocol, GR_BIND, &current->signal->saved_ip);
62990 + }
62991 + /* we'll log when they use connect or bind */
62992 + goto exit;
62993 + }
62994 +
62995 +exit_fail:
62996 + if (domain == PF_INET)
62997 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
62998 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
62999 + else
63000 +#ifndef CONFIG_IPV6
63001 + if (domain != PF_INET6)
63002 +#endif
63003 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63004 + gr_socktype_to_name(type), protocol);
63005 +
63006 + return 0;
63007 +exit:
63008 + return 1;
63009 +}
63010 +
63011 +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)
63012 +{
63013 + if ((ip->mode & mode) &&
63014 + (ip_port >= ip->low) &&
63015 + (ip_port <= ip->high) &&
63016 + ((ntohl(ip_addr) & our_netmask) ==
63017 + (ntohl(our_addr) & our_netmask))
63018 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63019 + && (ip->type & (1U << type))) {
63020 + if (ip->mode & GR_INVERT)
63021 + return 2; // specifically denied
63022 + else
63023 + return 1; // allowed
63024 + }
63025 +
63026 + return 0; // not specifically allowed, may continue parsing
63027 +}
63028 +
63029 +static int
63030 +gr_search_connectbind(const int full_mode, struct sock *sk,
63031 + struct sockaddr_in *addr, const int type)
63032 +{
63033 + char iface[IFNAMSIZ] = {0};
63034 + struct acl_subject_label *curr;
63035 + struct acl_ip_label *ip;
63036 + struct inet_sock *isk;
63037 + struct net_device *dev;
63038 + struct in_device *idev;
63039 + unsigned long i;
63040 + int ret;
63041 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63042 + __u32 ip_addr = 0;
63043 + __u32 our_addr;
63044 + __u32 our_netmask;
63045 + char *p;
63046 + __u16 ip_port = 0;
63047 + const struct cred *cred = current_cred();
63048 +
63049 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63050 + return 0;
63051 +
63052 + curr = current->acl;
63053 + isk = inet_sk(sk);
63054 +
63055 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63056 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63057 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63058 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63059 + struct sockaddr_in saddr;
63060 + int err;
63061 +
63062 + saddr.sin_family = AF_INET;
63063 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63064 + saddr.sin_port = isk->inet_sport;
63065 +
63066 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63067 + if (err)
63068 + return err;
63069 +
63070 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63071 + if (err)
63072 + return err;
63073 + }
63074 +
63075 + if (!curr->ips)
63076 + return 0;
63077 +
63078 + ip_addr = addr->sin_addr.s_addr;
63079 + ip_port = ntohs(addr->sin_port);
63080 +
63081 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
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 + &ip_addr, ip_port, type,
63089 + sk->sk_protocol, mode, &current->signal->saved_ip);
63090 + return 0;
63091 + }
63092 +
63093 + for (i = 0; i < curr->ip_num; i++) {
63094 + ip = *(curr->ips + i);
63095 + if (ip->iface != NULL) {
63096 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63097 + p = strchr(iface, ':');
63098 + if (p != NULL)
63099 + *p = '\0';
63100 + dev = dev_get_by_name(sock_net(sk), iface);
63101 + if (dev == NULL)
63102 + continue;
63103 + idev = in_dev_get(dev);
63104 + if (idev == NULL) {
63105 + dev_put(dev);
63106 + continue;
63107 + }
63108 + rcu_read_lock();
63109 + for_ifa(idev) {
63110 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63111 + our_addr = ifa->ifa_address;
63112 + our_netmask = 0xffffffff;
63113 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63114 + if (ret == 1) {
63115 + rcu_read_unlock();
63116 + in_dev_put(idev);
63117 + dev_put(dev);
63118 + return 0;
63119 + } else if (ret == 2) {
63120 + rcu_read_unlock();
63121 + in_dev_put(idev);
63122 + dev_put(dev);
63123 + goto denied;
63124 + }
63125 + }
63126 + } endfor_ifa(idev);
63127 + rcu_read_unlock();
63128 + in_dev_put(idev);
63129 + dev_put(dev);
63130 + } else {
63131 + our_addr = ip->addr;
63132 + our_netmask = ip->netmask;
63133 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63134 + if (ret == 1)
63135 + return 0;
63136 + else if (ret == 2)
63137 + goto denied;
63138 + }
63139 + }
63140 +
63141 +denied:
63142 + if (mode == GR_BIND)
63143 + 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));
63144 + else if (mode == GR_CONNECT)
63145 + 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));
63146 +
63147 + return -EACCES;
63148 +}
63149 +
63150 +int
63151 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63152 +{
63153 + /* always allow disconnection of dgram sockets with connect */
63154 + if (addr->sin_family == AF_UNSPEC)
63155 + return 0;
63156 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63157 +}
63158 +
63159 +int
63160 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63161 +{
63162 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63163 +}
63164 +
63165 +int gr_search_listen(struct socket *sock)
63166 +{
63167 + struct sock *sk = sock->sk;
63168 + struct sockaddr_in addr;
63169 +
63170 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63171 + addr.sin_port = inet_sk(sk)->inet_sport;
63172 +
63173 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63174 +}
63175 +
63176 +int gr_search_accept(struct socket *sock)
63177 +{
63178 + struct sock *sk = sock->sk;
63179 + struct sockaddr_in addr;
63180 +
63181 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63182 + addr.sin_port = inet_sk(sk)->inet_sport;
63183 +
63184 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63185 +}
63186 +
63187 +int
63188 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63189 +{
63190 + if (addr)
63191 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63192 + else {
63193 + struct sockaddr_in sin;
63194 + const struct inet_sock *inet = inet_sk(sk);
63195 +
63196 + sin.sin_addr.s_addr = inet->inet_daddr;
63197 + sin.sin_port = inet->inet_dport;
63198 +
63199 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63200 + }
63201 +}
63202 +
63203 +int
63204 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63205 +{
63206 + struct sockaddr_in sin;
63207 +
63208 + if (unlikely(skb->len < sizeof (struct udphdr)))
63209 + return 0; // skip this packet
63210 +
63211 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63212 + sin.sin_port = udp_hdr(skb)->source;
63213 +
63214 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63215 +}
63216 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63217 new file mode 100644
63218 index 0000000..25f54ef
63219 --- /dev/null
63220 +++ b/grsecurity/gracl_learn.c
63221 @@ -0,0 +1,207 @@
63222 +#include <linux/kernel.h>
63223 +#include <linux/mm.h>
63224 +#include <linux/sched.h>
63225 +#include <linux/poll.h>
63226 +#include <linux/string.h>
63227 +#include <linux/file.h>
63228 +#include <linux/types.h>
63229 +#include <linux/vmalloc.h>
63230 +#include <linux/grinternal.h>
63231 +
63232 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63233 + size_t count, loff_t *ppos);
63234 +extern int gr_acl_is_enabled(void);
63235 +
63236 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63237 +static int gr_learn_attached;
63238 +
63239 +/* use a 512k buffer */
63240 +#define LEARN_BUFFER_SIZE (512 * 1024)
63241 +
63242 +static DEFINE_SPINLOCK(gr_learn_lock);
63243 +static DEFINE_MUTEX(gr_learn_user_mutex);
63244 +
63245 +/* we need to maintain two buffers, so that the kernel context of grlearn
63246 + uses a semaphore around the userspace copying, and the other kernel contexts
63247 + use a spinlock when copying into the buffer, since they cannot sleep
63248 +*/
63249 +static char *learn_buffer;
63250 +static char *learn_buffer_user;
63251 +static int learn_buffer_len;
63252 +static int learn_buffer_user_len;
63253 +
63254 +static ssize_t
63255 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63256 +{
63257 + DECLARE_WAITQUEUE(wait, current);
63258 + ssize_t retval = 0;
63259 +
63260 + add_wait_queue(&learn_wait, &wait);
63261 + set_current_state(TASK_INTERRUPTIBLE);
63262 + do {
63263 + mutex_lock(&gr_learn_user_mutex);
63264 + spin_lock(&gr_learn_lock);
63265 + if (learn_buffer_len)
63266 + break;
63267 + spin_unlock(&gr_learn_lock);
63268 + mutex_unlock(&gr_learn_user_mutex);
63269 + if (file->f_flags & O_NONBLOCK) {
63270 + retval = -EAGAIN;
63271 + goto out;
63272 + }
63273 + if (signal_pending(current)) {
63274 + retval = -ERESTARTSYS;
63275 + goto out;
63276 + }
63277 +
63278 + schedule();
63279 + } while (1);
63280 +
63281 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63282 + learn_buffer_user_len = learn_buffer_len;
63283 + retval = learn_buffer_len;
63284 + learn_buffer_len = 0;
63285 +
63286 + spin_unlock(&gr_learn_lock);
63287 +
63288 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63289 + retval = -EFAULT;
63290 +
63291 + mutex_unlock(&gr_learn_user_mutex);
63292 +out:
63293 + set_current_state(TASK_RUNNING);
63294 + remove_wait_queue(&learn_wait, &wait);
63295 + return retval;
63296 +}
63297 +
63298 +static unsigned int
63299 +poll_learn(struct file * file, poll_table * wait)
63300 +{
63301 + poll_wait(file, &learn_wait, wait);
63302 +
63303 + if (learn_buffer_len)
63304 + return (POLLIN | POLLRDNORM);
63305 +
63306 + return 0;
63307 +}
63308 +
63309 +void
63310 +gr_clear_learn_entries(void)
63311 +{
63312 + char *tmp;
63313 +
63314 + mutex_lock(&gr_learn_user_mutex);
63315 + spin_lock(&gr_learn_lock);
63316 + tmp = learn_buffer;
63317 + learn_buffer = NULL;
63318 + spin_unlock(&gr_learn_lock);
63319 + if (tmp)
63320 + vfree(tmp);
63321 + if (learn_buffer_user != NULL) {
63322 + vfree(learn_buffer_user);
63323 + learn_buffer_user = NULL;
63324 + }
63325 + learn_buffer_len = 0;
63326 + mutex_unlock(&gr_learn_user_mutex);
63327 +
63328 + return;
63329 +}
63330 +
63331 +void
63332 +gr_add_learn_entry(const char *fmt, ...)
63333 +{
63334 + va_list args;
63335 + unsigned int len;
63336 +
63337 + if (!gr_learn_attached)
63338 + return;
63339 +
63340 + spin_lock(&gr_learn_lock);
63341 +
63342 + /* leave a gap at the end so we know when it's "full" but don't have to
63343 + compute the exact length of the string we're trying to append
63344 + */
63345 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63346 + spin_unlock(&gr_learn_lock);
63347 + wake_up_interruptible(&learn_wait);
63348 + return;
63349 + }
63350 + if (learn_buffer == NULL) {
63351 + spin_unlock(&gr_learn_lock);
63352 + return;
63353 + }
63354 +
63355 + va_start(args, fmt);
63356 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63357 + va_end(args);
63358 +
63359 + learn_buffer_len += len + 1;
63360 +
63361 + spin_unlock(&gr_learn_lock);
63362 + wake_up_interruptible(&learn_wait);
63363 +
63364 + return;
63365 +}
63366 +
63367 +static int
63368 +open_learn(struct inode *inode, struct file *file)
63369 +{
63370 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63371 + return -EBUSY;
63372 + if (file->f_mode & FMODE_READ) {
63373 + int retval = 0;
63374 + mutex_lock(&gr_learn_user_mutex);
63375 + if (learn_buffer == NULL)
63376 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63377 + if (learn_buffer_user == NULL)
63378 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63379 + if (learn_buffer == NULL) {
63380 + retval = -ENOMEM;
63381 + goto out_error;
63382 + }
63383 + if (learn_buffer_user == NULL) {
63384 + retval = -ENOMEM;
63385 + goto out_error;
63386 + }
63387 + learn_buffer_len = 0;
63388 + learn_buffer_user_len = 0;
63389 + gr_learn_attached = 1;
63390 +out_error:
63391 + mutex_unlock(&gr_learn_user_mutex);
63392 + return retval;
63393 + }
63394 + return 0;
63395 +}
63396 +
63397 +static int
63398 +close_learn(struct inode *inode, struct file *file)
63399 +{
63400 + if (file->f_mode & FMODE_READ) {
63401 + char *tmp = NULL;
63402 + mutex_lock(&gr_learn_user_mutex);
63403 + spin_lock(&gr_learn_lock);
63404 + tmp = learn_buffer;
63405 + learn_buffer = NULL;
63406 + spin_unlock(&gr_learn_lock);
63407 + if (tmp)
63408 + vfree(tmp);
63409 + if (learn_buffer_user != NULL) {
63410 + vfree(learn_buffer_user);
63411 + learn_buffer_user = NULL;
63412 + }
63413 + learn_buffer_len = 0;
63414 + learn_buffer_user_len = 0;
63415 + gr_learn_attached = 0;
63416 + mutex_unlock(&gr_learn_user_mutex);
63417 + }
63418 +
63419 + return 0;
63420 +}
63421 +
63422 +const struct file_operations grsec_fops = {
63423 + .read = read_learn,
63424 + .write = write_grsec_handler,
63425 + .open = open_learn,
63426 + .release = close_learn,
63427 + .poll = poll_learn,
63428 +};
63429 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63430 new file mode 100644
63431 index 0000000..39645c9
63432 --- /dev/null
63433 +++ b/grsecurity/gracl_res.c
63434 @@ -0,0 +1,68 @@
63435 +#include <linux/kernel.h>
63436 +#include <linux/sched.h>
63437 +#include <linux/gracl.h>
63438 +#include <linux/grinternal.h>
63439 +
63440 +static const char *restab_log[] = {
63441 + [RLIMIT_CPU] = "RLIMIT_CPU",
63442 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63443 + [RLIMIT_DATA] = "RLIMIT_DATA",
63444 + [RLIMIT_STACK] = "RLIMIT_STACK",
63445 + [RLIMIT_CORE] = "RLIMIT_CORE",
63446 + [RLIMIT_RSS] = "RLIMIT_RSS",
63447 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63448 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63449 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63450 + [RLIMIT_AS] = "RLIMIT_AS",
63451 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63452 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63453 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63454 + [RLIMIT_NICE] = "RLIMIT_NICE",
63455 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63456 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63457 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63458 +};
63459 +
63460 +void
63461 +gr_log_resource(const struct task_struct *task,
63462 + const int res, const unsigned long wanted, const int gt)
63463 +{
63464 + const struct cred *cred;
63465 + unsigned long rlim;
63466 +
63467 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63468 + return;
63469 +
63470 + // not yet supported resource
63471 + if (unlikely(!restab_log[res]))
63472 + return;
63473 +
63474 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63475 + rlim = task_rlimit_max(task, res);
63476 + else
63477 + rlim = task_rlimit(task, res);
63478 +
63479 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63480 + return;
63481 +
63482 + rcu_read_lock();
63483 + cred = __task_cred(task);
63484 +
63485 + if (res == RLIMIT_NPROC &&
63486 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63487 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63488 + goto out_rcu_unlock;
63489 + else if (res == RLIMIT_MEMLOCK &&
63490 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63491 + goto out_rcu_unlock;
63492 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63493 + goto out_rcu_unlock;
63494 + rcu_read_unlock();
63495 +
63496 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63497 +
63498 + return;
63499 +out_rcu_unlock:
63500 + rcu_read_unlock();
63501 + return;
63502 +}
63503 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63504 new file mode 100644
63505 index 0000000..cb1e5ab
63506 --- /dev/null
63507 +++ b/grsecurity/gracl_segv.c
63508 @@ -0,0 +1,303 @@
63509 +#include <linux/kernel.h>
63510 +#include <linux/mm.h>
63511 +#include <asm/uaccess.h>
63512 +#include <asm/errno.h>
63513 +#include <asm/mman.h>
63514 +#include <net/sock.h>
63515 +#include <linux/file.h>
63516 +#include <linux/fs.h>
63517 +#include <linux/net.h>
63518 +#include <linux/in.h>
63519 +#include <linux/slab.h>
63520 +#include <linux/types.h>
63521 +#include <linux/sched.h>
63522 +#include <linux/timer.h>
63523 +#include <linux/gracl.h>
63524 +#include <linux/grsecurity.h>
63525 +#include <linux/grinternal.h>
63526 +
63527 +static struct crash_uid *uid_set;
63528 +static unsigned short uid_used;
63529 +static DEFINE_SPINLOCK(gr_uid_lock);
63530 +extern rwlock_t gr_inode_lock;
63531 +extern struct acl_subject_label *
63532 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63533 + struct acl_role_label *role);
63534 +
63535 +#ifdef CONFIG_BTRFS_FS
63536 +extern dev_t get_btrfs_dev_from_inode(struct inode *inode);
63537 +extern int btrfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
63538 +#endif
63539 +
63540 +static inline dev_t __get_dev(const struct dentry *dentry)
63541 +{
63542 +#ifdef CONFIG_BTRFS_FS
63543 + if (dentry->d_inode->i_op && dentry->d_inode->i_op->getattr == &btrfs_getattr)
63544 + return get_btrfs_dev_from_inode(dentry->d_inode);
63545 + else
63546 +#endif
63547 + return dentry->d_inode->i_sb->s_dev;
63548 +}
63549 +
63550 +int
63551 +gr_init_uidset(void)
63552 +{
63553 + uid_set =
63554 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63555 + uid_used = 0;
63556 +
63557 + return uid_set ? 1 : 0;
63558 +}
63559 +
63560 +void
63561 +gr_free_uidset(void)
63562 +{
63563 + if (uid_set)
63564 + kfree(uid_set);
63565 +
63566 + return;
63567 +}
63568 +
63569 +int
63570 +gr_find_uid(const uid_t uid)
63571 +{
63572 + struct crash_uid *tmp = uid_set;
63573 + uid_t buid;
63574 + int low = 0, high = uid_used - 1, mid;
63575 +
63576 + while (high >= low) {
63577 + mid = (low + high) >> 1;
63578 + buid = tmp[mid].uid;
63579 + if (buid == uid)
63580 + return mid;
63581 + if (buid > uid)
63582 + high = mid - 1;
63583 + if (buid < uid)
63584 + low = mid + 1;
63585 + }
63586 +
63587 + return -1;
63588 +}
63589 +
63590 +static __inline__ void
63591 +gr_insertsort(void)
63592 +{
63593 + unsigned short i, j;
63594 + struct crash_uid index;
63595 +
63596 + for (i = 1; i < uid_used; i++) {
63597 + index = uid_set[i];
63598 + j = i;
63599 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63600 + uid_set[j] = uid_set[j - 1];
63601 + j--;
63602 + }
63603 + uid_set[j] = index;
63604 + }
63605 +
63606 + return;
63607 +}
63608 +
63609 +static __inline__ void
63610 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63611 +{
63612 + int loc;
63613 + uid_t uid = GR_GLOBAL_UID(kuid);
63614 +
63615 + if (uid_used == GR_UIDTABLE_MAX)
63616 + return;
63617 +
63618 + loc = gr_find_uid(uid);
63619 +
63620 + if (loc >= 0) {
63621 + uid_set[loc].expires = expires;
63622 + return;
63623 + }
63624 +
63625 + uid_set[uid_used].uid = uid;
63626 + uid_set[uid_used].expires = expires;
63627 + uid_used++;
63628 +
63629 + gr_insertsort();
63630 +
63631 + return;
63632 +}
63633 +
63634 +void
63635 +gr_remove_uid(const unsigned short loc)
63636 +{
63637 + unsigned short i;
63638 +
63639 + for (i = loc + 1; i < uid_used; i++)
63640 + uid_set[i - 1] = uid_set[i];
63641 +
63642 + uid_used--;
63643 +
63644 + return;
63645 +}
63646 +
63647 +int
63648 +gr_check_crash_uid(const kuid_t kuid)
63649 +{
63650 + int loc;
63651 + int ret = 0;
63652 + uid_t uid;
63653 +
63654 + if (unlikely(!gr_acl_is_enabled()))
63655 + return 0;
63656 +
63657 + uid = GR_GLOBAL_UID(kuid);
63658 +
63659 + spin_lock(&gr_uid_lock);
63660 + loc = gr_find_uid(uid);
63661 +
63662 + if (loc < 0)
63663 + goto out_unlock;
63664 +
63665 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63666 + gr_remove_uid(loc);
63667 + else
63668 + ret = 1;
63669 +
63670 +out_unlock:
63671 + spin_unlock(&gr_uid_lock);
63672 + return ret;
63673 +}
63674 +
63675 +static __inline__ int
63676 +proc_is_setxid(const struct cred *cred)
63677 +{
63678 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63679 + !uid_eq(cred->uid, cred->fsuid))
63680 + return 1;
63681 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63682 + !gid_eq(cred->gid, cred->fsgid))
63683 + return 1;
63684 +
63685 + return 0;
63686 +}
63687 +
63688 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63689 +
63690 +void
63691 +gr_handle_crash(struct task_struct *task, const int sig)
63692 +{
63693 + struct acl_subject_label *curr;
63694 + struct task_struct *tsk, *tsk2;
63695 + const struct cred *cred;
63696 + const struct cred *cred2;
63697 +
63698 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63699 + return;
63700 +
63701 + if (unlikely(!gr_acl_is_enabled()))
63702 + return;
63703 +
63704 + curr = task->acl;
63705 +
63706 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63707 + return;
63708 +
63709 + if (time_before_eq(curr->expires, get_seconds())) {
63710 + curr->expires = 0;
63711 + curr->crashes = 0;
63712 + }
63713 +
63714 + curr->crashes++;
63715 +
63716 + if (!curr->expires)
63717 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63718 +
63719 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63720 + time_after(curr->expires, get_seconds())) {
63721 + rcu_read_lock();
63722 + cred = __task_cred(task);
63723 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63724 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63725 + spin_lock(&gr_uid_lock);
63726 + gr_insert_uid(cred->uid, curr->expires);
63727 + spin_unlock(&gr_uid_lock);
63728 + curr->expires = 0;
63729 + curr->crashes = 0;
63730 + read_lock(&tasklist_lock);
63731 + do_each_thread(tsk2, tsk) {
63732 + cred2 = __task_cred(tsk);
63733 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63734 + gr_fake_force_sig(SIGKILL, tsk);
63735 + } while_each_thread(tsk2, tsk);
63736 + read_unlock(&tasklist_lock);
63737 + } else {
63738 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63739 + read_lock(&tasklist_lock);
63740 + read_lock(&grsec_exec_file_lock);
63741 + do_each_thread(tsk2, tsk) {
63742 + if (likely(tsk != task)) {
63743 + // if this thread has the same subject as the one that triggered
63744 + // RES_CRASH and it's the same binary, kill it
63745 + if (tsk->acl == task->acl && tsk->exec_file == task->exec_file)
63746 + gr_fake_force_sig(SIGKILL, tsk);
63747 + }
63748 + } while_each_thread(tsk2, tsk);
63749 + read_unlock(&grsec_exec_file_lock);
63750 + read_unlock(&tasklist_lock);
63751 + }
63752 + rcu_read_unlock();
63753 + }
63754 +
63755 + return;
63756 +}
63757 +
63758 +int
63759 +gr_check_crash_exec(const struct file *filp)
63760 +{
63761 + struct acl_subject_label *curr;
63762 +
63763 + if (unlikely(!gr_acl_is_enabled()))
63764 + return 0;
63765 +
63766 + read_lock(&gr_inode_lock);
63767 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63768 + __get_dev(filp->f_path.dentry),
63769 + current->role);
63770 + read_unlock(&gr_inode_lock);
63771 +
63772 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63773 + (!curr->crashes && !curr->expires))
63774 + return 0;
63775 +
63776 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63777 + time_after(curr->expires, get_seconds()))
63778 + return 1;
63779 + else if (time_before_eq(curr->expires, get_seconds())) {
63780 + curr->crashes = 0;
63781 + curr->expires = 0;
63782 + }
63783 +
63784 + return 0;
63785 +}
63786 +
63787 +void
63788 +gr_handle_alertkill(struct task_struct *task)
63789 +{
63790 + struct acl_subject_label *curracl;
63791 + __u32 curr_ip;
63792 + struct task_struct *p, *p2;
63793 +
63794 + if (unlikely(!gr_acl_is_enabled()))
63795 + return;
63796 +
63797 + curracl = task->acl;
63798 + curr_ip = task->signal->curr_ip;
63799 +
63800 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63801 + read_lock(&tasklist_lock);
63802 + do_each_thread(p2, p) {
63803 + if (p->signal->curr_ip == curr_ip)
63804 + gr_fake_force_sig(SIGKILL, p);
63805 + } while_each_thread(p2, p);
63806 + read_unlock(&tasklist_lock);
63807 + } else if (curracl->mode & GR_KILLPROC)
63808 + gr_fake_force_sig(SIGKILL, task);
63809 +
63810 + return;
63811 +}
63812 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63813 new file mode 100644
63814 index 0000000..98011b0
63815 --- /dev/null
63816 +++ b/grsecurity/gracl_shm.c
63817 @@ -0,0 +1,40 @@
63818 +#include <linux/kernel.h>
63819 +#include <linux/mm.h>
63820 +#include <linux/sched.h>
63821 +#include <linux/file.h>
63822 +#include <linux/ipc.h>
63823 +#include <linux/gracl.h>
63824 +#include <linux/grsecurity.h>
63825 +#include <linux/grinternal.h>
63826 +
63827 +int
63828 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63829 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63830 +{
63831 + struct task_struct *task;
63832 +
63833 + if (!gr_acl_is_enabled())
63834 + return 1;
63835 +
63836 + rcu_read_lock();
63837 + read_lock(&tasklist_lock);
63838 +
63839 + task = find_task_by_vpid(shm_cprid);
63840 +
63841 + if (unlikely(!task))
63842 + task = find_task_by_vpid(shm_lapid);
63843 +
63844 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63845 + (task_pid_nr(task) == shm_lapid)) &&
63846 + (task->acl->mode & GR_PROTSHM) &&
63847 + (task->acl != current->acl))) {
63848 + read_unlock(&tasklist_lock);
63849 + rcu_read_unlock();
63850 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63851 + return 0;
63852 + }
63853 + read_unlock(&tasklist_lock);
63854 + rcu_read_unlock();
63855 +
63856 + return 1;
63857 +}
63858 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63859 new file mode 100644
63860 index 0000000..bc0be01
63861 --- /dev/null
63862 +++ b/grsecurity/grsec_chdir.c
63863 @@ -0,0 +1,19 @@
63864 +#include <linux/kernel.h>
63865 +#include <linux/sched.h>
63866 +#include <linux/fs.h>
63867 +#include <linux/file.h>
63868 +#include <linux/grsecurity.h>
63869 +#include <linux/grinternal.h>
63870 +
63871 +void
63872 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63873 +{
63874 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63875 + if ((grsec_enable_chdir && grsec_enable_group &&
63876 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63877 + !grsec_enable_group)) {
63878 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63879 + }
63880 +#endif
63881 + return;
63882 +}
63883 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63884 new file mode 100644
63885 index 0000000..6d2de57
63886 --- /dev/null
63887 +++ b/grsecurity/grsec_chroot.c
63888 @@ -0,0 +1,357 @@
63889 +#include <linux/kernel.h>
63890 +#include <linux/module.h>
63891 +#include <linux/sched.h>
63892 +#include <linux/file.h>
63893 +#include <linux/fs.h>
63894 +#include <linux/mount.h>
63895 +#include <linux/types.h>
63896 +#include "../fs/mount.h"
63897 +#include <linux/grsecurity.h>
63898 +#include <linux/grinternal.h>
63899 +
63900 +void gr_set_chroot_entries(struct task_struct *task, struct path *path)
63901 +{
63902 +#ifdef CONFIG_GRKERNSEC
63903 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
63904 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root)
63905 + task->gr_is_chrooted = 1;
63906 + else
63907 + task->gr_is_chrooted = 0;
63908 +
63909 + task->gr_chroot_dentry = path->dentry;
63910 +#endif
63911 + return;
63912 +}
63913 +
63914 +void gr_clear_chroot_entries(struct task_struct *task)
63915 +{
63916 +#ifdef CONFIG_GRKERNSEC
63917 + task->gr_is_chrooted = 0;
63918 + task->gr_chroot_dentry = NULL;
63919 +#endif
63920 + return;
63921 +}
63922 +
63923 +int
63924 +gr_handle_chroot_unix(const pid_t pid)
63925 +{
63926 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
63927 + struct task_struct *p;
63928 +
63929 + if (unlikely(!grsec_enable_chroot_unix))
63930 + return 1;
63931 +
63932 + if (likely(!proc_is_chrooted(current)))
63933 + return 1;
63934 +
63935 + rcu_read_lock();
63936 + read_lock(&tasklist_lock);
63937 + p = find_task_by_vpid_unrestricted(pid);
63938 + if (unlikely(p && !have_same_root(current, p))) {
63939 + read_unlock(&tasklist_lock);
63940 + rcu_read_unlock();
63941 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
63942 + return 0;
63943 + }
63944 + read_unlock(&tasklist_lock);
63945 + rcu_read_unlock();
63946 +#endif
63947 + return 1;
63948 +}
63949 +
63950 +int
63951 +gr_handle_chroot_nice(void)
63952 +{
63953 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63954 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
63955 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
63956 + return -EPERM;
63957 + }
63958 +#endif
63959 + return 0;
63960 +}
63961 +
63962 +int
63963 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
63964 +{
63965 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
63966 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
63967 + && proc_is_chrooted(current)) {
63968 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
63969 + return -EACCES;
63970 + }
63971 +#endif
63972 + return 0;
63973 +}
63974 +
63975 +int
63976 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
63977 +{
63978 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
63979 + struct task_struct *p;
63980 + int ret = 0;
63981 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
63982 + return ret;
63983 +
63984 + read_lock(&tasklist_lock);
63985 + do_each_pid_task(pid, type, p) {
63986 + if (!have_same_root(current, p)) {
63987 + ret = 1;
63988 + goto out;
63989 + }
63990 + } while_each_pid_task(pid, type, p);
63991 +out:
63992 + read_unlock(&tasklist_lock);
63993 + return ret;
63994 +#endif
63995 + return 0;
63996 +}
63997 +
63998 +int
63999 +gr_pid_is_chrooted(struct task_struct *p)
64000 +{
64001 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64002 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64003 + return 0;
64004 +
64005 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64006 + !have_same_root(current, p)) {
64007 + return 1;
64008 + }
64009 +#endif
64010 + return 0;
64011 +}
64012 +
64013 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64014 +
64015 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64016 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64017 +{
64018 + struct path path, currentroot;
64019 + int ret = 0;
64020 +
64021 + path.dentry = (struct dentry *)u_dentry;
64022 + path.mnt = (struct vfsmount *)u_mnt;
64023 + get_fs_root(current->fs, &currentroot);
64024 + if (path_is_under(&path, &currentroot))
64025 + ret = 1;
64026 + path_put(&currentroot);
64027 +
64028 + return ret;
64029 +}
64030 +#endif
64031 +
64032 +int
64033 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64034 +{
64035 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64036 + if (!grsec_enable_chroot_fchdir)
64037 + return 1;
64038 +
64039 + if (!proc_is_chrooted(current))
64040 + return 1;
64041 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64042 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64043 + return 0;
64044 + }
64045 +#endif
64046 + return 1;
64047 +}
64048 +
64049 +int
64050 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64051 + const time_t shm_createtime)
64052 +{
64053 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64054 + struct task_struct *p;
64055 + time_t starttime;
64056 +
64057 + if (unlikely(!grsec_enable_chroot_shmat))
64058 + return 1;
64059 +
64060 + if (likely(!proc_is_chrooted(current)))
64061 + return 1;
64062 +
64063 + rcu_read_lock();
64064 + read_lock(&tasklist_lock);
64065 +
64066 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64067 + starttime = p->start_time.tv_sec;
64068 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64069 + if (have_same_root(current, p)) {
64070 + goto allow;
64071 + } else {
64072 + read_unlock(&tasklist_lock);
64073 + rcu_read_unlock();
64074 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64075 + return 0;
64076 + }
64077 + }
64078 + /* creator exited, pid reuse, fall through to next check */
64079 + }
64080 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64081 + if (unlikely(!have_same_root(current, p))) {
64082 + read_unlock(&tasklist_lock);
64083 + rcu_read_unlock();
64084 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64085 + return 0;
64086 + }
64087 + }
64088 +
64089 +allow:
64090 + read_unlock(&tasklist_lock);
64091 + rcu_read_unlock();
64092 +#endif
64093 + return 1;
64094 +}
64095 +
64096 +void
64097 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64098 +{
64099 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64100 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64101 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64102 +#endif
64103 + return;
64104 +}
64105 +
64106 +int
64107 +gr_handle_chroot_mknod(const struct dentry *dentry,
64108 + const struct vfsmount *mnt, const int mode)
64109 +{
64110 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64111 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64112 + proc_is_chrooted(current)) {
64113 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64114 + return -EPERM;
64115 + }
64116 +#endif
64117 + return 0;
64118 +}
64119 +
64120 +int
64121 +gr_handle_chroot_mount(const struct dentry *dentry,
64122 + const struct vfsmount *mnt, const char *dev_name)
64123 +{
64124 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64125 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64126 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64127 + return -EPERM;
64128 + }
64129 +#endif
64130 + return 0;
64131 +}
64132 +
64133 +int
64134 +gr_handle_chroot_pivot(void)
64135 +{
64136 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64137 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64138 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64139 + return -EPERM;
64140 + }
64141 +#endif
64142 + return 0;
64143 +}
64144 +
64145 +int
64146 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64147 +{
64148 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64149 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64150 + !gr_is_outside_chroot(dentry, mnt)) {
64151 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64152 + return -EPERM;
64153 + }
64154 +#endif
64155 + return 0;
64156 +}
64157 +
64158 +extern const char *captab_log[];
64159 +extern int captab_log_entries;
64160 +
64161 +int
64162 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64163 +{
64164 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64165 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64166 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64167 + if (cap_raised(chroot_caps, cap)) {
64168 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64169 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64170 + }
64171 + return 0;
64172 + }
64173 + }
64174 +#endif
64175 + return 1;
64176 +}
64177 +
64178 +int
64179 +gr_chroot_is_capable(const int cap)
64180 +{
64181 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64182 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64183 +#endif
64184 + return 1;
64185 +}
64186 +
64187 +int
64188 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64189 +{
64190 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64191 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64192 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64193 + if (cap_raised(chroot_caps, cap)) {
64194 + return 0;
64195 + }
64196 + }
64197 +#endif
64198 + return 1;
64199 +}
64200 +
64201 +int
64202 +gr_chroot_is_capable_nolog(const int cap)
64203 +{
64204 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64205 + return gr_task_chroot_is_capable_nolog(current, cap);
64206 +#endif
64207 + return 1;
64208 +}
64209 +
64210 +int
64211 +gr_handle_chroot_sysctl(const int op)
64212 +{
64213 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64214 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64215 + proc_is_chrooted(current))
64216 + return -EACCES;
64217 +#endif
64218 + return 0;
64219 +}
64220 +
64221 +void
64222 +gr_handle_chroot_chdir(struct path *path)
64223 +{
64224 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64225 + if (grsec_enable_chroot_chdir)
64226 + set_fs_pwd(current->fs, path);
64227 +#endif
64228 + return;
64229 +}
64230 +
64231 +int
64232 +gr_handle_chroot_chmod(const struct dentry *dentry,
64233 + const struct vfsmount *mnt, const int mode)
64234 +{
64235 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64236 + /* allow chmod +s on directories, but not files */
64237 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64238 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64239 + proc_is_chrooted(current)) {
64240 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64241 + return -EPERM;
64242 + }
64243 +#endif
64244 + return 0;
64245 +}
64246 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64247 new file mode 100644
64248 index 0000000..207d409
64249 --- /dev/null
64250 +++ b/grsecurity/grsec_disabled.c
64251 @@ -0,0 +1,434 @@
64252 +#include <linux/kernel.h>
64253 +#include <linux/module.h>
64254 +#include <linux/sched.h>
64255 +#include <linux/file.h>
64256 +#include <linux/fs.h>
64257 +#include <linux/kdev_t.h>
64258 +#include <linux/net.h>
64259 +#include <linux/in.h>
64260 +#include <linux/ip.h>
64261 +#include <linux/skbuff.h>
64262 +#include <linux/sysctl.h>
64263 +
64264 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64265 +void
64266 +pax_set_initial_flags(struct linux_binprm *bprm)
64267 +{
64268 + return;
64269 +}
64270 +#endif
64271 +
64272 +#ifdef CONFIG_SYSCTL
64273 +__u32
64274 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64275 +{
64276 + return 0;
64277 +}
64278 +#endif
64279 +
64280 +#ifdef CONFIG_TASKSTATS
64281 +int gr_is_taskstats_denied(int pid)
64282 +{
64283 + return 0;
64284 +}
64285 +#endif
64286 +
64287 +int
64288 +gr_acl_is_enabled(void)
64289 +{
64290 + return 0;
64291 +}
64292 +
64293 +void
64294 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64295 +{
64296 + return;
64297 +}
64298 +
64299 +int
64300 +gr_handle_rawio(const struct inode *inode)
64301 +{
64302 + return 0;
64303 +}
64304 +
64305 +void
64306 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64307 +{
64308 + return;
64309 +}
64310 +
64311 +int
64312 +gr_handle_ptrace(struct task_struct *task, const long request)
64313 +{
64314 + return 0;
64315 +}
64316 +
64317 +int
64318 +gr_handle_proc_ptrace(struct task_struct *task)
64319 +{
64320 + return 0;
64321 +}
64322 +
64323 +int
64324 +gr_set_acls(const int type)
64325 +{
64326 + return 0;
64327 +}
64328 +
64329 +int
64330 +gr_check_hidden_task(const struct task_struct *tsk)
64331 +{
64332 + return 0;
64333 +}
64334 +
64335 +int
64336 +gr_check_protected_task(const struct task_struct *task)
64337 +{
64338 + return 0;
64339 +}
64340 +
64341 +int
64342 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64343 +{
64344 + return 0;
64345 +}
64346 +
64347 +void
64348 +gr_copy_label(struct task_struct *tsk)
64349 +{
64350 + return;
64351 +}
64352 +
64353 +void
64354 +gr_set_pax_flags(struct task_struct *task)
64355 +{
64356 + return;
64357 +}
64358 +
64359 +int
64360 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64361 + const int unsafe_share)
64362 +{
64363 + return 0;
64364 +}
64365 +
64366 +void
64367 +gr_handle_delete(const ino_t ino, const dev_t dev)
64368 +{
64369 + return;
64370 +}
64371 +
64372 +void
64373 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64374 +{
64375 + return;
64376 +}
64377 +
64378 +void
64379 +gr_handle_crash(struct task_struct *task, const int sig)
64380 +{
64381 + return;
64382 +}
64383 +
64384 +int
64385 +gr_check_crash_exec(const struct file *filp)
64386 +{
64387 + return 0;
64388 +}
64389 +
64390 +int
64391 +gr_check_crash_uid(const kuid_t uid)
64392 +{
64393 + return 0;
64394 +}
64395 +
64396 +void
64397 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64398 + struct dentry *old_dentry,
64399 + struct dentry *new_dentry,
64400 + struct vfsmount *mnt, const __u8 replace)
64401 +{
64402 + return;
64403 +}
64404 +
64405 +int
64406 +gr_search_socket(const int family, const int type, const int protocol)
64407 +{
64408 + return 1;
64409 +}
64410 +
64411 +int
64412 +gr_search_connectbind(const int mode, const struct socket *sock,
64413 + const struct sockaddr_in *addr)
64414 +{
64415 + return 0;
64416 +}
64417 +
64418 +void
64419 +gr_handle_alertkill(struct task_struct *task)
64420 +{
64421 + return;
64422 +}
64423 +
64424 +__u32
64425 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64426 +{
64427 + return 1;
64428 +}
64429 +
64430 +__u32
64431 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64432 + const struct vfsmount * mnt)
64433 +{
64434 + return 1;
64435 +}
64436 +
64437 +__u32
64438 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64439 + int acc_mode)
64440 +{
64441 + return 1;
64442 +}
64443 +
64444 +__u32
64445 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64446 +{
64447 + return 1;
64448 +}
64449 +
64450 +__u32
64451 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64452 +{
64453 + return 1;
64454 +}
64455 +
64456 +int
64457 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64458 + unsigned int *vm_flags)
64459 +{
64460 + return 1;
64461 +}
64462 +
64463 +__u32
64464 +gr_acl_handle_truncate(const struct dentry * dentry,
64465 + const struct vfsmount * mnt)
64466 +{
64467 + return 1;
64468 +}
64469 +
64470 +__u32
64471 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64472 +{
64473 + return 1;
64474 +}
64475 +
64476 +__u32
64477 +gr_acl_handle_access(const struct dentry * dentry,
64478 + const struct vfsmount * mnt, const int fmode)
64479 +{
64480 + return 1;
64481 +}
64482 +
64483 +__u32
64484 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64485 + umode_t *mode)
64486 +{
64487 + return 1;
64488 +}
64489 +
64490 +__u32
64491 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64492 +{
64493 + return 1;
64494 +}
64495 +
64496 +__u32
64497 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64498 +{
64499 + return 1;
64500 +}
64501 +
64502 +void
64503 +grsecurity_init(void)
64504 +{
64505 + return;
64506 +}
64507 +
64508 +umode_t gr_acl_umask(void)
64509 +{
64510 + return 0;
64511 +}
64512 +
64513 +__u32
64514 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64515 + const struct dentry * parent_dentry,
64516 + const struct vfsmount * parent_mnt,
64517 + const int mode)
64518 +{
64519 + return 1;
64520 +}
64521 +
64522 +__u32
64523 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64524 + const struct dentry * parent_dentry,
64525 + const struct vfsmount * parent_mnt)
64526 +{
64527 + return 1;
64528 +}
64529 +
64530 +__u32
64531 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64532 + const struct dentry * parent_dentry,
64533 + const struct vfsmount * parent_mnt, const struct filename *from)
64534 +{
64535 + return 1;
64536 +}
64537 +
64538 +__u32
64539 +gr_acl_handle_link(const struct dentry * new_dentry,
64540 + const struct dentry * parent_dentry,
64541 + const struct vfsmount * parent_mnt,
64542 + const struct dentry * old_dentry,
64543 + const struct vfsmount * old_mnt, const struct filename *to)
64544 +{
64545 + return 1;
64546 +}
64547 +
64548 +int
64549 +gr_acl_handle_rename(const struct dentry *new_dentry,
64550 + const struct dentry *parent_dentry,
64551 + const struct vfsmount *parent_mnt,
64552 + const struct dentry *old_dentry,
64553 + const struct inode *old_parent_inode,
64554 + const struct vfsmount *old_mnt, const struct filename *newname)
64555 +{
64556 + return 0;
64557 +}
64558 +
64559 +int
64560 +gr_acl_handle_filldir(const struct file *file, const char *name,
64561 + const int namelen, const ino_t ino)
64562 +{
64563 + return 1;
64564 +}
64565 +
64566 +int
64567 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64568 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64569 +{
64570 + return 1;
64571 +}
64572 +
64573 +int
64574 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64575 +{
64576 + return 0;
64577 +}
64578 +
64579 +int
64580 +gr_search_accept(const struct socket *sock)
64581 +{
64582 + return 0;
64583 +}
64584 +
64585 +int
64586 +gr_search_listen(const struct socket *sock)
64587 +{
64588 + return 0;
64589 +}
64590 +
64591 +int
64592 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64593 +{
64594 + return 0;
64595 +}
64596 +
64597 +__u32
64598 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64599 +{
64600 + return 1;
64601 +}
64602 +
64603 +__u32
64604 +gr_acl_handle_creat(const struct dentry * dentry,
64605 + const struct dentry * p_dentry,
64606 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64607 + const int imode)
64608 +{
64609 + return 1;
64610 +}
64611 +
64612 +void
64613 +gr_acl_handle_exit(void)
64614 +{
64615 + return;
64616 +}
64617 +
64618 +int
64619 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64620 +{
64621 + return 1;
64622 +}
64623 +
64624 +void
64625 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64626 +{
64627 + return;
64628 +}
64629 +
64630 +int
64631 +gr_acl_handle_procpidmem(const struct task_struct *task)
64632 +{
64633 + return 0;
64634 +}
64635 +
64636 +int
64637 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64638 +{
64639 + return 0;
64640 +}
64641 +
64642 +int
64643 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64644 +{
64645 + return 0;
64646 +}
64647 +
64648 +void
64649 +gr_set_kernel_label(struct task_struct *task)
64650 +{
64651 + return;
64652 +}
64653 +
64654 +int
64655 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64656 +{
64657 + return 0;
64658 +}
64659 +
64660 +int
64661 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64662 +{
64663 + return 0;
64664 +}
64665 +
64666 +int gr_acl_enable_at_secure(void)
64667 +{
64668 + return 0;
64669 +}
64670 +
64671 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64672 +{
64673 + return dentry->d_inode->i_sb->s_dev;
64674 +}
64675 +
64676 +void gr_put_exec_file(struct task_struct *task)
64677 +{
64678 + return;
64679 +}
64680 +
64681 +EXPORT_SYMBOL(gr_set_kernel_label);
64682 +#ifdef CONFIG_SECURITY
64683 +EXPORT_SYMBOL(gr_check_user_change);
64684 +EXPORT_SYMBOL(gr_check_group_change);
64685 +#endif
64686 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64687 new file mode 100644
64688 index 0000000..387032b
64689 --- /dev/null
64690 +++ b/grsecurity/grsec_exec.c
64691 @@ -0,0 +1,187 @@
64692 +#include <linux/kernel.h>
64693 +#include <linux/sched.h>
64694 +#include <linux/file.h>
64695 +#include <linux/binfmts.h>
64696 +#include <linux/fs.h>
64697 +#include <linux/types.h>
64698 +#include <linux/grdefs.h>
64699 +#include <linux/grsecurity.h>
64700 +#include <linux/grinternal.h>
64701 +#include <linux/capability.h>
64702 +#include <linux/module.h>
64703 +#include <linux/compat.h>
64704 +
64705 +#include <asm/uaccess.h>
64706 +
64707 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64708 +static char gr_exec_arg_buf[132];
64709 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64710 +#endif
64711 +
64712 +struct user_arg_ptr {
64713 +#ifdef CONFIG_COMPAT
64714 + bool is_compat;
64715 +#endif
64716 + union {
64717 + const char __user *const __user *native;
64718 +#ifdef CONFIG_COMPAT
64719 + const compat_uptr_t __user *compat;
64720 +#endif
64721 + } ptr;
64722 +};
64723 +
64724 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64725 +
64726 +void
64727 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64728 +{
64729 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64730 + char *grarg = gr_exec_arg_buf;
64731 + unsigned int i, x, execlen = 0;
64732 + char c;
64733 +
64734 + if (!((grsec_enable_execlog && grsec_enable_group &&
64735 + in_group_p(grsec_audit_gid))
64736 + || (grsec_enable_execlog && !grsec_enable_group)))
64737 + return;
64738 +
64739 + mutex_lock(&gr_exec_arg_mutex);
64740 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64741 +
64742 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64743 + const char __user *p;
64744 + unsigned int len;
64745 +
64746 + p = get_user_arg_ptr(argv, i);
64747 + if (IS_ERR(p))
64748 + goto log;
64749 +
64750 + len = strnlen_user(p, 128 - execlen);
64751 + if (len > 128 - execlen)
64752 + len = 128 - execlen;
64753 + else if (len > 0)
64754 + len--;
64755 + if (copy_from_user(grarg + execlen, p, len))
64756 + goto log;
64757 +
64758 + /* rewrite unprintable characters */
64759 + for (x = 0; x < len; x++) {
64760 + c = *(grarg + execlen + x);
64761 + if (c < 32 || c > 126)
64762 + *(grarg + execlen + x) = ' ';
64763 + }
64764 +
64765 + execlen += len;
64766 + *(grarg + execlen) = ' ';
64767 + *(grarg + execlen + 1) = '\0';
64768 + execlen++;
64769 + }
64770 +
64771 + log:
64772 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64773 + bprm->file->f_path.mnt, grarg);
64774 + mutex_unlock(&gr_exec_arg_mutex);
64775 +#endif
64776 + return;
64777 +}
64778 +
64779 +#ifdef CONFIG_GRKERNSEC
64780 +extern int gr_acl_is_capable(const int cap);
64781 +extern int gr_acl_is_capable_nolog(const int cap);
64782 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64783 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64784 +extern int gr_chroot_is_capable(const int cap);
64785 +extern int gr_chroot_is_capable_nolog(const int cap);
64786 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64787 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64788 +#endif
64789 +
64790 +const char *captab_log[] = {
64791 + "CAP_CHOWN",
64792 + "CAP_DAC_OVERRIDE",
64793 + "CAP_DAC_READ_SEARCH",
64794 + "CAP_FOWNER",
64795 + "CAP_FSETID",
64796 + "CAP_KILL",
64797 + "CAP_SETGID",
64798 + "CAP_SETUID",
64799 + "CAP_SETPCAP",
64800 + "CAP_LINUX_IMMUTABLE",
64801 + "CAP_NET_BIND_SERVICE",
64802 + "CAP_NET_BROADCAST",
64803 + "CAP_NET_ADMIN",
64804 + "CAP_NET_RAW",
64805 + "CAP_IPC_LOCK",
64806 + "CAP_IPC_OWNER",
64807 + "CAP_SYS_MODULE",
64808 + "CAP_SYS_RAWIO",
64809 + "CAP_SYS_CHROOT",
64810 + "CAP_SYS_PTRACE",
64811 + "CAP_SYS_PACCT",
64812 + "CAP_SYS_ADMIN",
64813 + "CAP_SYS_BOOT",
64814 + "CAP_SYS_NICE",
64815 + "CAP_SYS_RESOURCE",
64816 + "CAP_SYS_TIME",
64817 + "CAP_SYS_TTY_CONFIG",
64818 + "CAP_MKNOD",
64819 + "CAP_LEASE",
64820 + "CAP_AUDIT_WRITE",
64821 + "CAP_AUDIT_CONTROL",
64822 + "CAP_SETFCAP",
64823 + "CAP_MAC_OVERRIDE",
64824 + "CAP_MAC_ADMIN",
64825 + "CAP_SYSLOG",
64826 + "CAP_WAKE_ALARM"
64827 +};
64828 +
64829 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64830 +
64831 +int gr_is_capable(const int cap)
64832 +{
64833 +#ifdef CONFIG_GRKERNSEC
64834 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64835 + return 1;
64836 + return 0;
64837 +#else
64838 + return 1;
64839 +#endif
64840 +}
64841 +
64842 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64843 +{
64844 +#ifdef CONFIG_GRKERNSEC
64845 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64846 + return 1;
64847 + return 0;
64848 +#else
64849 + return 1;
64850 +#endif
64851 +}
64852 +
64853 +int gr_is_capable_nolog(const int cap)
64854 +{
64855 +#ifdef CONFIG_GRKERNSEC
64856 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64857 + return 1;
64858 + return 0;
64859 +#else
64860 + return 1;
64861 +#endif
64862 +}
64863 +
64864 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64865 +{
64866 +#ifdef CONFIG_GRKERNSEC
64867 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64868 + return 1;
64869 + return 0;
64870 +#else
64871 + return 1;
64872 +#endif
64873 +}
64874 +
64875 +EXPORT_SYMBOL(gr_is_capable);
64876 +EXPORT_SYMBOL(gr_is_capable_nolog);
64877 +EXPORT_SYMBOL(gr_task_is_capable);
64878 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64879 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64880 new file mode 100644
64881 index 0000000..06cc6ea
64882 --- /dev/null
64883 +++ b/grsecurity/grsec_fifo.c
64884 @@ -0,0 +1,24 @@
64885 +#include <linux/kernel.h>
64886 +#include <linux/sched.h>
64887 +#include <linux/fs.h>
64888 +#include <linux/file.h>
64889 +#include <linux/grinternal.h>
64890 +
64891 +int
64892 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
64893 + const struct dentry *dir, const int flag, const int acc_mode)
64894 +{
64895 +#ifdef CONFIG_GRKERNSEC_FIFO
64896 + const struct cred *cred = current_cred();
64897 +
64898 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
64899 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
64900 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
64901 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
64902 + if (!inode_permission(dentry->d_inode, acc_mode))
64903 + 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));
64904 + return -EACCES;
64905 + }
64906 +#endif
64907 + return 0;
64908 +}
64909 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
64910 new file mode 100644
64911 index 0000000..8ca18bf
64912 --- /dev/null
64913 +++ b/grsecurity/grsec_fork.c
64914 @@ -0,0 +1,23 @@
64915 +#include <linux/kernel.h>
64916 +#include <linux/sched.h>
64917 +#include <linux/grsecurity.h>
64918 +#include <linux/grinternal.h>
64919 +#include <linux/errno.h>
64920 +
64921 +void
64922 +gr_log_forkfail(const int retval)
64923 +{
64924 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
64925 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
64926 + switch (retval) {
64927 + case -EAGAIN:
64928 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
64929 + break;
64930 + case -ENOMEM:
64931 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
64932 + break;
64933 + }
64934 + }
64935 +#endif
64936 + return;
64937 +}
64938 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
64939 new file mode 100644
64940 index 0000000..a862e9f
64941 --- /dev/null
64942 +++ b/grsecurity/grsec_init.c
64943 @@ -0,0 +1,283 @@
64944 +#include <linux/kernel.h>
64945 +#include <linux/sched.h>
64946 +#include <linux/mm.h>
64947 +#include <linux/gracl.h>
64948 +#include <linux/slab.h>
64949 +#include <linux/vmalloc.h>
64950 +#include <linux/percpu.h>
64951 +#include <linux/module.h>
64952 +
64953 +int grsec_enable_ptrace_readexec;
64954 +int grsec_enable_setxid;
64955 +int grsec_enable_symlinkown;
64956 +kgid_t grsec_symlinkown_gid;
64957 +int grsec_enable_brute;
64958 +int grsec_enable_link;
64959 +int grsec_enable_dmesg;
64960 +int grsec_enable_harden_ptrace;
64961 +int grsec_enable_fifo;
64962 +int grsec_enable_execlog;
64963 +int grsec_enable_signal;
64964 +int grsec_enable_forkfail;
64965 +int grsec_enable_audit_ptrace;
64966 +int grsec_enable_time;
64967 +int grsec_enable_audit_textrel;
64968 +int grsec_enable_group;
64969 +kgid_t grsec_audit_gid;
64970 +int grsec_enable_chdir;
64971 +int grsec_enable_mount;
64972 +int grsec_enable_rofs;
64973 +int grsec_enable_chroot_findtask;
64974 +int grsec_enable_chroot_mount;
64975 +int grsec_enable_chroot_shmat;
64976 +int grsec_enable_chroot_fchdir;
64977 +int grsec_enable_chroot_double;
64978 +int grsec_enable_chroot_pivot;
64979 +int grsec_enable_chroot_chdir;
64980 +int grsec_enable_chroot_chmod;
64981 +int grsec_enable_chroot_mknod;
64982 +int grsec_enable_chroot_nice;
64983 +int grsec_enable_chroot_execlog;
64984 +int grsec_enable_chroot_caps;
64985 +int grsec_enable_chroot_sysctl;
64986 +int grsec_enable_chroot_unix;
64987 +int grsec_enable_tpe;
64988 +kgid_t grsec_tpe_gid;
64989 +int grsec_enable_blackhole;
64990 +#ifdef CONFIG_IPV6_MODULE
64991 +EXPORT_SYMBOL(grsec_enable_blackhole);
64992 +#endif
64993 +int grsec_lastack_retries;
64994 +int grsec_enable_tpe_all;
64995 +int grsec_enable_tpe_invert;
64996 +int grsec_enable_socket_all;
64997 +kgid_t grsec_socket_all_gid;
64998 +int grsec_enable_socket_client;
64999 +kgid_t grsec_socket_client_gid;
65000 +int grsec_enable_socket_server;
65001 +kgid_t grsec_socket_server_gid;
65002 +int grsec_resource_logging;
65003 +int grsec_disable_privio;
65004 +int grsec_enable_log_rwxmaps;
65005 +int grsec_lock;
65006 +
65007 +DEFINE_SPINLOCK(grsec_alert_lock);
65008 +unsigned long grsec_alert_wtime = 0;
65009 +unsigned long grsec_alert_fyet = 0;
65010 +
65011 +DEFINE_SPINLOCK(grsec_audit_lock);
65012 +
65013 +DEFINE_RWLOCK(grsec_exec_file_lock);
65014 +
65015 +char *gr_shared_page[4];
65016 +
65017 +char *gr_alert_log_fmt;
65018 +char *gr_audit_log_fmt;
65019 +char *gr_alert_log_buf;
65020 +char *gr_audit_log_buf;
65021 +
65022 +extern struct gr_arg *gr_usermode;
65023 +extern unsigned char *gr_system_salt;
65024 +extern unsigned char *gr_system_sum;
65025 +
65026 +void __init
65027 +grsecurity_init(void)
65028 +{
65029 + int j;
65030 + /* create the per-cpu shared pages */
65031 +
65032 +#ifdef CONFIG_X86
65033 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65034 +#endif
65035 +
65036 + for (j = 0; j < 4; j++) {
65037 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65038 + if (gr_shared_page[j] == NULL) {
65039 + panic("Unable to allocate grsecurity shared page");
65040 + return;
65041 + }
65042 + }
65043 +
65044 + /* allocate log buffers */
65045 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65046 + if (!gr_alert_log_fmt) {
65047 + panic("Unable to allocate grsecurity alert log format buffer");
65048 + return;
65049 + }
65050 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65051 + if (!gr_audit_log_fmt) {
65052 + panic("Unable to allocate grsecurity audit log format buffer");
65053 + return;
65054 + }
65055 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65056 + if (!gr_alert_log_buf) {
65057 + panic("Unable to allocate grsecurity alert log buffer");
65058 + return;
65059 + }
65060 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65061 + if (!gr_audit_log_buf) {
65062 + panic("Unable to allocate grsecurity audit log buffer");
65063 + return;
65064 + }
65065 +
65066 + /* allocate memory for authentication structure */
65067 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65068 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65069 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65070 +
65071 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65072 + panic("Unable to allocate grsecurity authentication structure");
65073 + return;
65074 + }
65075 +
65076 +
65077 +#ifdef CONFIG_GRKERNSEC_IO
65078 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65079 + grsec_disable_privio = 1;
65080 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65081 + grsec_disable_privio = 1;
65082 +#else
65083 + grsec_disable_privio = 0;
65084 +#endif
65085 +#endif
65086 +
65087 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65088 + /* for backward compatibility, tpe_invert always defaults to on if
65089 + enabled in the kernel
65090 + */
65091 + grsec_enable_tpe_invert = 1;
65092 +#endif
65093 +
65094 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65095 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65096 + grsec_lock = 1;
65097 +#endif
65098 +
65099 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65100 + grsec_enable_audit_textrel = 1;
65101 +#endif
65102 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65103 + grsec_enable_log_rwxmaps = 1;
65104 +#endif
65105 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65106 + grsec_enable_group = 1;
65107 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65108 +#endif
65109 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65110 + grsec_enable_ptrace_readexec = 1;
65111 +#endif
65112 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65113 + grsec_enable_chdir = 1;
65114 +#endif
65115 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65116 + grsec_enable_harden_ptrace = 1;
65117 +#endif
65118 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65119 + grsec_enable_mount = 1;
65120 +#endif
65121 +#ifdef CONFIG_GRKERNSEC_LINK
65122 + grsec_enable_link = 1;
65123 +#endif
65124 +#ifdef CONFIG_GRKERNSEC_BRUTE
65125 + grsec_enable_brute = 1;
65126 +#endif
65127 +#ifdef CONFIG_GRKERNSEC_DMESG
65128 + grsec_enable_dmesg = 1;
65129 +#endif
65130 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65131 + grsec_enable_blackhole = 1;
65132 + grsec_lastack_retries = 4;
65133 +#endif
65134 +#ifdef CONFIG_GRKERNSEC_FIFO
65135 + grsec_enable_fifo = 1;
65136 +#endif
65137 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65138 + grsec_enable_execlog = 1;
65139 +#endif
65140 +#ifdef CONFIG_GRKERNSEC_SETXID
65141 + grsec_enable_setxid = 1;
65142 +#endif
65143 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65144 + grsec_enable_signal = 1;
65145 +#endif
65146 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65147 + grsec_enable_forkfail = 1;
65148 +#endif
65149 +#ifdef CONFIG_GRKERNSEC_TIME
65150 + grsec_enable_time = 1;
65151 +#endif
65152 +#ifdef CONFIG_GRKERNSEC_RESLOG
65153 + grsec_resource_logging = 1;
65154 +#endif
65155 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65156 + grsec_enable_chroot_findtask = 1;
65157 +#endif
65158 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65159 + grsec_enable_chroot_unix = 1;
65160 +#endif
65161 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65162 + grsec_enable_chroot_mount = 1;
65163 +#endif
65164 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65165 + grsec_enable_chroot_fchdir = 1;
65166 +#endif
65167 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65168 + grsec_enable_chroot_shmat = 1;
65169 +#endif
65170 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65171 + grsec_enable_audit_ptrace = 1;
65172 +#endif
65173 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65174 + grsec_enable_chroot_double = 1;
65175 +#endif
65176 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65177 + grsec_enable_chroot_pivot = 1;
65178 +#endif
65179 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65180 + grsec_enable_chroot_chdir = 1;
65181 +#endif
65182 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65183 + grsec_enable_chroot_chmod = 1;
65184 +#endif
65185 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65186 + grsec_enable_chroot_mknod = 1;
65187 +#endif
65188 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65189 + grsec_enable_chroot_nice = 1;
65190 +#endif
65191 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65192 + grsec_enable_chroot_execlog = 1;
65193 +#endif
65194 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65195 + grsec_enable_chroot_caps = 1;
65196 +#endif
65197 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65198 + grsec_enable_chroot_sysctl = 1;
65199 +#endif
65200 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65201 + grsec_enable_symlinkown = 1;
65202 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65203 +#endif
65204 +#ifdef CONFIG_GRKERNSEC_TPE
65205 + grsec_enable_tpe = 1;
65206 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65207 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65208 + grsec_enable_tpe_all = 1;
65209 +#endif
65210 +#endif
65211 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65212 + grsec_enable_socket_all = 1;
65213 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65214 +#endif
65215 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65216 + grsec_enable_socket_client = 1;
65217 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65218 +#endif
65219 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65220 + grsec_enable_socket_server = 1;
65221 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65222 +#endif
65223 +#endif
65224 +
65225 + return;
65226 +}
65227 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65228 new file mode 100644
65229 index 0000000..5e05e20
65230 --- /dev/null
65231 +++ b/grsecurity/grsec_link.c
65232 @@ -0,0 +1,58 @@
65233 +#include <linux/kernel.h>
65234 +#include <linux/sched.h>
65235 +#include <linux/fs.h>
65236 +#include <linux/file.h>
65237 +#include <linux/grinternal.h>
65238 +
65239 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65240 +{
65241 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65242 + const struct inode *link_inode = link->dentry->d_inode;
65243 +
65244 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65245 + /* ignore root-owned links, e.g. /proc/self */
65246 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65247 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65248 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65249 + return 1;
65250 + }
65251 +#endif
65252 + return 0;
65253 +}
65254 +
65255 +int
65256 +gr_handle_follow_link(const struct inode *parent,
65257 + const struct inode *inode,
65258 + const struct dentry *dentry, const struct vfsmount *mnt)
65259 +{
65260 +#ifdef CONFIG_GRKERNSEC_LINK
65261 + const struct cred *cred = current_cred();
65262 +
65263 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65264 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65265 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65266 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65267 + return -EACCES;
65268 + }
65269 +#endif
65270 + return 0;
65271 +}
65272 +
65273 +int
65274 +gr_handle_hardlink(const struct dentry *dentry,
65275 + const struct vfsmount *mnt,
65276 + struct inode *inode, const int mode, const struct filename *to)
65277 +{
65278 +#ifdef CONFIG_GRKERNSEC_LINK
65279 + const struct cred *cred = current_cred();
65280 +
65281 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65282 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65283 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65284 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65285 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65286 + return -EPERM;
65287 + }
65288 +#endif
65289 + return 0;
65290 +}
65291 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65292 new file mode 100644
65293 index 0000000..7c06085
65294 --- /dev/null
65295 +++ b/grsecurity/grsec_log.c
65296 @@ -0,0 +1,326 @@
65297 +#include <linux/kernel.h>
65298 +#include <linux/sched.h>
65299 +#include <linux/file.h>
65300 +#include <linux/tty.h>
65301 +#include <linux/fs.h>
65302 +#include <linux/grinternal.h>
65303 +
65304 +#ifdef CONFIG_TREE_PREEMPT_RCU
65305 +#define DISABLE_PREEMPT() preempt_disable()
65306 +#define ENABLE_PREEMPT() preempt_enable()
65307 +#else
65308 +#define DISABLE_PREEMPT()
65309 +#define ENABLE_PREEMPT()
65310 +#endif
65311 +
65312 +#define BEGIN_LOCKS(x) \
65313 + DISABLE_PREEMPT(); \
65314 + rcu_read_lock(); \
65315 + read_lock(&tasklist_lock); \
65316 + read_lock(&grsec_exec_file_lock); \
65317 + if (x != GR_DO_AUDIT) \
65318 + spin_lock(&grsec_alert_lock); \
65319 + else \
65320 + spin_lock(&grsec_audit_lock)
65321 +
65322 +#define END_LOCKS(x) \
65323 + if (x != GR_DO_AUDIT) \
65324 + spin_unlock(&grsec_alert_lock); \
65325 + else \
65326 + spin_unlock(&grsec_audit_lock); \
65327 + read_unlock(&grsec_exec_file_lock); \
65328 + read_unlock(&tasklist_lock); \
65329 + rcu_read_unlock(); \
65330 + ENABLE_PREEMPT(); \
65331 + if (x == GR_DONT_AUDIT) \
65332 + gr_handle_alertkill(current)
65333 +
65334 +enum {
65335 + FLOODING,
65336 + NO_FLOODING
65337 +};
65338 +
65339 +extern char *gr_alert_log_fmt;
65340 +extern char *gr_audit_log_fmt;
65341 +extern char *gr_alert_log_buf;
65342 +extern char *gr_audit_log_buf;
65343 +
65344 +static int gr_log_start(int audit)
65345 +{
65346 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65347 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65348 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65349 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65350 + unsigned long curr_secs = get_seconds();
65351 +
65352 + if (audit == GR_DO_AUDIT)
65353 + goto set_fmt;
65354 +
65355 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65356 + grsec_alert_wtime = curr_secs;
65357 + grsec_alert_fyet = 0;
65358 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65359 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65360 + grsec_alert_fyet++;
65361 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65362 + grsec_alert_wtime = curr_secs;
65363 + grsec_alert_fyet++;
65364 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65365 + return FLOODING;
65366 + }
65367 + else return FLOODING;
65368 +
65369 +set_fmt:
65370 +#endif
65371 + memset(buf, 0, PAGE_SIZE);
65372 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65373 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65374 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65375 + } else if (current->signal->curr_ip) {
65376 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65377 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65378 + } else if (gr_acl_is_enabled()) {
65379 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65380 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65381 + } else {
65382 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65383 + strcpy(buf, fmt);
65384 + }
65385 +
65386 + return NO_FLOODING;
65387 +}
65388 +
65389 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65390 + __attribute__ ((format (printf, 2, 0)));
65391 +
65392 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65393 +{
65394 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65395 + unsigned int len = strlen(buf);
65396 +
65397 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65398 +
65399 + return;
65400 +}
65401 +
65402 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65403 + __attribute__ ((format (printf, 2, 3)));
65404 +
65405 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65406 +{
65407 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65408 + unsigned int len = strlen(buf);
65409 + va_list ap;
65410 +
65411 + va_start(ap, msg);
65412 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65413 + va_end(ap);
65414 +
65415 + return;
65416 +}
65417 +
65418 +static void gr_log_end(int audit, int append_default)
65419 +{
65420 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65421 + if (append_default) {
65422 + struct task_struct *task = current;
65423 + struct task_struct *parent = task->real_parent;
65424 + const struct cred *cred = __task_cred(task);
65425 + const struct cred *pcred = __task_cred(parent);
65426 + unsigned int len = strlen(buf);
65427 +
65428 + 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));
65429 + }
65430 +
65431 + printk("%s\n", buf);
65432 +
65433 + return;
65434 +}
65435 +
65436 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65437 +{
65438 + int logtype;
65439 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65440 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65441 + void *voidptr = NULL;
65442 + int num1 = 0, num2 = 0;
65443 + unsigned long ulong1 = 0, ulong2 = 0;
65444 + struct dentry *dentry = NULL;
65445 + struct vfsmount *mnt = NULL;
65446 + struct file *file = NULL;
65447 + struct task_struct *task = NULL;
65448 + const struct cred *cred, *pcred;
65449 + va_list ap;
65450 +
65451 + BEGIN_LOCKS(audit);
65452 + logtype = gr_log_start(audit);
65453 + if (logtype == FLOODING) {
65454 + END_LOCKS(audit);
65455 + return;
65456 + }
65457 + va_start(ap, argtypes);
65458 + switch (argtypes) {
65459 + case GR_TTYSNIFF:
65460 + task = va_arg(ap, struct task_struct *);
65461 + 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));
65462 + break;
65463 + case GR_SYSCTL_HIDDEN:
65464 + str1 = va_arg(ap, char *);
65465 + gr_log_middle_varargs(audit, msg, result, str1);
65466 + break;
65467 + case GR_RBAC:
65468 + dentry = va_arg(ap, struct dentry *);
65469 + mnt = va_arg(ap, struct vfsmount *);
65470 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65471 + break;
65472 + case GR_RBAC_STR:
65473 + dentry = va_arg(ap, struct dentry *);
65474 + mnt = va_arg(ap, struct vfsmount *);
65475 + str1 = va_arg(ap, char *);
65476 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65477 + break;
65478 + case GR_STR_RBAC:
65479 + str1 = va_arg(ap, char *);
65480 + dentry = va_arg(ap, struct dentry *);
65481 + mnt = va_arg(ap, struct vfsmount *);
65482 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65483 + break;
65484 + case GR_RBAC_MODE2:
65485 + dentry = va_arg(ap, struct dentry *);
65486 + mnt = va_arg(ap, struct vfsmount *);
65487 + str1 = va_arg(ap, char *);
65488 + str2 = va_arg(ap, char *);
65489 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65490 + break;
65491 + case GR_RBAC_MODE3:
65492 + dentry = va_arg(ap, struct dentry *);
65493 + mnt = va_arg(ap, struct vfsmount *);
65494 + str1 = va_arg(ap, char *);
65495 + str2 = va_arg(ap, char *);
65496 + str3 = va_arg(ap, char *);
65497 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65498 + break;
65499 + case GR_FILENAME:
65500 + dentry = va_arg(ap, struct dentry *);
65501 + mnt = va_arg(ap, struct vfsmount *);
65502 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65503 + break;
65504 + case GR_STR_FILENAME:
65505 + str1 = va_arg(ap, char *);
65506 + dentry = va_arg(ap, struct dentry *);
65507 + mnt = va_arg(ap, struct vfsmount *);
65508 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65509 + break;
65510 + case GR_FILENAME_STR:
65511 + dentry = va_arg(ap, struct dentry *);
65512 + mnt = va_arg(ap, struct vfsmount *);
65513 + str1 = va_arg(ap, char *);
65514 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65515 + break;
65516 + case GR_FILENAME_TWO_INT:
65517 + dentry = va_arg(ap, struct dentry *);
65518 + mnt = va_arg(ap, struct vfsmount *);
65519 + num1 = va_arg(ap, int);
65520 + num2 = va_arg(ap, int);
65521 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65522 + break;
65523 + case GR_FILENAME_TWO_INT_STR:
65524 + dentry = va_arg(ap, struct dentry *);
65525 + mnt = va_arg(ap, struct vfsmount *);
65526 + num1 = va_arg(ap, int);
65527 + num2 = va_arg(ap, int);
65528 + str1 = va_arg(ap, char *);
65529 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65530 + break;
65531 + case GR_TEXTREL:
65532 + file = va_arg(ap, struct file *);
65533 + ulong1 = va_arg(ap, unsigned long);
65534 + ulong2 = va_arg(ap, unsigned long);
65535 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65536 + break;
65537 + case GR_PTRACE:
65538 + task = va_arg(ap, struct task_struct *);
65539 + 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));
65540 + break;
65541 + case GR_RESOURCE:
65542 + task = va_arg(ap, struct task_struct *);
65543 + cred = __task_cred(task);
65544 + pcred = __task_cred(task->real_parent);
65545 + ulong1 = va_arg(ap, unsigned long);
65546 + str1 = va_arg(ap, char *);
65547 + ulong2 = va_arg(ap, unsigned long);
65548 + 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));
65549 + break;
65550 + case GR_CAP:
65551 + task = va_arg(ap, struct task_struct *);
65552 + cred = __task_cred(task);
65553 + pcred = __task_cred(task->real_parent);
65554 + str1 = va_arg(ap, char *);
65555 + 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));
65556 + break;
65557 + case GR_SIG:
65558 + str1 = va_arg(ap, char *);
65559 + voidptr = va_arg(ap, void *);
65560 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65561 + break;
65562 + case GR_SIG2:
65563 + task = va_arg(ap, struct task_struct *);
65564 + cred = __task_cred(task);
65565 + pcred = __task_cred(task->real_parent);
65566 + num1 = va_arg(ap, int);
65567 + 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));
65568 + break;
65569 + case GR_CRASH1:
65570 + task = va_arg(ap, struct task_struct *);
65571 + cred = __task_cred(task);
65572 + pcred = __task_cred(task->real_parent);
65573 + ulong1 = va_arg(ap, unsigned long);
65574 + 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);
65575 + break;
65576 + case GR_CRASH2:
65577 + task = va_arg(ap, struct task_struct *);
65578 + cred = __task_cred(task);
65579 + pcred = __task_cred(task->real_parent);
65580 + ulong1 = va_arg(ap, unsigned long);
65581 + 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);
65582 + break;
65583 + case GR_RWXMAP:
65584 + file = va_arg(ap, struct file *);
65585 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65586 + break;
65587 + case GR_PSACCT:
65588 + {
65589 + unsigned int wday, cday;
65590 + __u8 whr, chr;
65591 + __u8 wmin, cmin;
65592 + __u8 wsec, csec;
65593 + char cur_tty[64] = { 0 };
65594 + char parent_tty[64] = { 0 };
65595 +
65596 + task = va_arg(ap, struct task_struct *);
65597 + wday = va_arg(ap, unsigned int);
65598 + cday = va_arg(ap, unsigned int);
65599 + whr = va_arg(ap, int);
65600 + chr = va_arg(ap, int);
65601 + wmin = va_arg(ap, int);
65602 + cmin = va_arg(ap, int);
65603 + wsec = va_arg(ap, int);
65604 + csec = va_arg(ap, int);
65605 + ulong1 = va_arg(ap, unsigned long);
65606 + cred = __task_cred(task);
65607 + pcred = __task_cred(task->real_parent);
65608 +
65609 + 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));
65610 + }
65611 + break;
65612 + default:
65613 + gr_log_middle(audit, msg, ap);
65614 + }
65615 + va_end(ap);
65616 + // these don't need DEFAULTSECARGS printed on the end
65617 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65618 + gr_log_end(audit, 0);
65619 + else
65620 + gr_log_end(audit, 1);
65621 + END_LOCKS(audit);
65622 +}
65623 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65624 new file mode 100644
65625 index 0000000..f536303
65626 --- /dev/null
65627 +++ b/grsecurity/grsec_mem.c
65628 @@ -0,0 +1,40 @@
65629 +#include <linux/kernel.h>
65630 +#include <linux/sched.h>
65631 +#include <linux/mm.h>
65632 +#include <linux/mman.h>
65633 +#include <linux/grinternal.h>
65634 +
65635 +void
65636 +gr_handle_ioperm(void)
65637 +{
65638 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65639 + return;
65640 +}
65641 +
65642 +void
65643 +gr_handle_iopl(void)
65644 +{
65645 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65646 + return;
65647 +}
65648 +
65649 +void
65650 +gr_handle_mem_readwrite(u64 from, u64 to)
65651 +{
65652 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65653 + return;
65654 +}
65655 +
65656 +void
65657 +gr_handle_vm86(void)
65658 +{
65659 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65660 + return;
65661 +}
65662 +
65663 +void
65664 +gr_log_badprocpid(const char *entry)
65665 +{
65666 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65667 + return;
65668 +}
65669 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65670 new file mode 100644
65671 index 0000000..2131422
65672 --- /dev/null
65673 +++ b/grsecurity/grsec_mount.c
65674 @@ -0,0 +1,62 @@
65675 +#include <linux/kernel.h>
65676 +#include <linux/sched.h>
65677 +#include <linux/mount.h>
65678 +#include <linux/grsecurity.h>
65679 +#include <linux/grinternal.h>
65680 +
65681 +void
65682 +gr_log_remount(const char *devname, const int retval)
65683 +{
65684 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65685 + if (grsec_enable_mount && (retval >= 0))
65686 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65687 +#endif
65688 + return;
65689 +}
65690 +
65691 +void
65692 +gr_log_unmount(const char *devname, const int retval)
65693 +{
65694 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65695 + if (grsec_enable_mount && (retval >= 0))
65696 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65697 +#endif
65698 + return;
65699 +}
65700 +
65701 +void
65702 +gr_log_mount(const char *from, const char *to, const int retval)
65703 +{
65704 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65705 + if (grsec_enable_mount && (retval >= 0))
65706 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65707 +#endif
65708 + return;
65709 +}
65710 +
65711 +int
65712 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65713 +{
65714 +#ifdef CONFIG_GRKERNSEC_ROFS
65715 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65716 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65717 + return -EPERM;
65718 + } else
65719 + return 0;
65720 +#endif
65721 + return 0;
65722 +}
65723 +
65724 +int
65725 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65726 +{
65727 +#ifdef CONFIG_GRKERNSEC_ROFS
65728 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65729 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65730 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65731 + return -EPERM;
65732 + } else
65733 + return 0;
65734 +#endif
65735 + return 0;
65736 +}
65737 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65738 new file mode 100644
65739 index 0000000..a3b12a0
65740 --- /dev/null
65741 +++ b/grsecurity/grsec_pax.c
65742 @@ -0,0 +1,36 @@
65743 +#include <linux/kernel.h>
65744 +#include <linux/sched.h>
65745 +#include <linux/mm.h>
65746 +#include <linux/file.h>
65747 +#include <linux/grinternal.h>
65748 +#include <linux/grsecurity.h>
65749 +
65750 +void
65751 +gr_log_textrel(struct vm_area_struct * vma)
65752 +{
65753 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65754 + if (grsec_enable_audit_textrel)
65755 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65756 +#endif
65757 + return;
65758 +}
65759 +
65760 +void
65761 +gr_log_rwxmmap(struct file *file)
65762 +{
65763 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65764 + if (grsec_enable_log_rwxmaps)
65765 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65766 +#endif
65767 + return;
65768 +}
65769 +
65770 +void
65771 +gr_log_rwxmprotect(struct file *file)
65772 +{
65773 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65774 + if (grsec_enable_log_rwxmaps)
65775 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65776 +#endif
65777 + return;
65778 +}
65779 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65780 new file mode 100644
65781 index 0000000..f7f29aa
65782 --- /dev/null
65783 +++ b/grsecurity/grsec_ptrace.c
65784 @@ -0,0 +1,30 @@
65785 +#include <linux/kernel.h>
65786 +#include <linux/sched.h>
65787 +#include <linux/grinternal.h>
65788 +#include <linux/security.h>
65789 +
65790 +void
65791 +gr_audit_ptrace(struct task_struct *task)
65792 +{
65793 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65794 + if (grsec_enable_audit_ptrace)
65795 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65796 +#endif
65797 + return;
65798 +}
65799 +
65800 +int
65801 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65802 +{
65803 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65804 + const struct dentry *dentry = file->f_path.dentry;
65805 + const struct vfsmount *mnt = file->f_path.mnt;
65806 +
65807 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65808 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65809 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65810 + return -EACCES;
65811 + }
65812 +#endif
65813 + return 0;
65814 +}
65815 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65816 new file mode 100644
65817 index 0000000..e09715a
65818 --- /dev/null
65819 +++ b/grsecurity/grsec_sig.c
65820 @@ -0,0 +1,222 @@
65821 +#include <linux/kernel.h>
65822 +#include <linux/sched.h>
65823 +#include <linux/delay.h>
65824 +#include <linux/grsecurity.h>
65825 +#include <linux/grinternal.h>
65826 +#include <linux/hardirq.h>
65827 +
65828 +char *signames[] = {
65829 + [SIGSEGV] = "Segmentation fault",
65830 + [SIGILL] = "Illegal instruction",
65831 + [SIGABRT] = "Abort",
65832 + [SIGBUS] = "Invalid alignment/Bus error"
65833 +};
65834 +
65835 +void
65836 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65837 +{
65838 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65839 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65840 + (sig == SIGABRT) || (sig == SIGBUS))) {
65841 + if (task_pid_nr(t) == task_pid_nr(current)) {
65842 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65843 + } else {
65844 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65845 + }
65846 + }
65847 +#endif
65848 + return;
65849 +}
65850 +
65851 +int
65852 +gr_handle_signal(const struct task_struct *p, const int sig)
65853 +{
65854 +#ifdef CONFIG_GRKERNSEC
65855 + /* ignore the 0 signal for protected task checks */
65856 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65857 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65858 + return -EPERM;
65859 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65860 + return -EPERM;
65861 + }
65862 +#endif
65863 + return 0;
65864 +}
65865 +
65866 +#ifdef CONFIG_GRKERNSEC
65867 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65868 +
65869 +int gr_fake_force_sig(int sig, struct task_struct *t)
65870 +{
65871 + unsigned long int flags;
65872 + int ret, blocked, ignored;
65873 + struct k_sigaction *action;
65874 +
65875 + spin_lock_irqsave(&t->sighand->siglock, flags);
65876 + action = &t->sighand->action[sig-1];
65877 + ignored = action->sa.sa_handler == SIG_IGN;
65878 + blocked = sigismember(&t->blocked, sig);
65879 + if (blocked || ignored) {
65880 + action->sa.sa_handler = SIG_DFL;
65881 + if (blocked) {
65882 + sigdelset(&t->blocked, sig);
65883 + recalc_sigpending_and_wake(t);
65884 + }
65885 + }
65886 + if (action->sa.sa_handler == SIG_DFL)
65887 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
65888 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
65889 +
65890 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
65891 +
65892 + return ret;
65893 +}
65894 +#endif
65895 +
65896 +#ifdef CONFIG_GRKERNSEC_BRUTE
65897 +#define GR_USER_BAN_TIME (15 * 60)
65898 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
65899 +
65900 +static int __get_dumpable(unsigned long mm_flags)
65901 +{
65902 + int ret;
65903 +
65904 + ret = mm_flags & MMF_DUMPABLE_MASK;
65905 + return (ret >= 2) ? 2 : ret;
65906 +}
65907 +#endif
65908 +
65909 +void gr_handle_brute_attach(unsigned long mm_flags)
65910 +{
65911 +#ifdef CONFIG_GRKERNSEC_BRUTE
65912 + struct task_struct *p = current;
65913 + kuid_t uid = GLOBAL_ROOT_UID;
65914 + int daemon = 0;
65915 +
65916 + if (!grsec_enable_brute)
65917 + return;
65918 +
65919 + rcu_read_lock();
65920 + read_lock(&tasklist_lock);
65921 + read_lock(&grsec_exec_file_lock);
65922 + if (p->real_parent && p->real_parent->exec_file == p->exec_file) {
65923 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
65924 + p->real_parent->brute = 1;
65925 + daemon = 1;
65926 + } else {
65927 + const struct cred *cred = __task_cred(p), *cred2;
65928 + struct task_struct *tsk, *tsk2;
65929 +
65930 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
65931 + struct user_struct *user;
65932 +
65933 + uid = cred->uid;
65934 +
65935 + /* this is put upon execution past expiration */
65936 + user = find_user(uid);
65937 + if (user == NULL)
65938 + goto unlock;
65939 + user->banned = 1;
65940 + user->ban_expires = get_seconds() + GR_USER_BAN_TIME;
65941 + if (user->ban_expires == ~0UL)
65942 + user->ban_expires--;
65943 +
65944 + do_each_thread(tsk2, tsk) {
65945 + cred2 = __task_cred(tsk);
65946 + if (tsk != p && uid_eq(cred2->uid, uid))
65947 + gr_fake_force_sig(SIGKILL, tsk);
65948 + } while_each_thread(tsk2, tsk);
65949 + }
65950 + }
65951 +unlock:
65952 + read_unlock(&grsec_exec_file_lock);
65953 + read_unlock(&tasklist_lock);
65954 + rcu_read_unlock();
65955 +
65956 + if (gr_is_global_nonroot(uid))
65957 + printk(KERN_ALERT "grsec: bruteforce prevention initiated against uid %u, banning for %d minutes\n",
65958 + GR_GLOBAL_UID(uid), GR_USER_BAN_TIME / 60);
65959 + else if (daemon)
65960 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
65961 +
65962 +#endif
65963 + return;
65964 +}
65965 +
65966 +void gr_handle_brute_check(void)
65967 +{
65968 +#ifdef CONFIG_GRKERNSEC_BRUTE
65969 + struct task_struct *p = current;
65970 +
65971 + if (unlikely(p->brute)) {
65972 + if (!grsec_enable_brute)
65973 + p->brute = 0;
65974 + else if (time_before(get_seconds(), p->brute_expires))
65975 + msleep(30 * 1000);
65976 + }
65977 +#endif
65978 + return;
65979 +}
65980 +
65981 +void gr_handle_kernel_exploit(void)
65982 +{
65983 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
65984 + const struct cred *cred;
65985 + struct task_struct *tsk, *tsk2;
65986 + struct user_struct *user;
65987 + kuid_t uid;
65988 +
65989 + if (in_irq() || in_serving_softirq() || in_nmi())
65990 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
65991 +
65992 + uid = current_uid();
65993 +
65994 + if (gr_is_global_root(uid))
65995 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
65996 + else {
65997 + /* kill all the processes of this user, hold a reference
65998 + to their creds struct, and prevent them from creating
65999 + another process until system reset
66000 + */
66001 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66002 + GR_GLOBAL_UID(uid));
66003 + /* we intentionally leak this ref */
66004 + user = get_uid(current->cred->user);
66005 + if (user) {
66006 + user->banned = 1;
66007 + user->ban_expires = ~0UL;
66008 + }
66009 +
66010 + read_lock(&tasklist_lock);
66011 + do_each_thread(tsk2, tsk) {
66012 + cred = __task_cred(tsk);
66013 + if (uid_eq(cred->uid, uid))
66014 + gr_fake_force_sig(SIGKILL, tsk);
66015 + } while_each_thread(tsk2, tsk);
66016 + read_unlock(&tasklist_lock);
66017 + }
66018 +#endif
66019 +}
66020 +
66021 +int __gr_process_user_ban(struct user_struct *user)
66022 +{
66023 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66024 + if (unlikely(user->banned)) {
66025 + if (user->ban_expires != ~0UL && time_after_eq(get_seconds(), user->ban_expires)) {
66026 + user->banned = 0;
66027 + user->ban_expires = 0;
66028 + free_uid(user);
66029 + } else
66030 + return -EPERM;
66031 + }
66032 +#endif
66033 + return 0;
66034 +}
66035 +
66036 +int gr_process_user_ban(void)
66037 +{
66038 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
66039 + return __gr_process_user_ban(current->cred->user);
66040 +#endif
66041 + return 0;
66042 +}
66043 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66044 new file mode 100644
66045 index 0000000..4030d57
66046 --- /dev/null
66047 +++ b/grsecurity/grsec_sock.c
66048 @@ -0,0 +1,244 @@
66049 +#include <linux/kernel.h>
66050 +#include <linux/module.h>
66051 +#include <linux/sched.h>
66052 +#include <linux/file.h>
66053 +#include <linux/net.h>
66054 +#include <linux/in.h>
66055 +#include <linux/ip.h>
66056 +#include <net/sock.h>
66057 +#include <net/inet_sock.h>
66058 +#include <linux/grsecurity.h>
66059 +#include <linux/grinternal.h>
66060 +#include <linux/gracl.h>
66061 +
66062 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66063 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66064 +
66065 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66066 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66067 +
66068 +#ifdef CONFIG_UNIX_MODULE
66069 +EXPORT_SYMBOL(gr_acl_handle_unix);
66070 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66071 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66072 +EXPORT_SYMBOL(gr_handle_create);
66073 +#endif
66074 +
66075 +#ifdef CONFIG_GRKERNSEC
66076 +#define gr_conn_table_size 32749
66077 +struct conn_table_entry {
66078 + struct conn_table_entry *next;
66079 + struct signal_struct *sig;
66080 +};
66081 +
66082 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66083 +DEFINE_SPINLOCK(gr_conn_table_lock);
66084 +
66085 +extern const char * gr_socktype_to_name(unsigned char type);
66086 +extern const char * gr_proto_to_name(unsigned char proto);
66087 +extern const char * gr_sockfamily_to_name(unsigned char family);
66088 +
66089 +static __inline__ int
66090 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66091 +{
66092 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66093 +}
66094 +
66095 +static __inline__ int
66096 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66097 + __u16 sport, __u16 dport)
66098 +{
66099 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66100 + sig->gr_sport == sport && sig->gr_dport == dport))
66101 + return 1;
66102 + else
66103 + return 0;
66104 +}
66105 +
66106 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66107 +{
66108 + struct conn_table_entry **match;
66109 + unsigned int index;
66110 +
66111 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66112 + sig->gr_sport, sig->gr_dport,
66113 + gr_conn_table_size);
66114 +
66115 + newent->sig = sig;
66116 +
66117 + match = &gr_conn_table[index];
66118 + newent->next = *match;
66119 + *match = newent;
66120 +
66121 + return;
66122 +}
66123 +
66124 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66125 +{
66126 + struct conn_table_entry *match, *last = NULL;
66127 + unsigned int index;
66128 +
66129 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66130 + sig->gr_sport, sig->gr_dport,
66131 + gr_conn_table_size);
66132 +
66133 + match = gr_conn_table[index];
66134 + while (match && !conn_match(match->sig,
66135 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66136 + sig->gr_dport)) {
66137 + last = match;
66138 + match = match->next;
66139 + }
66140 +
66141 + if (match) {
66142 + if (last)
66143 + last->next = match->next;
66144 + else
66145 + gr_conn_table[index] = NULL;
66146 + kfree(match);
66147 + }
66148 +
66149 + return;
66150 +}
66151 +
66152 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66153 + __u16 sport, __u16 dport)
66154 +{
66155 + struct conn_table_entry *match;
66156 + unsigned int index;
66157 +
66158 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66159 +
66160 + match = gr_conn_table[index];
66161 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66162 + match = match->next;
66163 +
66164 + if (match)
66165 + return match->sig;
66166 + else
66167 + return NULL;
66168 +}
66169 +
66170 +#endif
66171 +
66172 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66173 +{
66174 +#ifdef CONFIG_GRKERNSEC
66175 + struct signal_struct *sig = task->signal;
66176 + struct conn_table_entry *newent;
66177 +
66178 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66179 + if (newent == NULL)
66180 + return;
66181 + /* no bh lock needed since we are called with bh disabled */
66182 + spin_lock(&gr_conn_table_lock);
66183 + gr_del_task_from_ip_table_nolock(sig);
66184 + sig->gr_saddr = inet->inet_rcv_saddr;
66185 + sig->gr_daddr = inet->inet_daddr;
66186 + sig->gr_sport = inet->inet_sport;
66187 + sig->gr_dport = inet->inet_dport;
66188 + gr_add_to_task_ip_table_nolock(sig, newent);
66189 + spin_unlock(&gr_conn_table_lock);
66190 +#endif
66191 + return;
66192 +}
66193 +
66194 +void gr_del_task_from_ip_table(struct task_struct *task)
66195 +{
66196 +#ifdef CONFIG_GRKERNSEC
66197 + spin_lock_bh(&gr_conn_table_lock);
66198 + gr_del_task_from_ip_table_nolock(task->signal);
66199 + spin_unlock_bh(&gr_conn_table_lock);
66200 +#endif
66201 + return;
66202 +}
66203 +
66204 +void
66205 +gr_attach_curr_ip(const struct sock *sk)
66206 +{
66207 +#ifdef CONFIG_GRKERNSEC
66208 + struct signal_struct *p, *set;
66209 + const struct inet_sock *inet = inet_sk(sk);
66210 +
66211 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66212 + return;
66213 +
66214 + set = current->signal;
66215 +
66216 + spin_lock_bh(&gr_conn_table_lock);
66217 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66218 + inet->inet_dport, inet->inet_sport);
66219 + if (unlikely(p != NULL)) {
66220 + set->curr_ip = p->curr_ip;
66221 + set->used_accept = 1;
66222 + gr_del_task_from_ip_table_nolock(p);
66223 + spin_unlock_bh(&gr_conn_table_lock);
66224 + return;
66225 + }
66226 + spin_unlock_bh(&gr_conn_table_lock);
66227 +
66228 + set->curr_ip = inet->inet_daddr;
66229 + set->used_accept = 1;
66230 +#endif
66231 + return;
66232 +}
66233 +
66234 +int
66235 +gr_handle_sock_all(const int family, const int type, const int protocol)
66236 +{
66237 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66238 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66239 + (family != AF_UNIX)) {
66240 + if (family == AF_INET)
66241 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66242 + else
66243 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66244 + return -EACCES;
66245 + }
66246 +#endif
66247 + return 0;
66248 +}
66249 +
66250 +int
66251 +gr_handle_sock_server(const struct sockaddr *sck)
66252 +{
66253 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66254 + if (grsec_enable_socket_server &&
66255 + in_group_p(grsec_socket_server_gid) &&
66256 + sck && (sck->sa_family != AF_UNIX) &&
66257 + (sck->sa_family != AF_LOCAL)) {
66258 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66259 + return -EACCES;
66260 + }
66261 +#endif
66262 + return 0;
66263 +}
66264 +
66265 +int
66266 +gr_handle_sock_server_other(const struct sock *sck)
66267 +{
66268 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66269 + if (grsec_enable_socket_server &&
66270 + in_group_p(grsec_socket_server_gid) &&
66271 + sck && (sck->sk_family != AF_UNIX) &&
66272 + (sck->sk_family != AF_LOCAL)) {
66273 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66274 + return -EACCES;
66275 + }
66276 +#endif
66277 + return 0;
66278 +}
66279 +
66280 +int
66281 +gr_handle_sock_client(const struct sockaddr *sck)
66282 +{
66283 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66284 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66285 + sck && (sck->sa_family != AF_UNIX) &&
66286 + (sck->sa_family != AF_LOCAL)) {
66287 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66288 + return -EACCES;
66289 + }
66290 +#endif
66291 + return 0;
66292 +}
66293 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66294 new file mode 100644
66295 index 0000000..f55ef0f
66296 --- /dev/null
66297 +++ b/grsecurity/grsec_sysctl.c
66298 @@ -0,0 +1,469 @@
66299 +#include <linux/kernel.h>
66300 +#include <linux/sched.h>
66301 +#include <linux/sysctl.h>
66302 +#include <linux/grsecurity.h>
66303 +#include <linux/grinternal.h>
66304 +
66305 +int
66306 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66307 +{
66308 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66309 + if (dirname == NULL || name == NULL)
66310 + return 0;
66311 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66312 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66313 + return -EACCES;
66314 + }
66315 +#endif
66316 + return 0;
66317 +}
66318 +
66319 +#ifdef CONFIG_GRKERNSEC_ROFS
66320 +static int __maybe_unused one = 1;
66321 +#endif
66322 +
66323 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66324 +struct ctl_table grsecurity_table[] = {
66325 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66326 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66327 +#ifdef CONFIG_GRKERNSEC_IO
66328 + {
66329 + .procname = "disable_priv_io",
66330 + .data = &grsec_disable_privio,
66331 + .maxlen = sizeof(int),
66332 + .mode = 0600,
66333 + .proc_handler = &proc_dointvec,
66334 + },
66335 +#endif
66336 +#endif
66337 +#ifdef CONFIG_GRKERNSEC_LINK
66338 + {
66339 + .procname = "linking_restrictions",
66340 + .data = &grsec_enable_link,
66341 + .maxlen = sizeof(int),
66342 + .mode = 0600,
66343 + .proc_handler = &proc_dointvec,
66344 + },
66345 +#endif
66346 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66347 + {
66348 + .procname = "enforce_symlinksifowner",
66349 + .data = &grsec_enable_symlinkown,
66350 + .maxlen = sizeof(int),
66351 + .mode = 0600,
66352 + .proc_handler = &proc_dointvec,
66353 + },
66354 + {
66355 + .procname = "symlinkown_gid",
66356 + .data = &grsec_symlinkown_gid,
66357 + .maxlen = sizeof(int),
66358 + .mode = 0600,
66359 + .proc_handler = &proc_dointvec,
66360 + },
66361 +#endif
66362 +#ifdef CONFIG_GRKERNSEC_BRUTE
66363 + {
66364 + .procname = "deter_bruteforce",
66365 + .data = &grsec_enable_brute,
66366 + .maxlen = sizeof(int),
66367 + .mode = 0600,
66368 + .proc_handler = &proc_dointvec,
66369 + },
66370 +#endif
66371 +#ifdef CONFIG_GRKERNSEC_FIFO
66372 + {
66373 + .procname = "fifo_restrictions",
66374 + .data = &grsec_enable_fifo,
66375 + .maxlen = sizeof(int),
66376 + .mode = 0600,
66377 + .proc_handler = &proc_dointvec,
66378 + },
66379 +#endif
66380 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66381 + {
66382 + .procname = "ptrace_readexec",
66383 + .data = &grsec_enable_ptrace_readexec,
66384 + .maxlen = sizeof(int),
66385 + .mode = 0600,
66386 + .proc_handler = &proc_dointvec,
66387 + },
66388 +#endif
66389 +#ifdef CONFIG_GRKERNSEC_SETXID
66390 + {
66391 + .procname = "consistent_setxid",
66392 + .data = &grsec_enable_setxid,
66393 + .maxlen = sizeof(int),
66394 + .mode = 0600,
66395 + .proc_handler = &proc_dointvec,
66396 + },
66397 +#endif
66398 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66399 + {
66400 + .procname = "ip_blackhole",
66401 + .data = &grsec_enable_blackhole,
66402 + .maxlen = sizeof(int),
66403 + .mode = 0600,
66404 + .proc_handler = &proc_dointvec,
66405 + },
66406 + {
66407 + .procname = "lastack_retries",
66408 + .data = &grsec_lastack_retries,
66409 + .maxlen = sizeof(int),
66410 + .mode = 0600,
66411 + .proc_handler = &proc_dointvec,
66412 + },
66413 +#endif
66414 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66415 + {
66416 + .procname = "exec_logging",
66417 + .data = &grsec_enable_execlog,
66418 + .maxlen = sizeof(int),
66419 + .mode = 0600,
66420 + .proc_handler = &proc_dointvec,
66421 + },
66422 +#endif
66423 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66424 + {
66425 + .procname = "rwxmap_logging",
66426 + .data = &grsec_enable_log_rwxmaps,
66427 + .maxlen = sizeof(int),
66428 + .mode = 0600,
66429 + .proc_handler = &proc_dointvec,
66430 + },
66431 +#endif
66432 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66433 + {
66434 + .procname = "signal_logging",
66435 + .data = &grsec_enable_signal,
66436 + .maxlen = sizeof(int),
66437 + .mode = 0600,
66438 + .proc_handler = &proc_dointvec,
66439 + },
66440 +#endif
66441 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66442 + {
66443 + .procname = "forkfail_logging",
66444 + .data = &grsec_enable_forkfail,
66445 + .maxlen = sizeof(int),
66446 + .mode = 0600,
66447 + .proc_handler = &proc_dointvec,
66448 + },
66449 +#endif
66450 +#ifdef CONFIG_GRKERNSEC_TIME
66451 + {
66452 + .procname = "timechange_logging",
66453 + .data = &grsec_enable_time,
66454 + .maxlen = sizeof(int),
66455 + .mode = 0600,
66456 + .proc_handler = &proc_dointvec,
66457 + },
66458 +#endif
66459 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66460 + {
66461 + .procname = "chroot_deny_shmat",
66462 + .data = &grsec_enable_chroot_shmat,
66463 + .maxlen = sizeof(int),
66464 + .mode = 0600,
66465 + .proc_handler = &proc_dointvec,
66466 + },
66467 +#endif
66468 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66469 + {
66470 + .procname = "chroot_deny_unix",
66471 + .data = &grsec_enable_chroot_unix,
66472 + .maxlen = sizeof(int),
66473 + .mode = 0600,
66474 + .proc_handler = &proc_dointvec,
66475 + },
66476 +#endif
66477 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66478 + {
66479 + .procname = "chroot_deny_mount",
66480 + .data = &grsec_enable_chroot_mount,
66481 + .maxlen = sizeof(int),
66482 + .mode = 0600,
66483 + .proc_handler = &proc_dointvec,
66484 + },
66485 +#endif
66486 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66487 + {
66488 + .procname = "chroot_deny_fchdir",
66489 + .data = &grsec_enable_chroot_fchdir,
66490 + .maxlen = sizeof(int),
66491 + .mode = 0600,
66492 + .proc_handler = &proc_dointvec,
66493 + },
66494 +#endif
66495 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66496 + {
66497 + .procname = "chroot_deny_chroot",
66498 + .data = &grsec_enable_chroot_double,
66499 + .maxlen = sizeof(int),
66500 + .mode = 0600,
66501 + .proc_handler = &proc_dointvec,
66502 + },
66503 +#endif
66504 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66505 + {
66506 + .procname = "chroot_deny_pivot",
66507 + .data = &grsec_enable_chroot_pivot,
66508 + .maxlen = sizeof(int),
66509 + .mode = 0600,
66510 + .proc_handler = &proc_dointvec,
66511 + },
66512 +#endif
66513 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66514 + {
66515 + .procname = "chroot_enforce_chdir",
66516 + .data = &grsec_enable_chroot_chdir,
66517 + .maxlen = sizeof(int),
66518 + .mode = 0600,
66519 + .proc_handler = &proc_dointvec,
66520 + },
66521 +#endif
66522 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66523 + {
66524 + .procname = "chroot_deny_chmod",
66525 + .data = &grsec_enable_chroot_chmod,
66526 + .maxlen = sizeof(int),
66527 + .mode = 0600,
66528 + .proc_handler = &proc_dointvec,
66529 + },
66530 +#endif
66531 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66532 + {
66533 + .procname = "chroot_deny_mknod",
66534 + .data = &grsec_enable_chroot_mknod,
66535 + .maxlen = sizeof(int),
66536 + .mode = 0600,
66537 + .proc_handler = &proc_dointvec,
66538 + },
66539 +#endif
66540 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66541 + {
66542 + .procname = "chroot_restrict_nice",
66543 + .data = &grsec_enable_chroot_nice,
66544 + .maxlen = sizeof(int),
66545 + .mode = 0600,
66546 + .proc_handler = &proc_dointvec,
66547 + },
66548 +#endif
66549 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66550 + {
66551 + .procname = "chroot_execlog",
66552 + .data = &grsec_enable_chroot_execlog,
66553 + .maxlen = sizeof(int),
66554 + .mode = 0600,
66555 + .proc_handler = &proc_dointvec,
66556 + },
66557 +#endif
66558 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66559 + {
66560 + .procname = "chroot_caps",
66561 + .data = &grsec_enable_chroot_caps,
66562 + .maxlen = sizeof(int),
66563 + .mode = 0600,
66564 + .proc_handler = &proc_dointvec,
66565 + },
66566 +#endif
66567 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66568 + {
66569 + .procname = "chroot_deny_sysctl",
66570 + .data = &grsec_enable_chroot_sysctl,
66571 + .maxlen = sizeof(int),
66572 + .mode = 0600,
66573 + .proc_handler = &proc_dointvec,
66574 + },
66575 +#endif
66576 +#ifdef CONFIG_GRKERNSEC_TPE
66577 + {
66578 + .procname = "tpe",
66579 + .data = &grsec_enable_tpe,
66580 + .maxlen = sizeof(int),
66581 + .mode = 0600,
66582 + .proc_handler = &proc_dointvec,
66583 + },
66584 + {
66585 + .procname = "tpe_gid",
66586 + .data = &grsec_tpe_gid,
66587 + .maxlen = sizeof(int),
66588 + .mode = 0600,
66589 + .proc_handler = &proc_dointvec,
66590 + },
66591 +#endif
66592 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66593 + {
66594 + .procname = "tpe_invert",
66595 + .data = &grsec_enable_tpe_invert,
66596 + .maxlen = sizeof(int),
66597 + .mode = 0600,
66598 + .proc_handler = &proc_dointvec,
66599 + },
66600 +#endif
66601 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66602 + {
66603 + .procname = "tpe_restrict_all",
66604 + .data = &grsec_enable_tpe_all,
66605 + .maxlen = sizeof(int),
66606 + .mode = 0600,
66607 + .proc_handler = &proc_dointvec,
66608 + },
66609 +#endif
66610 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66611 + {
66612 + .procname = "socket_all",
66613 + .data = &grsec_enable_socket_all,
66614 + .maxlen = sizeof(int),
66615 + .mode = 0600,
66616 + .proc_handler = &proc_dointvec,
66617 + },
66618 + {
66619 + .procname = "socket_all_gid",
66620 + .data = &grsec_socket_all_gid,
66621 + .maxlen = sizeof(int),
66622 + .mode = 0600,
66623 + .proc_handler = &proc_dointvec,
66624 + },
66625 +#endif
66626 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66627 + {
66628 + .procname = "socket_client",
66629 + .data = &grsec_enable_socket_client,
66630 + .maxlen = sizeof(int),
66631 + .mode = 0600,
66632 + .proc_handler = &proc_dointvec,
66633 + },
66634 + {
66635 + .procname = "socket_client_gid",
66636 + .data = &grsec_socket_client_gid,
66637 + .maxlen = sizeof(int),
66638 + .mode = 0600,
66639 + .proc_handler = &proc_dointvec,
66640 + },
66641 +#endif
66642 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66643 + {
66644 + .procname = "socket_server",
66645 + .data = &grsec_enable_socket_server,
66646 + .maxlen = sizeof(int),
66647 + .mode = 0600,
66648 + .proc_handler = &proc_dointvec,
66649 + },
66650 + {
66651 + .procname = "socket_server_gid",
66652 + .data = &grsec_socket_server_gid,
66653 + .maxlen = sizeof(int),
66654 + .mode = 0600,
66655 + .proc_handler = &proc_dointvec,
66656 + },
66657 +#endif
66658 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66659 + {
66660 + .procname = "audit_group",
66661 + .data = &grsec_enable_group,
66662 + .maxlen = sizeof(int),
66663 + .mode = 0600,
66664 + .proc_handler = &proc_dointvec,
66665 + },
66666 + {
66667 + .procname = "audit_gid",
66668 + .data = &grsec_audit_gid,
66669 + .maxlen = sizeof(int),
66670 + .mode = 0600,
66671 + .proc_handler = &proc_dointvec,
66672 + },
66673 +#endif
66674 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66675 + {
66676 + .procname = "audit_chdir",
66677 + .data = &grsec_enable_chdir,
66678 + .maxlen = sizeof(int),
66679 + .mode = 0600,
66680 + .proc_handler = &proc_dointvec,
66681 + },
66682 +#endif
66683 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66684 + {
66685 + .procname = "audit_mount",
66686 + .data = &grsec_enable_mount,
66687 + .maxlen = sizeof(int),
66688 + .mode = 0600,
66689 + .proc_handler = &proc_dointvec,
66690 + },
66691 +#endif
66692 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66693 + {
66694 + .procname = "audit_textrel",
66695 + .data = &grsec_enable_audit_textrel,
66696 + .maxlen = sizeof(int),
66697 + .mode = 0600,
66698 + .proc_handler = &proc_dointvec,
66699 + },
66700 +#endif
66701 +#ifdef CONFIG_GRKERNSEC_DMESG
66702 + {
66703 + .procname = "dmesg",
66704 + .data = &grsec_enable_dmesg,
66705 + .maxlen = sizeof(int),
66706 + .mode = 0600,
66707 + .proc_handler = &proc_dointvec,
66708 + },
66709 +#endif
66710 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66711 + {
66712 + .procname = "chroot_findtask",
66713 + .data = &grsec_enable_chroot_findtask,
66714 + .maxlen = sizeof(int),
66715 + .mode = 0600,
66716 + .proc_handler = &proc_dointvec,
66717 + },
66718 +#endif
66719 +#ifdef CONFIG_GRKERNSEC_RESLOG
66720 + {
66721 + .procname = "resource_logging",
66722 + .data = &grsec_resource_logging,
66723 + .maxlen = sizeof(int),
66724 + .mode = 0600,
66725 + .proc_handler = &proc_dointvec,
66726 + },
66727 +#endif
66728 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66729 + {
66730 + .procname = "audit_ptrace",
66731 + .data = &grsec_enable_audit_ptrace,
66732 + .maxlen = sizeof(int),
66733 + .mode = 0600,
66734 + .proc_handler = &proc_dointvec,
66735 + },
66736 +#endif
66737 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66738 + {
66739 + .procname = "harden_ptrace",
66740 + .data = &grsec_enable_harden_ptrace,
66741 + .maxlen = sizeof(int),
66742 + .mode = 0600,
66743 + .proc_handler = &proc_dointvec,
66744 + },
66745 +#endif
66746 + {
66747 + .procname = "grsec_lock",
66748 + .data = &grsec_lock,
66749 + .maxlen = sizeof(int),
66750 + .mode = 0600,
66751 + .proc_handler = &proc_dointvec,
66752 + },
66753 +#endif
66754 +#ifdef CONFIG_GRKERNSEC_ROFS
66755 + {
66756 + .procname = "romount_protect",
66757 + .data = &grsec_enable_rofs,
66758 + .maxlen = sizeof(int),
66759 + .mode = 0600,
66760 + .proc_handler = &proc_dointvec_minmax,
66761 + .extra1 = &one,
66762 + .extra2 = &one,
66763 + },
66764 +#endif
66765 + { }
66766 +};
66767 +#endif
66768 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66769 new file mode 100644
66770 index 0000000..0dc13c3
66771 --- /dev/null
66772 +++ b/grsecurity/grsec_time.c
66773 @@ -0,0 +1,16 @@
66774 +#include <linux/kernel.h>
66775 +#include <linux/sched.h>
66776 +#include <linux/grinternal.h>
66777 +#include <linux/module.h>
66778 +
66779 +void
66780 +gr_log_timechange(void)
66781 +{
66782 +#ifdef CONFIG_GRKERNSEC_TIME
66783 + if (grsec_enable_time)
66784 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66785 +#endif
66786 + return;
66787 +}
66788 +
66789 +EXPORT_SYMBOL(gr_log_timechange);
66790 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66791 new file mode 100644
66792 index 0000000..ee57dcf
66793 --- /dev/null
66794 +++ b/grsecurity/grsec_tpe.c
66795 @@ -0,0 +1,73 @@
66796 +#include <linux/kernel.h>
66797 +#include <linux/sched.h>
66798 +#include <linux/file.h>
66799 +#include <linux/fs.h>
66800 +#include <linux/grinternal.h>
66801 +
66802 +extern int gr_acl_tpe_check(void);
66803 +
66804 +int
66805 +gr_tpe_allow(const struct file *file)
66806 +{
66807 +#ifdef CONFIG_GRKERNSEC
66808 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66809 + const struct cred *cred = current_cred();
66810 + char *msg = NULL;
66811 + char *msg2 = NULL;
66812 +
66813 + // never restrict root
66814 + if (gr_is_global_root(cred->uid))
66815 + return 1;
66816 +
66817 + if (grsec_enable_tpe) {
66818 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66819 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66820 + msg = "not being in trusted group";
66821 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66822 + msg = "being in untrusted group";
66823 +#else
66824 + if (in_group_p(grsec_tpe_gid))
66825 + msg = "being in untrusted group";
66826 +#endif
66827 + }
66828 + if (!msg && gr_acl_tpe_check())
66829 + msg = "being in untrusted role";
66830 +
66831 + // not in any affected group/role
66832 + if (!msg)
66833 + goto next_check;
66834 +
66835 + if (gr_is_global_nonroot(inode->i_uid))
66836 + msg2 = "file in non-root-owned directory";
66837 + else if (inode->i_mode & S_IWOTH)
66838 + msg2 = "file in world-writable directory";
66839 + else if (inode->i_mode & S_IWGRP)
66840 + msg2 = "file in group-writable directory";
66841 +
66842 + if (msg && msg2) {
66843 + char fullmsg[70] = {0};
66844 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66845 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66846 + return 0;
66847 + }
66848 + msg = NULL;
66849 +next_check:
66850 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66851 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66852 + return 1;
66853 +
66854 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66855 + msg = "directory not owned by user";
66856 + else if (inode->i_mode & S_IWOTH)
66857 + msg = "file in world-writable directory";
66858 + else if (inode->i_mode & S_IWGRP)
66859 + msg = "file in group-writable directory";
66860 +
66861 + if (msg) {
66862 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
66863 + return 0;
66864 + }
66865 +#endif
66866 +#endif
66867 + return 1;
66868 +}
66869 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
66870 new file mode 100644
66871 index 0000000..9f7b1ac
66872 --- /dev/null
66873 +++ b/grsecurity/grsum.c
66874 @@ -0,0 +1,61 @@
66875 +#include <linux/err.h>
66876 +#include <linux/kernel.h>
66877 +#include <linux/sched.h>
66878 +#include <linux/mm.h>
66879 +#include <linux/scatterlist.h>
66880 +#include <linux/crypto.h>
66881 +#include <linux/gracl.h>
66882 +
66883 +
66884 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
66885 +#error "crypto and sha256 must be built into the kernel"
66886 +#endif
66887 +
66888 +int
66889 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
66890 +{
66891 + char *p;
66892 + struct crypto_hash *tfm;
66893 + struct hash_desc desc;
66894 + struct scatterlist sg;
66895 + unsigned char temp_sum[GR_SHA_LEN];
66896 + volatile int retval = 0;
66897 + volatile int dummy = 0;
66898 + unsigned int i;
66899 +
66900 + sg_init_table(&sg, 1);
66901 +
66902 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
66903 + if (IS_ERR(tfm)) {
66904 + /* should never happen, since sha256 should be built in */
66905 + return 1;
66906 + }
66907 +
66908 + desc.tfm = tfm;
66909 + desc.flags = 0;
66910 +
66911 + crypto_hash_init(&desc);
66912 +
66913 + p = salt;
66914 + sg_set_buf(&sg, p, GR_SALT_LEN);
66915 + crypto_hash_update(&desc, &sg, sg.length);
66916 +
66917 + p = entry->pw;
66918 + sg_set_buf(&sg, p, strlen(p));
66919 +
66920 + crypto_hash_update(&desc, &sg, sg.length);
66921 +
66922 + crypto_hash_final(&desc, temp_sum);
66923 +
66924 + memset(entry->pw, 0, GR_PW_LEN);
66925 +
66926 + for (i = 0; i < GR_SHA_LEN; i++)
66927 + if (sum[i] != temp_sum[i])
66928 + retval = 1;
66929 + else
66930 + dummy = 1; // waste a cycle
66931 +
66932 + crypto_free_hash(tfm);
66933 +
66934 + return retval;
66935 +}
66936 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
66937 index 77ff547..181834f 100644
66938 --- a/include/asm-generic/4level-fixup.h
66939 +++ b/include/asm-generic/4level-fixup.h
66940 @@ -13,8 +13,10 @@
66941 #define pmd_alloc(mm, pud, address) \
66942 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
66943 NULL: pmd_offset(pud, address))
66944 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
66945
66946 #define pud_alloc(mm, pgd, address) (pgd)
66947 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
66948 #define pud_offset(pgd, start) (pgd)
66949 #define pud_none(pud) 0
66950 #define pud_bad(pud) 0
66951 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
66952 index b7babf0..04ad282 100644
66953 --- a/include/asm-generic/atomic-long.h
66954 +++ b/include/asm-generic/atomic-long.h
66955 @@ -22,6 +22,12 @@
66956
66957 typedef atomic64_t atomic_long_t;
66958
66959 +#ifdef CONFIG_PAX_REFCOUNT
66960 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
66961 +#else
66962 +typedef atomic64_t atomic_long_unchecked_t;
66963 +#endif
66964 +
66965 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
66966
66967 static inline long atomic_long_read(atomic_long_t *l)
66968 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
66969 return (long)atomic64_read(v);
66970 }
66971
66972 +#ifdef CONFIG_PAX_REFCOUNT
66973 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
66974 +{
66975 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66976 +
66977 + return (long)atomic64_read_unchecked(v);
66978 +}
66979 +#endif
66980 +
66981 static inline void atomic_long_set(atomic_long_t *l, long i)
66982 {
66983 atomic64_t *v = (atomic64_t *)l;
66984 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
66985 atomic64_set(v, i);
66986 }
66987
66988 +#ifdef CONFIG_PAX_REFCOUNT
66989 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
66990 +{
66991 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
66992 +
66993 + atomic64_set_unchecked(v, i);
66994 +}
66995 +#endif
66996 +
66997 static inline void atomic_long_inc(atomic_long_t *l)
66998 {
66999 atomic64_t *v = (atomic64_t *)l;
67000 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67001 atomic64_inc(v);
67002 }
67003
67004 +#ifdef CONFIG_PAX_REFCOUNT
67005 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67006 +{
67007 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67008 +
67009 + atomic64_inc_unchecked(v);
67010 +}
67011 +#endif
67012 +
67013 static inline void atomic_long_dec(atomic_long_t *l)
67014 {
67015 atomic64_t *v = (atomic64_t *)l;
67016 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67017 atomic64_dec(v);
67018 }
67019
67020 +#ifdef CONFIG_PAX_REFCOUNT
67021 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67022 +{
67023 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67024 +
67025 + atomic64_dec_unchecked(v);
67026 +}
67027 +#endif
67028 +
67029 static inline void atomic_long_add(long i, atomic_long_t *l)
67030 {
67031 atomic64_t *v = (atomic64_t *)l;
67032 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67033 atomic64_add(i, v);
67034 }
67035
67036 +#ifdef CONFIG_PAX_REFCOUNT
67037 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67038 +{
67039 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67040 +
67041 + atomic64_add_unchecked(i, v);
67042 +}
67043 +#endif
67044 +
67045 static inline void atomic_long_sub(long i, atomic_long_t *l)
67046 {
67047 atomic64_t *v = (atomic64_t *)l;
67048 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67049 atomic64_sub(i, v);
67050 }
67051
67052 +#ifdef CONFIG_PAX_REFCOUNT
67053 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67054 +{
67055 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67056 +
67057 + atomic64_sub_unchecked(i, v);
67058 +}
67059 +#endif
67060 +
67061 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67062 {
67063 atomic64_t *v = (atomic64_t *)l;
67064 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67065 return (long)atomic64_add_return(i, v);
67066 }
67067
67068 +#ifdef CONFIG_PAX_REFCOUNT
67069 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67070 +{
67071 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67072 +
67073 + return (long)atomic64_add_return_unchecked(i, v);
67074 +}
67075 +#endif
67076 +
67077 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67078 {
67079 atomic64_t *v = (atomic64_t *)l;
67080 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67081 return (long)atomic64_inc_return(v);
67082 }
67083
67084 +#ifdef CONFIG_PAX_REFCOUNT
67085 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67086 +{
67087 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67088 +
67089 + return (long)atomic64_inc_return_unchecked(v);
67090 +}
67091 +#endif
67092 +
67093 static inline long atomic_long_dec_return(atomic_long_t *l)
67094 {
67095 atomic64_t *v = (atomic64_t *)l;
67096 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67097
67098 typedef atomic_t atomic_long_t;
67099
67100 +#ifdef CONFIG_PAX_REFCOUNT
67101 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67102 +#else
67103 +typedef atomic_t atomic_long_unchecked_t;
67104 +#endif
67105 +
67106 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67107 static inline long atomic_long_read(atomic_long_t *l)
67108 {
67109 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67110 return (long)atomic_read(v);
67111 }
67112
67113 +#ifdef CONFIG_PAX_REFCOUNT
67114 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67115 +{
67116 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67117 +
67118 + return (long)atomic_read_unchecked(v);
67119 +}
67120 +#endif
67121 +
67122 static inline void atomic_long_set(atomic_long_t *l, long i)
67123 {
67124 atomic_t *v = (atomic_t *)l;
67125 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67126 atomic_set(v, i);
67127 }
67128
67129 +#ifdef CONFIG_PAX_REFCOUNT
67130 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67131 +{
67132 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67133 +
67134 + atomic_set_unchecked(v, i);
67135 +}
67136 +#endif
67137 +
67138 static inline void atomic_long_inc(atomic_long_t *l)
67139 {
67140 atomic_t *v = (atomic_t *)l;
67141 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67142 atomic_inc(v);
67143 }
67144
67145 +#ifdef CONFIG_PAX_REFCOUNT
67146 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67147 +{
67148 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67149 +
67150 + atomic_inc_unchecked(v);
67151 +}
67152 +#endif
67153 +
67154 static inline void atomic_long_dec(atomic_long_t *l)
67155 {
67156 atomic_t *v = (atomic_t *)l;
67157 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67158 atomic_dec(v);
67159 }
67160
67161 +#ifdef CONFIG_PAX_REFCOUNT
67162 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67163 +{
67164 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67165 +
67166 + atomic_dec_unchecked(v);
67167 +}
67168 +#endif
67169 +
67170 static inline void atomic_long_add(long i, atomic_long_t *l)
67171 {
67172 atomic_t *v = (atomic_t *)l;
67173 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67174 atomic_add(i, v);
67175 }
67176
67177 +#ifdef CONFIG_PAX_REFCOUNT
67178 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67179 +{
67180 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67181 +
67182 + atomic_add_unchecked(i, v);
67183 +}
67184 +#endif
67185 +
67186 static inline void atomic_long_sub(long i, atomic_long_t *l)
67187 {
67188 atomic_t *v = (atomic_t *)l;
67189 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67190 atomic_sub(i, v);
67191 }
67192
67193 +#ifdef CONFIG_PAX_REFCOUNT
67194 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67195 +{
67196 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67197 +
67198 + atomic_sub_unchecked(i, v);
67199 +}
67200 +#endif
67201 +
67202 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67203 {
67204 atomic_t *v = (atomic_t *)l;
67205 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67206 return (long)atomic_add_return(i, v);
67207 }
67208
67209 +#ifdef CONFIG_PAX_REFCOUNT
67210 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67211 +{
67212 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67213 +
67214 + return (long)atomic_add_return_unchecked(i, v);
67215 +}
67216 +
67217 +#endif
67218 +
67219 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67220 {
67221 atomic_t *v = (atomic_t *)l;
67222 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67223 return (long)atomic_inc_return(v);
67224 }
67225
67226 +#ifdef CONFIG_PAX_REFCOUNT
67227 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67228 +{
67229 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67230 +
67231 + return (long)atomic_inc_return_unchecked(v);
67232 +}
67233 +#endif
67234 +
67235 static inline long atomic_long_dec_return(atomic_long_t *l)
67236 {
67237 atomic_t *v = (atomic_t *)l;
67238 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67239
67240 #endif /* BITS_PER_LONG == 64 */
67241
67242 +#ifdef CONFIG_PAX_REFCOUNT
67243 +static inline void pax_refcount_needs_these_functions(void)
67244 +{
67245 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67246 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67247 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67248 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67249 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67250 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67251 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67252 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67253 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67254 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67255 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67256 +#ifdef CONFIG_X86
67257 + atomic_clear_mask_unchecked(0, NULL);
67258 + atomic_set_mask_unchecked(0, NULL);
67259 +#endif
67260 +
67261 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67262 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67263 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67264 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67265 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67266 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67267 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67268 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67269 +}
67270 +#else
67271 +#define atomic_read_unchecked(v) atomic_read(v)
67272 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67273 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67274 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67275 +#define atomic_inc_unchecked(v) atomic_inc(v)
67276 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67277 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67278 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67279 +#define atomic_dec_unchecked(v) atomic_dec(v)
67280 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67281 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67282 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67283 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67284 +
67285 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67286 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67287 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67288 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67289 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67290 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67291 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67292 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67293 +#endif
67294 +
67295 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67296 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67297 index 1ced641..c896ee8 100644
67298 --- a/include/asm-generic/atomic.h
67299 +++ b/include/asm-generic/atomic.h
67300 @@ -159,7 +159,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67301 * Atomically clears the bits set in @mask from @v
67302 */
67303 #ifndef atomic_clear_mask
67304 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67305 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67306 {
67307 unsigned long flags;
67308
67309 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67310 index b18ce4f..2ee2843 100644
67311 --- a/include/asm-generic/atomic64.h
67312 +++ b/include/asm-generic/atomic64.h
67313 @@ -16,6 +16,8 @@ typedef struct {
67314 long long counter;
67315 } atomic64_t;
67316
67317 +typedef atomic64_t atomic64_unchecked_t;
67318 +
67319 #define ATOMIC64_INIT(i) { (i) }
67320
67321 extern long long atomic64_read(const atomic64_t *v);
67322 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67323 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67324 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67325
67326 +#define atomic64_read_unchecked(v) atomic64_read(v)
67327 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67328 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67329 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67330 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67331 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67332 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67333 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67334 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67335 +
67336 #endif /* _ASM_GENERIC_ATOMIC64_H */
67337 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67338 index 1bfcfe5..e04c5c9 100644
67339 --- a/include/asm-generic/cache.h
67340 +++ b/include/asm-generic/cache.h
67341 @@ -6,7 +6,7 @@
67342 * cache lines need to provide their own cache.h.
67343 */
67344
67345 -#define L1_CACHE_SHIFT 5
67346 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67347 +#define L1_CACHE_SHIFT 5UL
67348 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67349
67350 #endif /* __ASM_GENERIC_CACHE_H */
67351 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67352 index 0d68a1e..b74a761 100644
67353 --- a/include/asm-generic/emergency-restart.h
67354 +++ b/include/asm-generic/emergency-restart.h
67355 @@ -1,7 +1,7 @@
67356 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67357 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67358
67359 -static inline void machine_emergency_restart(void)
67360 +static inline __noreturn void machine_emergency_restart(void)
67361 {
67362 machine_restart(NULL);
67363 }
67364 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67365 index 90f99c7..00ce236 100644
67366 --- a/include/asm-generic/kmap_types.h
67367 +++ b/include/asm-generic/kmap_types.h
67368 @@ -2,9 +2,9 @@
67369 #define _ASM_GENERIC_KMAP_TYPES_H
67370
67371 #ifdef __WITH_KM_FENCE
67372 -# define KM_TYPE_NR 41
67373 +# define KM_TYPE_NR 42
67374 #else
67375 -# define KM_TYPE_NR 20
67376 +# define KM_TYPE_NR 21
67377 #endif
67378
67379 #endif
67380 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67381 index 9ceb03b..62b0b8f 100644
67382 --- a/include/asm-generic/local.h
67383 +++ b/include/asm-generic/local.h
67384 @@ -23,24 +23,37 @@ typedef struct
67385 atomic_long_t a;
67386 } local_t;
67387
67388 +typedef struct {
67389 + atomic_long_unchecked_t a;
67390 +} local_unchecked_t;
67391 +
67392 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67393
67394 #define local_read(l) atomic_long_read(&(l)->a)
67395 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67396 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67397 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67398 #define local_inc(l) atomic_long_inc(&(l)->a)
67399 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67400 #define local_dec(l) atomic_long_dec(&(l)->a)
67401 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67402 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67403 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67404 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67405 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67406
67407 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67408 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67409 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67410 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67411 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67412 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67413 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67414 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67415 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67416
67417 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67418 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67419 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67420 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67421 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67422 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67423 index 725612b..9cc513a 100644
67424 --- a/include/asm-generic/pgtable-nopmd.h
67425 +++ b/include/asm-generic/pgtable-nopmd.h
67426 @@ -1,14 +1,19 @@
67427 #ifndef _PGTABLE_NOPMD_H
67428 #define _PGTABLE_NOPMD_H
67429
67430 -#ifndef __ASSEMBLY__
67431 -
67432 #include <asm-generic/pgtable-nopud.h>
67433
67434 -struct mm_struct;
67435 -
67436 #define __PAGETABLE_PMD_FOLDED
67437
67438 +#define PMD_SHIFT PUD_SHIFT
67439 +#define PTRS_PER_PMD 1
67440 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67441 +#define PMD_MASK (~(PMD_SIZE-1))
67442 +
67443 +#ifndef __ASSEMBLY__
67444 +
67445 +struct mm_struct;
67446 +
67447 /*
67448 * Having the pmd type consist of a pud gets the size right, and allows
67449 * us to conceptually access the pud entry that this pmd is folded into
67450 @@ -16,11 +21,6 @@ struct mm_struct;
67451 */
67452 typedef struct { pud_t pud; } pmd_t;
67453
67454 -#define PMD_SHIFT PUD_SHIFT
67455 -#define PTRS_PER_PMD 1
67456 -#define PMD_SIZE (1UL << PMD_SHIFT)
67457 -#define PMD_MASK (~(PMD_SIZE-1))
67458 -
67459 /*
67460 * The "pud_xxx()" functions here are trivial for a folded two-level
67461 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67462 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67463 index 810431d..0ec4804f 100644
67464 --- a/include/asm-generic/pgtable-nopud.h
67465 +++ b/include/asm-generic/pgtable-nopud.h
67466 @@ -1,10 +1,15 @@
67467 #ifndef _PGTABLE_NOPUD_H
67468 #define _PGTABLE_NOPUD_H
67469
67470 -#ifndef __ASSEMBLY__
67471 -
67472 #define __PAGETABLE_PUD_FOLDED
67473
67474 +#define PUD_SHIFT PGDIR_SHIFT
67475 +#define PTRS_PER_PUD 1
67476 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67477 +#define PUD_MASK (~(PUD_SIZE-1))
67478 +
67479 +#ifndef __ASSEMBLY__
67480 +
67481 /*
67482 * Having the pud type consist of a pgd gets the size right, and allows
67483 * us to conceptually access the pgd entry that this pud is folded into
67484 @@ -12,11 +17,6 @@
67485 */
67486 typedef struct { pgd_t pgd; } pud_t;
67487
67488 -#define PUD_SHIFT PGDIR_SHIFT
67489 -#define PTRS_PER_PUD 1
67490 -#define PUD_SIZE (1UL << PUD_SHIFT)
67491 -#define PUD_MASK (~(PUD_SIZE-1))
67492 -
67493 /*
67494 * The "pgd_xxx()" functions here are trivial for a folded two-level
67495 * setup: the pud is never bad, and a pud always exists (as it's folded
67496 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67497 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67498
67499 #define pgd_populate(mm, pgd, pud) do { } while (0)
67500 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67501 /*
67502 * (puds are folded into pgds so this doesn't get actually called,
67503 * but the define is needed for a generic inline function.)
67504 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67505 index 5cf680a..4b74d62 100644
67506 --- a/include/asm-generic/pgtable.h
67507 +++ b/include/asm-generic/pgtable.h
67508 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67509 }
67510 #endif /* CONFIG_NUMA_BALANCING */
67511
67512 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67513 +static inline unsigned long pax_open_kernel(void) { return 0; }
67514 +#endif
67515 +
67516 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67517 +static inline unsigned long pax_close_kernel(void) { return 0; }
67518 +#endif
67519 +
67520 #endif /* CONFIG_MMU */
67521
67522 #endif /* !__ASSEMBLY__ */
67523 diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h
67524 index 25f01d0..b1b1fa6 100644
67525 --- a/include/asm-generic/tlb.h
67526 +++ b/include/asm-generic/tlb.h
67527 @@ -99,7 +99,12 @@ struct mmu_gather {
67528 unsigned int need_flush : 1, /* Did free PTEs */
67529 fast_mode : 1; /* No batching */
67530
67531 - unsigned int fullmm;
67532 + /* we are in the middle of an operation to clear
67533 + * a full mm and can make some optimizations */
67534 + unsigned int fullmm : 1,
67535 + /* we have performed an operation which
67536 + * requires a complete flush of the tlb */
67537 + need_flush_all : 1;
67538
67539 struct mmu_gather_batch *active;
67540 struct mmu_gather_batch local;
67541 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67542 index d1ea7ce..b1ebf2a 100644
67543 --- a/include/asm-generic/vmlinux.lds.h
67544 +++ b/include/asm-generic/vmlinux.lds.h
67545 @@ -218,6 +218,7 @@
67546 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67547 VMLINUX_SYMBOL(__start_rodata) = .; \
67548 *(.rodata) *(.rodata.*) \
67549 + *(.data..read_only) \
67550 *(__vermagic) /* Kernel version magic */ \
67551 . = ALIGN(8); \
67552 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67553 @@ -725,17 +726,18 @@
67554 * section in the linker script will go there too. @phdr should have
67555 * a leading colon.
67556 *
67557 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67558 + * Note that this macros defines per_cpu_load as an absolute symbol.
67559 * If there is no need to put the percpu section at a predetermined
67560 * address, use PERCPU_SECTION.
67561 */
67562 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67563 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67564 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67565 + per_cpu_load = .; \
67566 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67567 - LOAD_OFFSET) { \
67568 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67569 PERCPU_INPUT(cacheline) \
67570 } phdr \
67571 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67572 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67573
67574 /**
67575 * PERCPU_SECTION - define output section for percpu area, simple version
67576 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67577 index 418d270..bfd2794 100644
67578 --- a/include/crypto/algapi.h
67579 +++ b/include/crypto/algapi.h
67580 @@ -34,7 +34,7 @@ struct crypto_type {
67581 unsigned int maskclear;
67582 unsigned int maskset;
67583 unsigned int tfmsize;
67584 -};
67585 +} __do_const;
67586
67587 struct crypto_instance {
67588 struct crypto_alg alg;
67589 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67590 index fad21c9..ab858bc 100644
67591 --- a/include/drm/drmP.h
67592 +++ b/include/drm/drmP.h
67593 @@ -72,6 +72,7 @@
67594 #include <linux/workqueue.h>
67595 #include <linux/poll.h>
67596 #include <asm/pgalloc.h>
67597 +#include <asm/local.h>
67598 #include <drm/drm.h>
67599 #include <drm/drm_sarea.h>
67600
67601 @@ -293,10 +294,12 @@ do { \
67602 * \param cmd command.
67603 * \param arg argument.
67604 */
67605 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67606 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67607 + struct drm_file *file_priv);
67608 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67609 struct drm_file *file_priv);
67610
67611 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67612 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67613 unsigned long arg);
67614
67615 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67616 @@ -311,9 +314,9 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67617 struct drm_ioctl_desc {
67618 unsigned int cmd;
67619 int flags;
67620 - drm_ioctl_t *func;
67621 + drm_ioctl_t func;
67622 unsigned int cmd_drv;
67623 -};
67624 +} __do_const;
67625
67626 /**
67627 * Creates a driver or general drm_ioctl_desc array entry for the given
67628 @@ -995,7 +998,7 @@ struct drm_info_list {
67629 int (*show)(struct seq_file*, void*); /** show callback */
67630 u32 driver_features; /**< Required driver features for this entry */
67631 void *data;
67632 -};
67633 +} __do_const;
67634
67635 /**
67636 * debugfs node structure. This structure represents a debugfs file.
67637 @@ -1068,7 +1071,7 @@ struct drm_device {
67638
67639 /** \name Usage Counters */
67640 /*@{ */
67641 - int open_count; /**< Outstanding files open */
67642 + local_t open_count; /**< Outstanding files open */
67643 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67644 atomic_t vma_count; /**< Outstanding vma areas open */
67645 int buf_use; /**< Buffers in use -- cannot alloc */
67646 @@ -1079,7 +1082,7 @@ struct drm_device {
67647 /*@{ */
67648 unsigned long counters;
67649 enum drm_stat_type types[15];
67650 - atomic_t counts[15];
67651 + atomic_unchecked_t counts[15];
67652 /*@} */
67653
67654 struct list_head filelist;
67655 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67656 index f43d556..94d9343 100644
67657 --- a/include/drm/drm_crtc_helper.h
67658 +++ b/include/drm/drm_crtc_helper.h
67659 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67660 struct drm_connector *connector);
67661 /* disable encoder when not in use - more explicit than dpms off */
67662 void (*disable)(struct drm_encoder *encoder);
67663 -};
67664 +} __no_const;
67665
67666 /**
67667 * drm_connector_helper_funcs - helper operations for connectors
67668 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67669 index 72dcbe8..8db58d7 100644
67670 --- a/include/drm/ttm/ttm_memory.h
67671 +++ b/include/drm/ttm/ttm_memory.h
67672 @@ -48,7 +48,7 @@
67673
67674 struct ttm_mem_shrink {
67675 int (*do_shrink) (struct ttm_mem_shrink *);
67676 -};
67677 +} __no_const;
67678
67679 /**
67680 * struct ttm_mem_global - Global memory accounting structure.
67681 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67682 index 4b840e8..155d235 100644
67683 --- a/include/keys/asymmetric-subtype.h
67684 +++ b/include/keys/asymmetric-subtype.h
67685 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67686 /* Verify the signature on a key of this subtype (optional) */
67687 int (*verify_signature)(const struct key *key,
67688 const struct public_key_signature *sig);
67689 -};
67690 +} __do_const;
67691
67692 /**
67693 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67694 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67695 index c1da539..1dcec55 100644
67696 --- a/include/linux/atmdev.h
67697 +++ b/include/linux/atmdev.h
67698 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67699 #endif
67700
67701 struct k_atm_aal_stats {
67702 -#define __HANDLE_ITEM(i) atomic_t i
67703 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67704 __AAL_STAT_ITEMS
67705 #undef __HANDLE_ITEM
67706 };
67707 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67708 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67709 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67710 struct module *owner;
67711 -};
67712 +} __do_const ;
67713
67714 struct atmphy_ops {
67715 int (*start)(struct atm_dev *dev);
67716 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67717 index 0530b98..96a8ac0 100644
67718 --- a/include/linux/binfmts.h
67719 +++ b/include/linux/binfmts.h
67720 @@ -73,8 +73,9 @@ struct linux_binfmt {
67721 int (*load_binary)(struct linux_binprm *);
67722 int (*load_shlib)(struct file *);
67723 int (*core_dump)(struct coredump_params *cprm);
67724 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67725 unsigned long min_coredump; /* minimal dump size */
67726 -};
67727 +} __do_const;
67728
67729 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67730
67731 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67732 index f94bc83..62b9cfe 100644
67733 --- a/include/linux/blkdev.h
67734 +++ b/include/linux/blkdev.h
67735 @@ -1498,7 +1498,7 @@ struct block_device_operations {
67736 /* this callback is with swap_lock and sometimes page table lock held */
67737 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67738 struct module *owner;
67739 -};
67740 +} __do_const;
67741
67742 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67743 unsigned long);
67744 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67745 index 7c2e030..b72475d 100644
67746 --- a/include/linux/blktrace_api.h
67747 +++ b/include/linux/blktrace_api.h
67748 @@ -23,7 +23,7 @@ struct blk_trace {
67749 struct dentry *dir;
67750 struct dentry *dropped_file;
67751 struct dentry *msg_file;
67752 - atomic_t dropped;
67753 + atomic_unchecked_t dropped;
67754 };
67755
67756 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67757 diff --git a/include/linux/cache.h b/include/linux/cache.h
67758 index 4c57065..4307975 100644
67759 --- a/include/linux/cache.h
67760 +++ b/include/linux/cache.h
67761 @@ -16,6 +16,10 @@
67762 #define __read_mostly
67763 #endif
67764
67765 +#ifndef __read_only
67766 +#define __read_only __read_mostly
67767 +#endif
67768 +
67769 #ifndef ____cacheline_aligned
67770 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67771 #endif
67772 diff --git a/include/linux/capability.h b/include/linux/capability.h
67773 index 98503b7..cc36d18 100644
67774 --- a/include/linux/capability.h
67775 +++ b/include/linux/capability.h
67776 @@ -211,8 +211,13 @@ extern bool capable(int cap);
67777 extern bool ns_capable(struct user_namespace *ns, int cap);
67778 extern bool nsown_capable(int cap);
67779 extern bool inode_capable(const struct inode *inode, int cap);
67780 +extern bool capable_nolog(int cap);
67781 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67782 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67783
67784 /* audit system wants to get cap info from files as well */
67785 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67786
67787 +extern int is_privileged_binary(const struct dentry *dentry);
67788 +
67789 #endif /* !_LINUX_CAPABILITY_H */
67790 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67791 index 8609d57..86e4d79 100644
67792 --- a/include/linux/cdrom.h
67793 +++ b/include/linux/cdrom.h
67794 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67795
67796 /* driver specifications */
67797 const int capability; /* capability flags */
67798 - int n_minors; /* number of active minor devices */
67799 /* handle uniform packets for scsi type devices (scsi,atapi) */
67800 int (*generic_packet) (struct cdrom_device_info *,
67801 struct packet_command *);
67802 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67803 index 42e55de..1cd0e66 100644
67804 --- a/include/linux/cleancache.h
67805 +++ b/include/linux/cleancache.h
67806 @@ -31,7 +31,7 @@ struct cleancache_ops {
67807 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67808 void (*invalidate_inode)(int, struct cleancache_filekey);
67809 void (*invalidate_fs)(int);
67810 -};
67811 +} __no_const;
67812
67813 extern struct cleancache_ops
67814 cleancache_register_ops(struct cleancache_ops *ops);
67815 diff --git a/include/linux/compat.h b/include/linux/compat.h
67816 index dec7e2d..45db13f 100644
67817 --- a/include/linux/compat.h
67818 +++ b/include/linux/compat.h
67819 @@ -311,14 +311,14 @@ long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
67820 long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
67821 int version, void __user *uptr);
67822 long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
67823 - void __user *uptr);
67824 + void __user *uptr) __intentional_overflow(0);
67825 #else
67826 long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67827 long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
67828 compat_ssize_t msgsz, int msgflg);
67829 long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
67830 compat_ssize_t msgsz, long msgtyp, int msgflg);
67831 -long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67832 +long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67833 #endif
67834 long compat_sys_msgctl(int first, int second, void __user *uptr);
67835 long compat_sys_shmctl(int first, int second, void __user *uptr);
67836 @@ -414,7 +414,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67837 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67838 compat_ulong_t addr, compat_ulong_t data);
67839 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67840 - compat_long_t addr, compat_long_t data);
67841 + compat_ulong_t addr, compat_ulong_t data);
67842
67843 /*
67844 * epoll (fs/eventpoll.c) compat bits follow ...
67845 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67846 index 662fd1b..e801992 100644
67847 --- a/include/linux/compiler-gcc4.h
67848 +++ b/include/linux/compiler-gcc4.h
67849 @@ -34,6 +34,21 @@
67850 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
67851
67852 #if __GNUC_MINOR__ >= 5
67853 +
67854 +#ifdef CONSTIFY_PLUGIN
67855 +#define __no_const __attribute__((no_const))
67856 +#define __do_const __attribute__((do_const))
67857 +#endif
67858 +
67859 +#ifdef SIZE_OVERFLOW_PLUGIN
67860 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67861 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67862 +#endif
67863 +
67864 +#ifdef LATENT_ENTROPY_PLUGIN
67865 +#define __latent_entropy __attribute__((latent_entropy))
67866 +#endif
67867 +
67868 /*
67869 * Mark a position in code as unreachable. This can be used to
67870 * suppress control flow warnings after asm blocks that transfer
67871 @@ -49,6 +64,11 @@
67872 #define __noclone __attribute__((__noclone__))
67873
67874 #endif
67875 +
67876 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67877 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67878 +#define __bos0(ptr) __bos((ptr), 0)
67879 +#define __bos1(ptr) __bos((ptr), 1)
67880 #endif
67881
67882 #if __GNUC_MINOR__ >= 6
67883 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
67884 index dd852b7..1ad5fba 100644
67885 --- a/include/linux/compiler.h
67886 +++ b/include/linux/compiler.h
67887 @@ -5,11 +5,14 @@
67888
67889 #ifdef __CHECKER__
67890 # define __user __attribute__((noderef, address_space(1)))
67891 +# define __force_user __force __user
67892 # define __kernel __attribute__((address_space(0)))
67893 +# define __force_kernel __force __kernel
67894 # define __safe __attribute__((safe))
67895 # define __force __attribute__((force))
67896 # define __nocast __attribute__((nocast))
67897 # define __iomem __attribute__((noderef, address_space(2)))
67898 +# define __force_iomem __force __iomem
67899 # define __must_hold(x) __attribute__((context(x,1,1)))
67900 # define __acquires(x) __attribute__((context(x,0,1)))
67901 # define __releases(x) __attribute__((context(x,1,0)))
67902 @@ -17,20 +20,37 @@
67903 # define __release(x) __context__(x,-1)
67904 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
67905 # define __percpu __attribute__((noderef, address_space(3)))
67906 +# define __force_percpu __force __percpu
67907 #ifdef CONFIG_SPARSE_RCU_POINTER
67908 # define __rcu __attribute__((noderef, address_space(4)))
67909 +# define __force_rcu __force __rcu
67910 #else
67911 # define __rcu
67912 +# define __force_rcu
67913 #endif
67914 extern void __chk_user_ptr(const volatile void __user *);
67915 extern void __chk_io_ptr(const volatile void __iomem *);
67916 #else
67917 -# define __user
67918 -# define __kernel
67919 +# ifdef CHECKER_PLUGIN
67920 +//# define __user
67921 +//# define __force_user
67922 +//# define __kernel
67923 +//# define __force_kernel
67924 +# else
67925 +# ifdef STRUCTLEAK_PLUGIN
67926 +# define __user __attribute__((user))
67927 +# else
67928 +# define __user
67929 +# endif
67930 +# define __force_user
67931 +# define __kernel
67932 +# define __force_kernel
67933 +# endif
67934 # define __safe
67935 # define __force
67936 # define __nocast
67937 # define __iomem
67938 +# define __force_iomem
67939 # define __chk_user_ptr(x) (void)0
67940 # define __chk_io_ptr(x) (void)0
67941 # define __builtin_warning(x, y...) (1)
67942 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
67943 # define __release(x) (void)0
67944 # define __cond_lock(x,c) (c)
67945 # define __percpu
67946 +# define __force_percpu
67947 # define __rcu
67948 +# define __force_rcu
67949 #endif
67950
67951 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
67952 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67953 # define __attribute_const__ /* unimplemented */
67954 #endif
67955
67956 +#ifndef __no_const
67957 +# define __no_const
67958 +#endif
67959 +
67960 +#ifndef __do_const
67961 +# define __do_const
67962 +#endif
67963 +
67964 +#ifndef __size_overflow
67965 +# define __size_overflow(...)
67966 +#endif
67967 +
67968 +#ifndef __intentional_overflow
67969 +# define __intentional_overflow(...)
67970 +#endif
67971 +
67972 +#ifndef __latent_entropy
67973 +# define __latent_entropy
67974 +#endif
67975 +
67976 /*
67977 * Tell gcc if a function is cold. The compiler will assume any path
67978 * directly leading to the call is unlikely.
67979 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
67980 #define __cold
67981 #endif
67982
67983 +#ifndef __alloc_size
67984 +#define __alloc_size(...)
67985 +#endif
67986 +
67987 +#ifndef __bos
67988 +#define __bos(ptr, arg)
67989 +#endif
67990 +
67991 +#ifndef __bos0
67992 +#define __bos0(ptr)
67993 +#endif
67994 +
67995 +#ifndef __bos1
67996 +#define __bos1(ptr)
67997 +#endif
67998 +
67999 /* Simple shorthand for a section definition */
68000 #ifndef __section
68001 # define __section(S) __attribute__ ((__section__(#S)))
68002 @@ -323,6 +381,7 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68003 * use is to mediate communication between process-level code and irq/NMI
68004 * handlers, all running on the same CPU.
68005 */
68006 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68007 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68008 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68009
68010 #endif /* __LINUX_COMPILER_H */
68011 diff --git a/include/linux/completion.h b/include/linux/completion.h
68012 index 51494e6..0fd1b61 100644
68013 --- a/include/linux/completion.h
68014 +++ b/include/linux/completion.h
68015 @@ -78,13 +78,13 @@ static inline void init_completion(struct completion *x)
68016
68017 extern void wait_for_completion(struct completion *);
68018 extern int wait_for_completion_interruptible(struct completion *x);
68019 -extern int wait_for_completion_killable(struct completion *x);
68020 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68021 extern unsigned long wait_for_completion_timeout(struct completion *x,
68022 unsigned long timeout);
68023 extern long wait_for_completion_interruptible_timeout(
68024 - struct completion *x, unsigned long timeout);
68025 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68026 extern long wait_for_completion_killable_timeout(
68027 - struct completion *x, unsigned long timeout);
68028 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68029 extern bool try_wait_for_completion(struct completion *x);
68030 extern bool completion_done(struct completion *x);
68031
68032 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68033 index 34025df..d94bbbc 100644
68034 --- a/include/linux/configfs.h
68035 +++ b/include/linux/configfs.h
68036 @@ -125,7 +125,7 @@ struct configfs_attribute {
68037 const char *ca_name;
68038 struct module *ca_owner;
68039 umode_t ca_mode;
68040 -};
68041 +} __do_const;
68042
68043 /*
68044 * Users often need to create attribute structures for their configurable
68045 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68046 index ce7a074..01ab8ac 100644
68047 --- a/include/linux/cpu.h
68048 +++ b/include/linux/cpu.h
68049 @@ -115,7 +115,7 @@ enum {
68050 /* Need to know about CPUs going up/down? */
68051 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68052 #define cpu_notifier(fn, pri) { \
68053 - static struct notifier_block fn##_nb __cpuinitdata = \
68054 + static struct notifier_block fn##_nb = \
68055 { .notifier_call = fn, .priority = pri }; \
68056 register_cpu_notifier(&fn##_nb); \
68057 }
68058 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68059 index a55b88e..fba90c5 100644
68060 --- a/include/linux/cpufreq.h
68061 +++ b/include/linux/cpufreq.h
68062 @@ -240,7 +240,7 @@ struct cpufreq_driver {
68063 int (*suspend) (struct cpufreq_policy *policy);
68064 int (*resume) (struct cpufreq_policy *policy);
68065 struct freq_attr **attr;
68066 -};
68067 +} __do_const;
68068
68069 /* flags */
68070
68071 @@ -299,6 +299,7 @@ struct global_attr {
68072 ssize_t (*store)(struct kobject *a, struct attribute *b,
68073 const char *c, size_t count);
68074 };
68075 +typedef struct global_attr __no_const global_attr_no_const;
68076
68077 #define define_one_global_ro(_name) \
68078 static struct global_attr _name = \
68079 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68080 index 24cd1037..20a63aae 100644
68081 --- a/include/linux/cpuidle.h
68082 +++ b/include/linux/cpuidle.h
68083 @@ -54,7 +54,8 @@ struct cpuidle_state {
68084 int index);
68085
68086 int (*enter_dead) (struct cpuidle_device *dev, int index);
68087 -};
68088 +} __do_const;
68089 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68090
68091 /* Idle State Flags */
68092 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68093 @@ -216,7 +217,7 @@ struct cpuidle_governor {
68094 void (*reflect) (struct cpuidle_device *dev, int index);
68095
68096 struct module *owner;
68097 -};
68098 +} __do_const;
68099
68100 #ifdef CONFIG_CPU_IDLE
68101
68102 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68103 index 0325602..5e9feff 100644
68104 --- a/include/linux/cpumask.h
68105 +++ b/include/linux/cpumask.h
68106 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68107 }
68108
68109 /* Valid inputs for n are -1 and 0. */
68110 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68111 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68112 {
68113 return n+1;
68114 }
68115
68116 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68117 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68118 {
68119 return n+1;
68120 }
68121
68122 -static inline unsigned int cpumask_next_and(int n,
68123 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68124 const struct cpumask *srcp,
68125 const struct cpumask *andp)
68126 {
68127 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68128 *
68129 * Returns >= nr_cpu_ids if no further cpus set.
68130 */
68131 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68132 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68133 {
68134 /* -1 is a legal arg here. */
68135 if (n != -1)
68136 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68137 *
68138 * Returns >= nr_cpu_ids if no further cpus unset.
68139 */
68140 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68141 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68142 {
68143 /* -1 is a legal arg here. */
68144 if (n != -1)
68145 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68146 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68147 }
68148
68149 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68150 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68151 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68152
68153 /**
68154 diff --git a/include/linux/cred.h b/include/linux/cred.h
68155 index 04421e8..6bce4ef 100644
68156 --- a/include/linux/cred.h
68157 +++ b/include/linux/cred.h
68158 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68159 static inline void validate_process_creds(void)
68160 {
68161 }
68162 +static inline void validate_task_creds(struct task_struct *task)
68163 +{
68164 +}
68165 #endif
68166
68167 /**
68168 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68169 index b92eadf..b4ecdc1 100644
68170 --- a/include/linux/crypto.h
68171 +++ b/include/linux/crypto.h
68172 @@ -373,7 +373,7 @@ struct cipher_tfm {
68173 const u8 *key, unsigned int keylen);
68174 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68175 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68176 -};
68177 +} __no_const;
68178
68179 struct hash_tfm {
68180 int (*init)(struct hash_desc *desc);
68181 @@ -394,13 +394,13 @@ struct compress_tfm {
68182 int (*cot_decompress)(struct crypto_tfm *tfm,
68183 const u8 *src, unsigned int slen,
68184 u8 *dst, unsigned int *dlen);
68185 -};
68186 +} __no_const;
68187
68188 struct rng_tfm {
68189 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68190 unsigned int dlen);
68191 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68192 -};
68193 +} __no_const;
68194
68195 #define crt_ablkcipher crt_u.ablkcipher
68196 #define crt_aead crt_u.aead
68197 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68198 index 8acfe31..6ffccd63 100644
68199 --- a/include/linux/ctype.h
68200 +++ b/include/linux/ctype.h
68201 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68202 * Fast implementation of tolower() for internal usage. Do not use in your
68203 * code.
68204 */
68205 -static inline char _tolower(const char c)
68206 +static inline unsigned char _tolower(const unsigned char c)
68207 {
68208 return c | 0x20;
68209 }
68210 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68211 index 7925bf0..d5143d2 100644
68212 --- a/include/linux/decompress/mm.h
68213 +++ b/include/linux/decompress/mm.h
68214 @@ -77,7 +77,7 @@ static void free(void *where)
68215 * warnings when not needed (indeed large_malloc / large_free are not
68216 * needed by inflate */
68217
68218 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68219 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68220 #define free(a) kfree(a)
68221
68222 #define large_malloc(a) vmalloc(a)
68223 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68224 index e83ef39..33e0eb3 100644
68225 --- a/include/linux/devfreq.h
68226 +++ b/include/linux/devfreq.h
68227 @@ -114,7 +114,7 @@ struct devfreq_governor {
68228 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68229 int (*event_handler)(struct devfreq *devfreq,
68230 unsigned int event, void *data);
68231 -};
68232 +} __do_const;
68233
68234 /**
68235 * struct devfreq - Device devfreq structure
68236 diff --git a/include/linux/device.h b/include/linux/device.h
68237 index 43dcda9..7a1fb65 100644
68238 --- a/include/linux/device.h
68239 +++ b/include/linux/device.h
68240 @@ -294,7 +294,7 @@ struct subsys_interface {
68241 struct list_head node;
68242 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68243 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68244 -};
68245 +} __do_const;
68246
68247 int subsys_interface_register(struct subsys_interface *sif);
68248 void subsys_interface_unregister(struct subsys_interface *sif);
68249 @@ -474,7 +474,7 @@ struct device_type {
68250 void (*release)(struct device *dev);
68251
68252 const struct dev_pm_ops *pm;
68253 -};
68254 +} __do_const;
68255
68256 /* interface for exporting device attributes */
68257 struct device_attribute {
68258 @@ -484,11 +484,12 @@ struct device_attribute {
68259 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68260 const char *buf, size_t count);
68261 };
68262 +typedef struct device_attribute __no_const device_attribute_no_const;
68263
68264 struct dev_ext_attribute {
68265 struct device_attribute attr;
68266 void *var;
68267 -};
68268 +} __do_const;
68269
68270 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68271 char *buf);
68272 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68273 index 94af418..b1ca7a2 100644
68274 --- a/include/linux/dma-mapping.h
68275 +++ b/include/linux/dma-mapping.h
68276 @@ -54,7 +54,7 @@ struct dma_map_ops {
68277 u64 (*get_required_mask)(struct device *dev);
68278 #endif
68279 int is_phys;
68280 -};
68281 +} __do_const;
68282
68283 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68284
68285 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68286 index d3201e4..8281e63 100644
68287 --- a/include/linux/dmaengine.h
68288 +++ b/include/linux/dmaengine.h
68289 @@ -1018,9 +1018,9 @@ struct dma_pinned_list {
68290 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68291 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68292
68293 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68294 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68295 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68296 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68297 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68298 struct dma_pinned_list *pinned_list, struct page *page,
68299 unsigned int offset, size_t len);
68300
68301 diff --git a/include/linux/efi.h b/include/linux/efi.h
68302 index 7a9498a..155713d 100644
68303 --- a/include/linux/efi.h
68304 +++ b/include/linux/efi.h
68305 @@ -733,6 +733,7 @@ struct efivar_operations {
68306 efi_set_variable_t *set_variable;
68307 efi_query_variable_info_t *query_variable_info;
68308 };
68309 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68310
68311 struct efivars {
68312 /*
68313 diff --git a/include/linux/elf.h b/include/linux/elf.h
68314 index 8c9048e..16a4665 100644
68315 --- a/include/linux/elf.h
68316 +++ b/include/linux/elf.h
68317 @@ -20,6 +20,7 @@ extern Elf32_Dyn _DYNAMIC [];
68318 #define elf_note elf32_note
68319 #define elf_addr_t Elf32_Off
68320 #define Elf_Half Elf32_Half
68321 +#define elf_dyn Elf32_Dyn
68322
68323 #else
68324
68325 @@ -30,6 +31,7 @@ extern Elf64_Dyn _DYNAMIC [];
68326 #define elf_note elf64_note
68327 #define elf_addr_t Elf64_Off
68328 #define Elf_Half Elf64_Half
68329 +#define elf_dyn Elf64_Dyn
68330
68331 #endif
68332
68333 diff --git a/include/linux/err.h b/include/linux/err.h
68334 index f2edce2..cc2082c 100644
68335 --- a/include/linux/err.h
68336 +++ b/include/linux/err.h
68337 @@ -19,12 +19,12 @@
68338
68339 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68340
68341 -static inline void * __must_check ERR_PTR(long error)
68342 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68343 {
68344 return (void *) error;
68345 }
68346
68347 -static inline long __must_check PTR_ERR(const void *ptr)
68348 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68349 {
68350 return (long) ptr;
68351 }
68352 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68353 index fcb51c8..bdafcf6 100644
68354 --- a/include/linux/extcon.h
68355 +++ b/include/linux/extcon.h
68356 @@ -134,7 +134,7 @@ struct extcon_dev {
68357 /* /sys/class/extcon/.../mutually_exclusive/... */
68358 struct attribute_group attr_g_muex;
68359 struct attribute **attrs_muex;
68360 - struct device_attribute *d_attrs_muex;
68361 + device_attribute_no_const *d_attrs_muex;
68362 };
68363
68364 /**
68365 diff --git a/include/linux/fb.h b/include/linux/fb.h
68366 index c7a9571..02eeffe 100644
68367 --- a/include/linux/fb.h
68368 +++ b/include/linux/fb.h
68369 @@ -302,7 +302,7 @@ struct fb_ops {
68370 /* called at KDB enter and leave time to prepare the console */
68371 int (*fb_debug_enter)(struct fb_info *info);
68372 int (*fb_debug_leave)(struct fb_info *info);
68373 -};
68374 +} __do_const;
68375
68376 #ifdef CONFIG_FB_TILEBLITTING
68377 #define FB_TILE_CURSOR_NONE 0
68378 diff --git a/include/linux/filter.h b/include/linux/filter.h
68379 index c45eabc..baa0be5 100644
68380 --- a/include/linux/filter.h
68381 +++ b/include/linux/filter.h
68382 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68383
68384 struct sk_buff;
68385 struct sock;
68386 +struct bpf_jit_work;
68387
68388 struct sk_filter
68389 {
68390 @@ -27,6 +28,9 @@ struct sk_filter
68391 unsigned int len; /* Number of filter blocks */
68392 unsigned int (*bpf_func)(const struct sk_buff *skb,
68393 const struct sock_filter *filter);
68394 +#ifdef CONFIG_BPF_JIT
68395 + struct bpf_jit_work *work;
68396 +#endif
68397 struct rcu_head rcu;
68398 struct sock_filter insns[0];
68399 };
68400 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68401 index 3044254..9767f41 100644
68402 --- a/include/linux/frontswap.h
68403 +++ b/include/linux/frontswap.h
68404 @@ -11,7 +11,7 @@ struct frontswap_ops {
68405 int (*load)(unsigned, pgoff_t, struct page *);
68406 void (*invalidate_page)(unsigned, pgoff_t);
68407 void (*invalidate_area)(unsigned);
68408 -};
68409 +} __no_const;
68410
68411 extern bool frontswap_enabled;
68412 extern struct frontswap_ops
68413 diff --git a/include/linux/fs.h b/include/linux/fs.h
68414 index 7617ee0..b575199 100644
68415 --- a/include/linux/fs.h
68416 +++ b/include/linux/fs.h
68417 @@ -1541,7 +1541,8 @@ struct file_operations {
68418 long (*fallocate)(struct file *file, int mode, loff_t offset,
68419 loff_t len);
68420 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68421 -};
68422 +} __do_const;
68423 +typedef struct file_operations __no_const file_operations_no_const;
68424
68425 struct inode_operations {
68426 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68427 @@ -2665,4 +2666,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68428 inode->i_flags |= S_NOSEC;
68429 }
68430
68431 +static inline bool is_sidechannel_device(const struct inode *inode)
68432 +{
68433 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68434 + umode_t mode = inode->i_mode;
68435 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68436 +#else
68437 + return false;
68438 +#endif
68439 +}
68440 +
68441 #endif /* _LINUX_FS_H */
68442 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68443 index 324f931..f292b65 100644
68444 --- a/include/linux/fs_struct.h
68445 +++ b/include/linux/fs_struct.h
68446 @@ -6,7 +6,7 @@
68447 #include <linux/seqlock.h>
68448
68449 struct fs_struct {
68450 - int users;
68451 + atomic_t users;
68452 spinlock_t lock;
68453 seqcount_t seq;
68454 int umask;
68455 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68456 index 5dfa0aa..6acf322 100644
68457 --- a/include/linux/fscache-cache.h
68458 +++ b/include/linux/fscache-cache.h
68459 @@ -112,7 +112,7 @@ struct fscache_operation {
68460 fscache_operation_release_t release;
68461 };
68462
68463 -extern atomic_t fscache_op_debug_id;
68464 +extern atomic_unchecked_t fscache_op_debug_id;
68465 extern void fscache_op_work_func(struct work_struct *work);
68466
68467 extern void fscache_enqueue_operation(struct fscache_operation *);
68468 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68469 INIT_WORK(&op->work, fscache_op_work_func);
68470 atomic_set(&op->usage, 1);
68471 op->state = FSCACHE_OP_ST_INITIALISED;
68472 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68473 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68474 op->processor = processor;
68475 op->release = release;
68476 INIT_LIST_HEAD(&op->pend_link);
68477 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68478 index 7a08623..4c07b0f 100644
68479 --- a/include/linux/fscache.h
68480 +++ b/include/linux/fscache.h
68481 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68482 * - this is mandatory for any object that may have data
68483 */
68484 void (*now_uncached)(void *cookie_netfs_data);
68485 -};
68486 +} __do_const;
68487
68488 /*
68489 * fscache cached network filesystem type
68490 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68491 index 0fbfb46..508eb0d 100644
68492 --- a/include/linux/fsnotify.h
68493 +++ b/include/linux/fsnotify.h
68494 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68495 struct inode *inode = path->dentry->d_inode;
68496 __u32 mask = FS_ACCESS;
68497
68498 + if (is_sidechannel_device(inode))
68499 + return;
68500 +
68501 if (S_ISDIR(inode->i_mode))
68502 mask |= FS_ISDIR;
68503
68504 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68505 struct inode *inode = path->dentry->d_inode;
68506 __u32 mask = FS_MODIFY;
68507
68508 + if (is_sidechannel_device(inode))
68509 + return;
68510 +
68511 if (S_ISDIR(inode->i_mode))
68512 mask |= FS_ISDIR;
68513
68514 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68515 */
68516 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68517 {
68518 - return kstrdup(name, GFP_KERNEL);
68519 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68520 }
68521
68522 /*
68523 diff --git a/include/linux/ftrace_event.h b/include/linux/ftrace_event.h
68524 index a3d4895..ddd2a50 100644
68525 --- a/include/linux/ftrace_event.h
68526 +++ b/include/linux/ftrace_event.h
68527 @@ -272,7 +272,7 @@ extern int trace_define_field(struct ftrace_event_call *call, const char *type,
68528 extern int trace_add_event_call(struct ftrace_event_call *call);
68529 extern void trace_remove_event_call(struct ftrace_event_call *call);
68530
68531 -#define is_signed_type(type) (((type)(-1)) < 0)
68532 +#define is_signed_type(type) (((type)(-1)) < (type)1)
68533
68534 int trace_set_clr_event(const char *system, const char *event, int set);
68535
68536 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68537 index 79b8bba..86b539e 100644
68538 --- a/include/linux/genhd.h
68539 +++ b/include/linux/genhd.h
68540 @@ -194,7 +194,7 @@ struct gendisk {
68541 struct kobject *slave_dir;
68542
68543 struct timer_rand_state *random;
68544 - atomic_t sync_io; /* RAID */
68545 + atomic_unchecked_t sync_io; /* RAID */
68546 struct disk_events *ev;
68547 #ifdef CONFIG_BLK_DEV_INTEGRITY
68548 struct blk_integrity *integrity;
68549 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68550 index 023bc34..b02b46a 100644
68551 --- a/include/linux/genl_magic_func.h
68552 +++ b/include/linux/genl_magic_func.h
68553 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68554 },
68555
68556 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68557 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68558 +static struct genl_ops ZZZ_genl_ops[] = {
68559 #include GENL_MAGIC_INCLUDE_FILE
68560 };
68561
68562 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68563 index 0f615eb..5c3832f 100644
68564 --- a/include/linux/gfp.h
68565 +++ b/include/linux/gfp.h
68566 @@ -35,6 +35,13 @@ struct vm_area_struct;
68567 #define ___GFP_NO_KSWAPD 0x400000u
68568 #define ___GFP_OTHER_NODE 0x800000u
68569 #define ___GFP_WRITE 0x1000000u
68570 +
68571 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68572 +#define ___GFP_USERCOPY 0x2000000u
68573 +#else
68574 +#define ___GFP_USERCOPY 0
68575 +#endif
68576 +
68577 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68578
68579 /*
68580 @@ -92,6 +99,7 @@ struct vm_area_struct;
68581 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68582 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68583 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68584 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68585
68586 /*
68587 * This may seem redundant, but it's a way of annotating false positives vs.
68588 @@ -99,7 +107,7 @@ struct vm_area_struct;
68589 */
68590 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68591
68592 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68593 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68594 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68595
68596 /* This equals 0, but use constants in case they ever change */
68597 @@ -153,6 +161,8 @@ struct vm_area_struct;
68598 /* 4GB DMA on some platforms */
68599 #define GFP_DMA32 __GFP_DMA32
68600
68601 +#define GFP_USERCOPY __GFP_USERCOPY
68602 +
68603 /* Convert GFP flags to their corresponding migrate type */
68604 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68605 {
68606 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68607 new file mode 100644
68608 index 0000000..ebe6d72
68609 --- /dev/null
68610 +++ b/include/linux/gracl.h
68611 @@ -0,0 +1,319 @@
68612 +#ifndef GR_ACL_H
68613 +#define GR_ACL_H
68614 +
68615 +#include <linux/grdefs.h>
68616 +#include <linux/resource.h>
68617 +#include <linux/capability.h>
68618 +#include <linux/dcache.h>
68619 +#include <asm/resource.h>
68620 +
68621 +/* Major status information */
68622 +
68623 +#define GR_VERSION "grsecurity 2.9.1"
68624 +#define GRSECURITY_VERSION 0x2901
68625 +
68626 +enum {
68627 + GR_SHUTDOWN = 0,
68628 + GR_ENABLE = 1,
68629 + GR_SPROLE = 2,
68630 + GR_RELOAD = 3,
68631 + GR_SEGVMOD = 4,
68632 + GR_STATUS = 5,
68633 + GR_UNSPROLE = 6,
68634 + GR_PASSSET = 7,
68635 + GR_SPROLEPAM = 8,
68636 +};
68637 +
68638 +/* Password setup definitions
68639 + * kernel/grhash.c */
68640 +enum {
68641 + GR_PW_LEN = 128,
68642 + GR_SALT_LEN = 16,
68643 + GR_SHA_LEN = 32,
68644 +};
68645 +
68646 +enum {
68647 + GR_SPROLE_LEN = 64,
68648 +};
68649 +
68650 +enum {
68651 + GR_NO_GLOB = 0,
68652 + GR_REG_GLOB,
68653 + GR_CREATE_GLOB
68654 +};
68655 +
68656 +#define GR_NLIMITS 32
68657 +
68658 +/* Begin Data Structures */
68659 +
68660 +struct sprole_pw {
68661 + unsigned char *rolename;
68662 + unsigned char salt[GR_SALT_LEN];
68663 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68664 +};
68665 +
68666 +struct name_entry {
68667 + __u32 key;
68668 + ino_t inode;
68669 + dev_t device;
68670 + char *name;
68671 + __u16 len;
68672 + __u8 deleted;
68673 + struct name_entry *prev;
68674 + struct name_entry *next;
68675 +};
68676 +
68677 +struct inodev_entry {
68678 + struct name_entry *nentry;
68679 + struct inodev_entry *prev;
68680 + struct inodev_entry *next;
68681 +};
68682 +
68683 +struct acl_role_db {
68684 + struct acl_role_label **r_hash;
68685 + __u32 r_size;
68686 +};
68687 +
68688 +struct inodev_db {
68689 + struct inodev_entry **i_hash;
68690 + __u32 i_size;
68691 +};
68692 +
68693 +struct name_db {
68694 + struct name_entry **n_hash;
68695 + __u32 n_size;
68696 +};
68697 +
68698 +struct crash_uid {
68699 + uid_t uid;
68700 + unsigned long expires;
68701 +};
68702 +
68703 +struct gr_hash_struct {
68704 + void **table;
68705 + void **nametable;
68706 + void *first;
68707 + __u32 table_size;
68708 + __u32 used_size;
68709 + int type;
68710 +};
68711 +
68712 +/* Userspace Grsecurity ACL data structures */
68713 +
68714 +struct acl_subject_label {
68715 + char *filename;
68716 + ino_t inode;
68717 + dev_t device;
68718 + __u32 mode;
68719 + kernel_cap_t cap_mask;
68720 + kernel_cap_t cap_lower;
68721 + kernel_cap_t cap_invert_audit;
68722 +
68723 + struct rlimit res[GR_NLIMITS];
68724 + __u32 resmask;
68725 +
68726 + __u8 user_trans_type;
68727 + __u8 group_trans_type;
68728 + uid_t *user_transitions;
68729 + gid_t *group_transitions;
68730 + __u16 user_trans_num;
68731 + __u16 group_trans_num;
68732 +
68733 + __u32 sock_families[2];
68734 + __u32 ip_proto[8];
68735 + __u32 ip_type;
68736 + struct acl_ip_label **ips;
68737 + __u32 ip_num;
68738 + __u32 inaddr_any_override;
68739 +
68740 + __u32 crashes;
68741 + unsigned long expires;
68742 +
68743 + struct acl_subject_label *parent_subject;
68744 + struct gr_hash_struct *hash;
68745 + struct acl_subject_label *prev;
68746 + struct acl_subject_label *next;
68747 +
68748 + struct acl_object_label **obj_hash;
68749 + __u32 obj_hash_size;
68750 + __u16 pax_flags;
68751 +};
68752 +
68753 +struct role_allowed_ip {
68754 + __u32 addr;
68755 + __u32 netmask;
68756 +
68757 + struct role_allowed_ip *prev;
68758 + struct role_allowed_ip *next;
68759 +};
68760 +
68761 +struct role_transition {
68762 + char *rolename;
68763 +
68764 + struct role_transition *prev;
68765 + struct role_transition *next;
68766 +};
68767 +
68768 +struct acl_role_label {
68769 + char *rolename;
68770 + uid_t uidgid;
68771 + __u16 roletype;
68772 +
68773 + __u16 auth_attempts;
68774 + unsigned long expires;
68775 +
68776 + struct acl_subject_label *root_label;
68777 + struct gr_hash_struct *hash;
68778 +
68779 + struct acl_role_label *prev;
68780 + struct acl_role_label *next;
68781 +
68782 + struct role_transition *transitions;
68783 + struct role_allowed_ip *allowed_ips;
68784 + uid_t *domain_children;
68785 + __u16 domain_child_num;
68786 +
68787 + umode_t umask;
68788 +
68789 + struct acl_subject_label **subj_hash;
68790 + __u32 subj_hash_size;
68791 +};
68792 +
68793 +struct user_acl_role_db {
68794 + struct acl_role_label **r_table;
68795 + __u32 num_pointers; /* Number of allocations to track */
68796 + __u32 num_roles; /* Number of roles */
68797 + __u32 num_domain_children; /* Number of domain children */
68798 + __u32 num_subjects; /* Number of subjects */
68799 + __u32 num_objects; /* Number of objects */
68800 +};
68801 +
68802 +struct acl_object_label {
68803 + char *filename;
68804 + ino_t inode;
68805 + dev_t device;
68806 + __u32 mode;
68807 +
68808 + struct acl_subject_label *nested;
68809 + struct acl_object_label *globbed;
68810 +
68811 + /* next two structures not used */
68812 +
68813 + struct acl_object_label *prev;
68814 + struct acl_object_label *next;
68815 +};
68816 +
68817 +struct acl_ip_label {
68818 + char *iface;
68819 + __u32 addr;
68820 + __u32 netmask;
68821 + __u16 low, high;
68822 + __u8 mode;
68823 + __u32 type;
68824 + __u32 proto[8];
68825 +
68826 + /* next two structures not used */
68827 +
68828 + struct acl_ip_label *prev;
68829 + struct acl_ip_label *next;
68830 +};
68831 +
68832 +struct gr_arg {
68833 + struct user_acl_role_db role_db;
68834 + unsigned char pw[GR_PW_LEN];
68835 + unsigned char salt[GR_SALT_LEN];
68836 + unsigned char sum[GR_SHA_LEN];
68837 + unsigned char sp_role[GR_SPROLE_LEN];
68838 + struct sprole_pw *sprole_pws;
68839 + dev_t segv_device;
68840 + ino_t segv_inode;
68841 + uid_t segv_uid;
68842 + __u16 num_sprole_pws;
68843 + __u16 mode;
68844 +};
68845 +
68846 +struct gr_arg_wrapper {
68847 + struct gr_arg *arg;
68848 + __u32 version;
68849 + __u32 size;
68850 +};
68851 +
68852 +struct subject_map {
68853 + struct acl_subject_label *user;
68854 + struct acl_subject_label *kernel;
68855 + struct subject_map *prev;
68856 + struct subject_map *next;
68857 +};
68858 +
68859 +struct acl_subj_map_db {
68860 + struct subject_map **s_hash;
68861 + __u32 s_size;
68862 +};
68863 +
68864 +/* End Data Structures Section */
68865 +
68866 +/* Hash functions generated by empirical testing by Brad Spengler
68867 + Makes good use of the low bits of the inode. Generally 0-1 times
68868 + in loop for successful match. 0-3 for unsuccessful match.
68869 + Shift/add algorithm with modulus of table size and an XOR*/
68870 +
68871 +static __inline__ unsigned int
68872 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68873 +{
68874 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68875 +}
68876 +
68877 + static __inline__ unsigned int
68878 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68879 +{
68880 + return ((const unsigned long)userp % sz);
68881 +}
68882 +
68883 +static __inline__ unsigned int
68884 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68885 +{
68886 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
68887 +}
68888 +
68889 +static __inline__ unsigned int
68890 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
68891 +{
68892 + return full_name_hash((const unsigned char *)name, len) % sz;
68893 +}
68894 +
68895 +#define FOR_EACH_ROLE_START(role) \
68896 + role = role_list; \
68897 + while (role) {
68898 +
68899 +#define FOR_EACH_ROLE_END(role) \
68900 + role = role->prev; \
68901 + }
68902 +
68903 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
68904 + subj = NULL; \
68905 + iter = 0; \
68906 + while (iter < role->subj_hash_size) { \
68907 + if (subj == NULL) \
68908 + subj = role->subj_hash[iter]; \
68909 + if (subj == NULL) { \
68910 + iter++; \
68911 + continue; \
68912 + }
68913 +
68914 +#define FOR_EACH_SUBJECT_END(subj,iter) \
68915 + subj = subj->next; \
68916 + if (subj == NULL) \
68917 + iter++; \
68918 + }
68919 +
68920 +
68921 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
68922 + subj = role->hash->first; \
68923 + while (subj != NULL) {
68924 +
68925 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
68926 + subj = subj->next; \
68927 + }
68928 +
68929 +#endif
68930 +
68931 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
68932 new file mode 100644
68933 index 0000000..323ecf2
68934 --- /dev/null
68935 +++ b/include/linux/gralloc.h
68936 @@ -0,0 +1,9 @@
68937 +#ifndef __GRALLOC_H
68938 +#define __GRALLOC_H
68939 +
68940 +void acl_free_all(void);
68941 +int acl_alloc_stack_init(unsigned long size);
68942 +void *acl_alloc(unsigned long len);
68943 +void *acl_alloc_num(unsigned long num, unsigned long len);
68944 +
68945 +#endif
68946 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
68947 new file mode 100644
68948 index 0000000..be66033
68949 --- /dev/null
68950 +++ b/include/linux/grdefs.h
68951 @@ -0,0 +1,140 @@
68952 +#ifndef GRDEFS_H
68953 +#define GRDEFS_H
68954 +
68955 +/* Begin grsecurity status declarations */
68956 +
68957 +enum {
68958 + GR_READY = 0x01,
68959 + GR_STATUS_INIT = 0x00 // disabled state
68960 +};
68961 +
68962 +/* Begin ACL declarations */
68963 +
68964 +/* Role flags */
68965 +
68966 +enum {
68967 + GR_ROLE_USER = 0x0001,
68968 + GR_ROLE_GROUP = 0x0002,
68969 + GR_ROLE_DEFAULT = 0x0004,
68970 + GR_ROLE_SPECIAL = 0x0008,
68971 + GR_ROLE_AUTH = 0x0010,
68972 + GR_ROLE_NOPW = 0x0020,
68973 + GR_ROLE_GOD = 0x0040,
68974 + GR_ROLE_LEARN = 0x0080,
68975 + GR_ROLE_TPE = 0x0100,
68976 + GR_ROLE_DOMAIN = 0x0200,
68977 + GR_ROLE_PAM = 0x0400,
68978 + GR_ROLE_PERSIST = 0x0800
68979 +};
68980 +
68981 +/* ACL Subject and Object mode flags */
68982 +enum {
68983 + GR_DELETED = 0x80000000
68984 +};
68985 +
68986 +/* ACL Object-only mode flags */
68987 +enum {
68988 + GR_READ = 0x00000001,
68989 + GR_APPEND = 0x00000002,
68990 + GR_WRITE = 0x00000004,
68991 + GR_EXEC = 0x00000008,
68992 + GR_FIND = 0x00000010,
68993 + GR_INHERIT = 0x00000020,
68994 + GR_SETID = 0x00000040,
68995 + GR_CREATE = 0x00000080,
68996 + GR_DELETE = 0x00000100,
68997 + GR_LINK = 0x00000200,
68998 + GR_AUDIT_READ = 0x00000400,
68999 + GR_AUDIT_APPEND = 0x00000800,
69000 + GR_AUDIT_WRITE = 0x00001000,
69001 + GR_AUDIT_EXEC = 0x00002000,
69002 + GR_AUDIT_FIND = 0x00004000,
69003 + GR_AUDIT_INHERIT= 0x00008000,
69004 + GR_AUDIT_SETID = 0x00010000,
69005 + GR_AUDIT_CREATE = 0x00020000,
69006 + GR_AUDIT_DELETE = 0x00040000,
69007 + GR_AUDIT_LINK = 0x00080000,
69008 + GR_PTRACERD = 0x00100000,
69009 + GR_NOPTRACE = 0x00200000,
69010 + GR_SUPPRESS = 0x00400000,
69011 + GR_NOLEARN = 0x00800000,
69012 + GR_INIT_TRANSFER= 0x01000000
69013 +};
69014 +
69015 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69016 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69017 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69018 +
69019 +/* ACL subject-only mode flags */
69020 +enum {
69021 + GR_KILL = 0x00000001,
69022 + GR_VIEW = 0x00000002,
69023 + GR_PROTECTED = 0x00000004,
69024 + GR_LEARN = 0x00000008,
69025 + GR_OVERRIDE = 0x00000010,
69026 + /* just a placeholder, this mode is only used in userspace */
69027 + GR_DUMMY = 0x00000020,
69028 + GR_PROTSHM = 0x00000040,
69029 + GR_KILLPROC = 0x00000080,
69030 + GR_KILLIPPROC = 0x00000100,
69031 + /* just a placeholder, this mode is only used in userspace */
69032 + GR_NOTROJAN = 0x00000200,
69033 + GR_PROTPROCFD = 0x00000400,
69034 + GR_PROCACCT = 0x00000800,
69035 + GR_RELAXPTRACE = 0x00001000,
69036 + //GR_NESTED = 0x00002000,
69037 + GR_INHERITLEARN = 0x00004000,
69038 + GR_PROCFIND = 0x00008000,
69039 + GR_POVERRIDE = 0x00010000,
69040 + GR_KERNELAUTH = 0x00020000,
69041 + GR_ATSECURE = 0x00040000,
69042 + GR_SHMEXEC = 0x00080000
69043 +};
69044 +
69045 +enum {
69046 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69047 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69048 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69049 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69050 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69051 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69052 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69053 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69054 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69055 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69056 +};
69057 +
69058 +enum {
69059 + GR_ID_USER = 0x01,
69060 + GR_ID_GROUP = 0x02,
69061 +};
69062 +
69063 +enum {
69064 + GR_ID_ALLOW = 0x01,
69065 + GR_ID_DENY = 0x02,
69066 +};
69067 +
69068 +#define GR_CRASH_RES 31
69069 +#define GR_UIDTABLE_MAX 500
69070 +
69071 +/* begin resource learning section */
69072 +enum {
69073 + GR_RLIM_CPU_BUMP = 60,
69074 + GR_RLIM_FSIZE_BUMP = 50000,
69075 + GR_RLIM_DATA_BUMP = 10000,
69076 + GR_RLIM_STACK_BUMP = 1000,
69077 + GR_RLIM_CORE_BUMP = 10000,
69078 + GR_RLIM_RSS_BUMP = 500000,
69079 + GR_RLIM_NPROC_BUMP = 1,
69080 + GR_RLIM_NOFILE_BUMP = 5,
69081 + GR_RLIM_MEMLOCK_BUMP = 50000,
69082 + GR_RLIM_AS_BUMP = 500000,
69083 + GR_RLIM_LOCKS_BUMP = 2,
69084 + GR_RLIM_SIGPENDING_BUMP = 5,
69085 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69086 + GR_RLIM_NICE_BUMP = 1,
69087 + GR_RLIM_RTPRIO_BUMP = 1,
69088 + GR_RLIM_RTTIME_BUMP = 1000000
69089 +};
69090 +
69091 +#endif
69092 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69093 new file mode 100644
69094 index 0000000..9bb6662
69095 --- /dev/null
69096 +++ b/include/linux/grinternal.h
69097 @@ -0,0 +1,215 @@
69098 +#ifndef __GRINTERNAL_H
69099 +#define __GRINTERNAL_H
69100 +
69101 +#ifdef CONFIG_GRKERNSEC
69102 +
69103 +#include <linux/fs.h>
69104 +#include <linux/mnt_namespace.h>
69105 +#include <linux/nsproxy.h>
69106 +#include <linux/gracl.h>
69107 +#include <linux/grdefs.h>
69108 +#include <linux/grmsg.h>
69109 +
69110 +void gr_add_learn_entry(const char *fmt, ...)
69111 + __attribute__ ((format (printf, 1, 2)));
69112 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69113 + const struct vfsmount *mnt);
69114 +__u32 gr_check_create(const struct dentry *new_dentry,
69115 + const struct dentry *parent,
69116 + const struct vfsmount *mnt, const __u32 mode);
69117 +int gr_check_protected_task(const struct task_struct *task);
69118 +__u32 to_gr_audit(const __u32 reqmode);
69119 +int gr_set_acls(const int type);
69120 +int gr_apply_subject_to_task(struct task_struct *task);
69121 +int gr_acl_is_enabled(void);
69122 +char gr_roletype_to_char(void);
69123 +
69124 +void gr_handle_alertkill(struct task_struct *task);
69125 +char *gr_to_filename(const struct dentry *dentry,
69126 + const struct vfsmount *mnt);
69127 +char *gr_to_filename1(const struct dentry *dentry,
69128 + const struct vfsmount *mnt);
69129 +char *gr_to_filename2(const struct dentry *dentry,
69130 + const struct vfsmount *mnt);
69131 +char *gr_to_filename3(const struct dentry *dentry,
69132 + const struct vfsmount *mnt);
69133 +
69134 +extern int grsec_enable_ptrace_readexec;
69135 +extern int grsec_enable_harden_ptrace;
69136 +extern int grsec_enable_link;
69137 +extern int grsec_enable_fifo;
69138 +extern int grsec_enable_execve;
69139 +extern int grsec_enable_shm;
69140 +extern int grsec_enable_execlog;
69141 +extern int grsec_enable_signal;
69142 +extern int grsec_enable_audit_ptrace;
69143 +extern int grsec_enable_forkfail;
69144 +extern int grsec_enable_time;
69145 +extern int grsec_enable_rofs;
69146 +extern int grsec_enable_chroot_shmat;
69147 +extern int grsec_enable_chroot_mount;
69148 +extern int grsec_enable_chroot_double;
69149 +extern int grsec_enable_chroot_pivot;
69150 +extern int grsec_enable_chroot_chdir;
69151 +extern int grsec_enable_chroot_chmod;
69152 +extern int grsec_enable_chroot_mknod;
69153 +extern int grsec_enable_chroot_fchdir;
69154 +extern int grsec_enable_chroot_nice;
69155 +extern int grsec_enable_chroot_execlog;
69156 +extern int grsec_enable_chroot_caps;
69157 +extern int grsec_enable_chroot_sysctl;
69158 +extern int grsec_enable_chroot_unix;
69159 +extern int grsec_enable_symlinkown;
69160 +extern kgid_t grsec_symlinkown_gid;
69161 +extern int grsec_enable_tpe;
69162 +extern kgid_t grsec_tpe_gid;
69163 +extern int grsec_enable_tpe_all;
69164 +extern int grsec_enable_tpe_invert;
69165 +extern int grsec_enable_socket_all;
69166 +extern kgid_t grsec_socket_all_gid;
69167 +extern int grsec_enable_socket_client;
69168 +extern kgid_t grsec_socket_client_gid;
69169 +extern int grsec_enable_socket_server;
69170 +extern kgid_t grsec_socket_server_gid;
69171 +extern kgid_t grsec_audit_gid;
69172 +extern int grsec_enable_group;
69173 +extern int grsec_enable_audit_textrel;
69174 +extern int grsec_enable_log_rwxmaps;
69175 +extern int grsec_enable_mount;
69176 +extern int grsec_enable_chdir;
69177 +extern int grsec_resource_logging;
69178 +extern int grsec_enable_blackhole;
69179 +extern int grsec_lastack_retries;
69180 +extern int grsec_enable_brute;
69181 +extern int grsec_lock;
69182 +
69183 +extern spinlock_t grsec_alert_lock;
69184 +extern unsigned long grsec_alert_wtime;
69185 +extern unsigned long grsec_alert_fyet;
69186 +
69187 +extern spinlock_t grsec_audit_lock;
69188 +
69189 +extern rwlock_t grsec_exec_file_lock;
69190 +
69191 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69192 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69193 + (tsk)->exec_file->f_vfsmnt) : "/")
69194 +
69195 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69196 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69197 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69198 +
69199 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69200 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69201 + (tsk)->exec_file->f_vfsmnt) : "/")
69202 +
69203 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69204 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69205 + (tsk)->real_parent->exec_file->f_vfsmnt) : "/")
69206 +
69207 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69208 +
69209 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69210 +
69211 +#define GR_CHROOT_CAPS {{ \
69212 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69213 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69214 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69215 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69216 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69217 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69218 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69219 +
69220 +#define security_learn(normal_msg,args...) \
69221 +({ \
69222 + read_lock(&grsec_exec_file_lock); \
69223 + gr_add_learn_entry(normal_msg "\n", ## args); \
69224 + read_unlock(&grsec_exec_file_lock); \
69225 +})
69226 +
69227 +enum {
69228 + GR_DO_AUDIT,
69229 + GR_DONT_AUDIT,
69230 + /* used for non-audit messages that we shouldn't kill the task on */
69231 + GR_DONT_AUDIT_GOOD
69232 +};
69233 +
69234 +enum {
69235 + GR_TTYSNIFF,
69236 + GR_RBAC,
69237 + GR_RBAC_STR,
69238 + GR_STR_RBAC,
69239 + GR_RBAC_MODE2,
69240 + GR_RBAC_MODE3,
69241 + GR_FILENAME,
69242 + GR_SYSCTL_HIDDEN,
69243 + GR_NOARGS,
69244 + GR_ONE_INT,
69245 + GR_ONE_INT_TWO_STR,
69246 + GR_ONE_STR,
69247 + GR_STR_INT,
69248 + GR_TWO_STR_INT,
69249 + GR_TWO_INT,
69250 + GR_TWO_U64,
69251 + GR_THREE_INT,
69252 + GR_FIVE_INT_TWO_STR,
69253 + GR_TWO_STR,
69254 + GR_THREE_STR,
69255 + GR_FOUR_STR,
69256 + GR_STR_FILENAME,
69257 + GR_FILENAME_STR,
69258 + GR_FILENAME_TWO_INT,
69259 + GR_FILENAME_TWO_INT_STR,
69260 + GR_TEXTREL,
69261 + GR_PTRACE,
69262 + GR_RESOURCE,
69263 + GR_CAP,
69264 + GR_SIG,
69265 + GR_SIG2,
69266 + GR_CRASH1,
69267 + GR_CRASH2,
69268 + GR_PSACCT,
69269 + GR_RWXMAP
69270 +};
69271 +
69272 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69273 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69274 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69275 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69276 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69277 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69278 +#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)
69279 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69280 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69281 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69282 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69283 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69284 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69285 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69286 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69287 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69288 +#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)
69289 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69290 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69291 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69292 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69293 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69294 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69295 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69296 +#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)
69297 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69298 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69299 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69300 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69301 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69302 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69303 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69304 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69305 +#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)
69306 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69307 +
69308 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69309 +
69310 +#endif
69311 +
69312 +#endif
69313 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69314 new file mode 100644
69315 index 0000000..2bd4c8d
69316 --- /dev/null
69317 +++ b/include/linux/grmsg.h
69318 @@ -0,0 +1,111 @@
69319 +#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"
69320 +#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"
69321 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69322 +#define GR_STOPMOD_MSG "denied modification of module state by "
69323 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69324 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69325 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69326 +#define GR_IOPL_MSG "denied use of iopl() by "
69327 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69328 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69329 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69330 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69331 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69332 +#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"
69333 +#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"
69334 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69335 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69336 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69337 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69338 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69339 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69340 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69341 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69342 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69343 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69344 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69345 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69346 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69347 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69348 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69349 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69350 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69351 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69352 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69353 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69354 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69355 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69356 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69357 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69358 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69359 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69360 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69361 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69362 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69363 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69364 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69365 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69366 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69367 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69368 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69369 +#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"
69370 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69371 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69372 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69373 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69374 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69375 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69376 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69377 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69378 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69379 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69380 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69381 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69382 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69383 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69384 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69385 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69386 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69387 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69388 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69389 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69390 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69391 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69392 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69393 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69394 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69395 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69396 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69397 +#define GR_TIME_MSG "time set by "
69398 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69399 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69400 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69401 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69402 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69403 +#define GR_BIND_MSG "denied bind() by "
69404 +#define GR_CONNECT_MSG "denied connect() by "
69405 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69406 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69407 +#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"
69408 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69409 +#define GR_CAP_ACL_MSG "use of %s denied for "
69410 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69411 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69412 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69413 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69414 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69415 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69416 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69417 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69418 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69419 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69420 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69421 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69422 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69423 +#define GR_VM86_MSG "denied use of vm86 by "
69424 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69425 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69426 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69427 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69428 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69429 +#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 "
69430 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69431 new file mode 100644
69432 index 0000000..8da63a4
69433 --- /dev/null
69434 +++ b/include/linux/grsecurity.h
69435 @@ -0,0 +1,242 @@
69436 +#ifndef GR_SECURITY_H
69437 +#define GR_SECURITY_H
69438 +#include <linux/fs.h>
69439 +#include <linux/fs_struct.h>
69440 +#include <linux/binfmts.h>
69441 +#include <linux/gracl.h>
69442 +
69443 +/* notify of brain-dead configs */
69444 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69445 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69446 +#endif
69447 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69448 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69449 +#endif
69450 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69451 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69452 +#endif
69453 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69454 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69455 +#endif
69456 +
69457 +void gr_handle_brute_attach(unsigned long mm_flags);
69458 +void gr_handle_brute_check(void);
69459 +void gr_handle_kernel_exploit(void);
69460 +int gr_process_user_ban(void);
69461 +
69462 +char gr_roletype_to_char(void);
69463 +
69464 +int gr_acl_enable_at_secure(void);
69465 +
69466 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69467 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69468 +
69469 +void gr_del_task_from_ip_table(struct task_struct *p);
69470 +
69471 +int gr_pid_is_chrooted(struct task_struct *p);
69472 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69473 +int gr_handle_chroot_nice(void);
69474 +int gr_handle_chroot_sysctl(const int op);
69475 +int gr_handle_chroot_setpriority(struct task_struct *p,
69476 + const int niceval);
69477 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69478 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69479 + const struct vfsmount *mnt);
69480 +void gr_handle_chroot_chdir(struct path *path);
69481 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69482 + const struct vfsmount *mnt, const int mode);
69483 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69484 + const struct vfsmount *mnt, const int mode);
69485 +int gr_handle_chroot_mount(const struct dentry *dentry,
69486 + const struct vfsmount *mnt,
69487 + const char *dev_name);
69488 +int gr_handle_chroot_pivot(void);
69489 +int gr_handle_chroot_unix(const pid_t pid);
69490 +
69491 +int gr_handle_rawio(const struct inode *inode);
69492 +
69493 +void gr_handle_ioperm(void);
69494 +void gr_handle_iopl(void);
69495 +
69496 +umode_t gr_acl_umask(void);
69497 +
69498 +int gr_tpe_allow(const struct file *file);
69499 +
69500 +void gr_set_chroot_entries(struct task_struct *task, struct path *path);
69501 +void gr_clear_chroot_entries(struct task_struct *task);
69502 +
69503 +void gr_log_forkfail(const int retval);
69504 +void gr_log_timechange(void);
69505 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69506 +void gr_log_chdir(const struct dentry *dentry,
69507 + const struct vfsmount *mnt);
69508 +void gr_log_chroot_exec(const struct dentry *dentry,
69509 + const struct vfsmount *mnt);
69510 +void gr_log_remount(const char *devname, const int retval);
69511 +void gr_log_unmount(const char *devname, const int retval);
69512 +void gr_log_mount(const char *from, const char *to, const int retval);
69513 +void gr_log_textrel(struct vm_area_struct *vma);
69514 +void gr_log_rwxmmap(struct file *file);
69515 +void gr_log_rwxmprotect(struct file *file);
69516 +
69517 +int gr_handle_follow_link(const struct inode *parent,
69518 + const struct inode *inode,
69519 + const struct dentry *dentry,
69520 + const struct vfsmount *mnt);
69521 +int gr_handle_fifo(const struct dentry *dentry,
69522 + const struct vfsmount *mnt,
69523 + const struct dentry *dir, const int flag,
69524 + const int acc_mode);
69525 +int gr_handle_hardlink(const struct dentry *dentry,
69526 + const struct vfsmount *mnt,
69527 + struct inode *inode,
69528 + const int mode, const struct filename *to);
69529 +
69530 +int gr_is_capable(const int cap);
69531 +int gr_is_capable_nolog(const int cap);
69532 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69533 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69534 +
69535 +void gr_copy_label(struct task_struct *tsk);
69536 +void gr_handle_crash(struct task_struct *task, const int sig);
69537 +int gr_handle_signal(const struct task_struct *p, const int sig);
69538 +int gr_check_crash_uid(const kuid_t uid);
69539 +int gr_check_protected_task(const struct task_struct *task);
69540 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69541 +int gr_acl_handle_mmap(const struct file *file,
69542 + const unsigned long prot);
69543 +int gr_acl_handle_mprotect(const struct file *file,
69544 + const unsigned long prot);
69545 +int gr_check_hidden_task(const struct task_struct *tsk);
69546 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69547 + const struct vfsmount *mnt);
69548 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69549 + const struct vfsmount *mnt);
69550 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69551 + const struct vfsmount *mnt, const int fmode);
69552 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69553 + const struct vfsmount *mnt, umode_t *mode);
69554 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69555 + const struct vfsmount *mnt);
69556 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69557 + const struct vfsmount *mnt);
69558 +int gr_handle_ptrace(struct task_struct *task, const long request);
69559 +int gr_handle_proc_ptrace(struct task_struct *task);
69560 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69561 + const struct vfsmount *mnt);
69562 +int gr_check_crash_exec(const struct file *filp);
69563 +int gr_acl_is_enabled(void);
69564 +void gr_set_kernel_label(struct task_struct *task);
69565 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69566 + const kgid_t gid);
69567 +int gr_set_proc_label(const struct dentry *dentry,
69568 + const struct vfsmount *mnt,
69569 + const int unsafe_flags);
69570 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69571 + const struct vfsmount *mnt);
69572 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69573 + const struct vfsmount *mnt, int acc_mode);
69574 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69575 + const struct dentry *p_dentry,
69576 + const struct vfsmount *p_mnt,
69577 + int open_flags, int acc_mode, const int imode);
69578 +void gr_handle_create(const struct dentry *dentry,
69579 + const struct vfsmount *mnt);
69580 +void gr_handle_proc_create(const struct dentry *dentry,
69581 + const struct inode *inode);
69582 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69583 + const struct dentry *parent_dentry,
69584 + const struct vfsmount *parent_mnt,
69585 + const int mode);
69586 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69587 + const struct dentry *parent_dentry,
69588 + const struct vfsmount *parent_mnt);
69589 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69590 + const struct vfsmount *mnt);
69591 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69592 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69593 + const struct vfsmount *mnt);
69594 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69595 + const struct dentry *parent_dentry,
69596 + const struct vfsmount *parent_mnt,
69597 + const struct filename *from);
69598 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69599 + const struct dentry *parent_dentry,
69600 + const struct vfsmount *parent_mnt,
69601 + const struct dentry *old_dentry,
69602 + const struct vfsmount *old_mnt, const struct filename *to);
69603 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69604 +int gr_acl_handle_rename(struct dentry *new_dentry,
69605 + struct dentry *parent_dentry,
69606 + const struct vfsmount *parent_mnt,
69607 + struct dentry *old_dentry,
69608 + struct inode *old_parent_inode,
69609 + struct vfsmount *old_mnt, const struct filename *newname);
69610 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69611 + struct dentry *old_dentry,
69612 + struct dentry *new_dentry,
69613 + struct vfsmount *mnt, const __u8 replace);
69614 +__u32 gr_check_link(const struct dentry *new_dentry,
69615 + const struct dentry *parent_dentry,
69616 + const struct vfsmount *parent_mnt,
69617 + const struct dentry *old_dentry,
69618 + const struct vfsmount *old_mnt);
69619 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69620 + const unsigned int namelen, const ino_t ino);
69621 +
69622 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69623 + const struct vfsmount *mnt);
69624 +void gr_acl_handle_exit(void);
69625 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69626 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69627 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69628 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69629 +void gr_audit_ptrace(struct task_struct *task);
69630 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69631 +void gr_put_exec_file(struct task_struct *task);
69632 +
69633 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69634 +
69635 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69636 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69637 + const unsigned long wanted, const int gt);
69638 +#else
69639 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69640 + const unsigned long wanted, const int gt)
69641 +{
69642 +}
69643 +#endif
69644 +
69645 +#ifdef CONFIG_GRKERNSEC_RESLOG
69646 +extern void gr_log_resource(const struct task_struct *task, const int res,
69647 + const unsigned long wanted, const int gt);
69648 +#else
69649 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69650 + const unsigned long wanted, const int gt)
69651 +{
69652 +}
69653 +#endif
69654 +
69655 +#ifdef CONFIG_GRKERNSEC
69656 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69657 +void gr_handle_vm86(void);
69658 +void gr_handle_mem_readwrite(u64 from, u64 to);
69659 +
69660 +void gr_log_badprocpid(const char *entry);
69661 +
69662 +extern int grsec_enable_dmesg;
69663 +extern int grsec_disable_privio;
69664 +
69665 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69666 +extern kgid_t grsec_proc_gid;
69667 +#endif
69668 +
69669 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69670 +extern int grsec_enable_chroot_findtask;
69671 +#endif
69672 +#ifdef CONFIG_GRKERNSEC_SETXID
69673 +extern int grsec_enable_setxid;
69674 +#endif
69675 +#endif
69676 +
69677 +#endif
69678 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69679 new file mode 100644
69680 index 0000000..e7ffaaf
69681 --- /dev/null
69682 +++ b/include/linux/grsock.h
69683 @@ -0,0 +1,19 @@
69684 +#ifndef __GRSOCK_H
69685 +#define __GRSOCK_H
69686 +
69687 +extern void gr_attach_curr_ip(const struct sock *sk);
69688 +extern int gr_handle_sock_all(const int family, const int type,
69689 + const int protocol);
69690 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69691 +extern int gr_handle_sock_server_other(const struct sock *sck);
69692 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69693 +extern int gr_search_connect(struct socket * sock,
69694 + struct sockaddr_in * addr);
69695 +extern int gr_search_bind(struct socket * sock,
69696 + struct sockaddr_in * addr);
69697 +extern int gr_search_listen(struct socket * sock);
69698 +extern int gr_search_accept(struct socket * sock);
69699 +extern int gr_search_socket(const int domain, const int type,
69700 + const int protocol);
69701 +
69702 +#endif
69703 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69704 index ef788b5..ac41b7b 100644
69705 --- a/include/linux/highmem.h
69706 +++ b/include/linux/highmem.h
69707 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69708 kunmap_atomic(kaddr);
69709 }
69710
69711 +static inline void sanitize_highpage(struct page *page)
69712 +{
69713 + void *kaddr;
69714 + unsigned long flags;
69715 +
69716 + local_irq_save(flags);
69717 + kaddr = kmap_atomic(page);
69718 + clear_page(kaddr);
69719 + kunmap_atomic(kaddr);
69720 + local_irq_restore(flags);
69721 +}
69722 +
69723 static inline void zero_user_segments(struct page *page,
69724 unsigned start1, unsigned end1,
69725 unsigned start2, unsigned end2)
69726 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69727 index 1c7b89a..7f52502 100644
69728 --- a/include/linux/hwmon-sysfs.h
69729 +++ b/include/linux/hwmon-sysfs.h
69730 @@ -25,7 +25,8 @@
69731 struct sensor_device_attribute{
69732 struct device_attribute dev_attr;
69733 int index;
69734 -};
69735 +} __do_const;
69736 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69737 #define to_sensor_dev_attr(_dev_attr) \
69738 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69739
69740 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69741 struct device_attribute dev_attr;
69742 u8 index;
69743 u8 nr;
69744 -};
69745 +} __do_const;
69746 #define to_sensor_dev_attr_2(_dev_attr) \
69747 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69748
69749 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69750 index d0c4db7..61b3577 100644
69751 --- a/include/linux/i2c.h
69752 +++ b/include/linux/i2c.h
69753 @@ -369,6 +369,7 @@ struct i2c_algorithm {
69754 /* To determine what the adapter supports */
69755 u32 (*functionality) (struct i2c_adapter *);
69756 };
69757 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69758
69759 /*
69760 * i2c_adapter is the structure used to identify a physical i2c bus along
69761 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69762 index d23c3c2..eb63c81 100644
69763 --- a/include/linux/i2o.h
69764 +++ b/include/linux/i2o.h
69765 @@ -565,7 +565,7 @@ struct i2o_controller {
69766 struct i2o_device *exec; /* Executive */
69767 #if BITS_PER_LONG == 64
69768 spinlock_t context_list_lock; /* lock for context_list */
69769 - atomic_t context_list_counter; /* needed for unique contexts */
69770 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69771 struct list_head context_list; /* list of context id's
69772 and pointers */
69773 #endif
69774 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69775 index aff7ad8..3942bbd 100644
69776 --- a/include/linux/if_pppox.h
69777 +++ b/include/linux/if_pppox.h
69778 @@ -76,7 +76,7 @@ struct pppox_proto {
69779 int (*ioctl)(struct socket *sock, unsigned int cmd,
69780 unsigned long arg);
69781 struct module *owner;
69782 -};
69783 +} __do_const;
69784
69785 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69786 extern void unregister_pppox_proto(int proto_num);
69787 diff --git a/include/linux/init.h b/include/linux/init.h
69788 index 10ed4f4..8e8490d 100644
69789 --- a/include/linux/init.h
69790 +++ b/include/linux/init.h
69791 @@ -39,9 +39,36 @@
69792 * Also note, that this data cannot be "const".
69793 */
69794
69795 +#ifdef MODULE
69796 +#define add_init_latent_entropy
69797 +#define add_devinit_latent_entropy
69798 +#define add_cpuinit_latent_entropy
69799 +#define add_meminit_latent_entropy
69800 +#else
69801 +#define add_init_latent_entropy __latent_entropy
69802 +
69803 +#ifdef CONFIG_HOTPLUG
69804 +#define add_devinit_latent_entropy
69805 +#else
69806 +#define add_devinit_latent_entropy __latent_entropy
69807 +#endif
69808 +
69809 +#ifdef CONFIG_HOTPLUG_CPU
69810 +#define add_cpuinit_latent_entropy
69811 +#else
69812 +#define add_cpuinit_latent_entropy __latent_entropy
69813 +#endif
69814 +
69815 +#ifdef CONFIG_MEMORY_HOTPLUG
69816 +#define add_meminit_latent_entropy
69817 +#else
69818 +#define add_meminit_latent_entropy __latent_entropy
69819 +#endif
69820 +#endif
69821 +
69822 /* These are for everybody (although not all archs will actually
69823 discard it in modules) */
69824 -#define __init __section(.init.text) __cold notrace
69825 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69826 #define __initdata __section(.init.data)
69827 #define __initconst __constsection(.init.rodata)
69828 #define __exitdata __section(.exit.data)
69829 @@ -94,7 +121,7 @@
69830 #define __exit __section(.exit.text) __exitused __cold notrace
69831
69832 /* Used for HOTPLUG_CPU */
69833 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69834 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69835 #define __cpuinitdata __section(.cpuinit.data)
69836 #define __cpuinitconst __constsection(.cpuinit.rodata)
69837 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69838 @@ -102,7 +129,7 @@
69839 #define __cpuexitconst __constsection(.cpuexit.rodata)
69840
69841 /* Used for MEMORY_HOTPLUG */
69842 -#define __meminit __section(.meminit.text) __cold notrace
69843 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69844 #define __meminitdata __section(.meminit.data)
69845 #define __meminitconst __constsection(.meminit.rodata)
69846 #define __memexit __section(.memexit.text) __exitused __cold notrace
69847 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69848 index 6d087c5..401cab8 100644
69849 --- a/include/linux/init_task.h
69850 +++ b/include/linux/init_task.h
69851 @@ -143,6 +143,12 @@ extern struct task_group root_task_group;
69852
69853 #define INIT_TASK_COMM "swapper"
69854
69855 +#ifdef CONFIG_X86
69856 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69857 +#else
69858 +#define INIT_TASK_THREAD_INFO
69859 +#endif
69860 +
69861 /*
69862 * INIT_TASK is used to set up the first task table, touch at
69863 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69864 @@ -182,6 +188,7 @@ extern struct task_group root_task_group;
69865 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69866 .comm = INIT_TASK_COMM, \
69867 .thread = INIT_THREAD, \
69868 + INIT_TASK_THREAD_INFO \
69869 .fs = &init_fs, \
69870 .files = &init_files, \
69871 .signal = &init_signals, \
69872 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69873 index 5fa5afe..ac55b25 100644
69874 --- a/include/linux/interrupt.h
69875 +++ b/include/linux/interrupt.h
69876 @@ -430,7 +430,7 @@ enum
69877 /* map softirq index to softirq name. update 'softirq_to_name' in
69878 * kernel/softirq.c when adding a new softirq.
69879 */
69880 -extern char *softirq_to_name[NR_SOFTIRQS];
69881 +extern const char * const softirq_to_name[NR_SOFTIRQS];
69882
69883 /* softirq mask and active fields moved to irq_cpustat_t in
69884 * asm/hardirq.h to get better cache usage. KAO
69885 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
69886
69887 struct softirq_action
69888 {
69889 - void (*action)(struct softirq_action *);
69890 -};
69891 + void (*action)(void);
69892 +} __no_const;
69893
69894 asmlinkage void do_softirq(void);
69895 asmlinkage void __do_softirq(void);
69896 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
69897 +extern void open_softirq(int nr, void (*action)(void));
69898 extern void softirq_init(void);
69899 extern void __raise_softirq_irqoff(unsigned int nr);
69900
69901 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
69902 index f3b99e1..9b73cee 100644
69903 --- a/include/linux/iommu.h
69904 +++ b/include/linux/iommu.h
69905 @@ -101,7 +101,7 @@ struct iommu_ops {
69906 int (*domain_set_attr)(struct iommu_domain *domain,
69907 enum iommu_attr attr, void *data);
69908 unsigned long pgsize_bitmap;
69909 -};
69910 +} __do_const;
69911
69912 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
69913 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
69914 diff --git a/include/linux/irq.h b/include/linux/irq.h
69915 index fdf2c4a..5332486 100644
69916 --- a/include/linux/irq.h
69917 +++ b/include/linux/irq.h
69918 @@ -328,7 +328,8 @@ struct irq_chip {
69919 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
69920
69921 unsigned long flags;
69922 -};
69923 +} __do_const;
69924 +typedef struct irq_chip __no_const irq_chip_no_const;
69925
69926 /*
69927 * irq_chip specific flags
69928 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
69929 index 6883e19..06992b1 100644
69930 --- a/include/linux/kallsyms.h
69931 +++ b/include/linux/kallsyms.h
69932 @@ -15,7 +15,8 @@
69933
69934 struct module;
69935
69936 -#ifdef CONFIG_KALLSYMS
69937 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
69938 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
69939 /* Lookup the address for a symbol. Returns 0 if not found. */
69940 unsigned long kallsyms_lookup_name(const char *name);
69941
69942 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
69943 /* Stupid that this does nothing, but I didn't create this mess. */
69944 #define __print_symbol(fmt, addr)
69945 #endif /*CONFIG_KALLSYMS*/
69946 +#else /* when included by kallsyms.c, vsnprintf.c, or
69947 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
69948 +extern void __print_symbol(const char *fmt, unsigned long address);
69949 +extern int sprint_backtrace(char *buffer, unsigned long address);
69950 +extern int sprint_symbol(char *buffer, unsigned long address);
69951 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
69952 +const char *kallsyms_lookup(unsigned long addr,
69953 + unsigned long *symbolsize,
69954 + unsigned long *offset,
69955 + char **modname, char *namebuf);
69956 +#endif
69957
69958 /* This macro allows us to keep printk typechecking */
69959 static __printf(1, 2)
69960 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
69961 index 518a53a..5e28358 100644
69962 --- a/include/linux/key-type.h
69963 +++ b/include/linux/key-type.h
69964 @@ -125,7 +125,7 @@ struct key_type {
69965 /* internal fields */
69966 struct list_head link; /* link in types list */
69967 struct lock_class_key lock_class; /* key->sem lock class */
69968 -};
69969 +} __do_const;
69970
69971 extern struct key_type key_type_keyring;
69972
69973 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
69974 index 4dff0c6..1ca9b72 100644
69975 --- a/include/linux/kgdb.h
69976 +++ b/include/linux/kgdb.h
69977 @@ -53,7 +53,7 @@ extern int kgdb_connected;
69978 extern int kgdb_io_module_registered;
69979
69980 extern atomic_t kgdb_setting_breakpoint;
69981 -extern atomic_t kgdb_cpu_doing_single_step;
69982 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
69983
69984 extern struct task_struct *kgdb_usethread;
69985 extern struct task_struct *kgdb_contthread;
69986 @@ -255,7 +255,7 @@ struct kgdb_arch {
69987 void (*correct_hw_break)(void);
69988
69989 void (*enable_nmi)(bool on);
69990 -};
69991 +} __do_const;
69992
69993 /**
69994 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
69995 @@ -280,7 +280,7 @@ struct kgdb_io {
69996 void (*pre_exception) (void);
69997 void (*post_exception) (void);
69998 int is_console;
69999 -};
70000 +} __do_const;
70001
70002 extern struct kgdb_arch arch_kgdb_ops;
70003
70004 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70005 index 5398d58..5883a34 100644
70006 --- a/include/linux/kmod.h
70007 +++ b/include/linux/kmod.h
70008 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70009 * usually useless though. */
70010 extern __printf(2, 3)
70011 int __request_module(bool wait, const char *name, ...);
70012 +extern __printf(3, 4)
70013 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70014 #define request_module(mod...) __request_module(true, mod)
70015 #define request_module_nowait(mod...) __request_module(false, mod)
70016 #define try_then_request_module(x, mod...) \
70017 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70018 index 939b112..ed6ed51 100644
70019 --- a/include/linux/kobject.h
70020 +++ b/include/linux/kobject.h
70021 @@ -111,7 +111,7 @@ struct kobj_type {
70022 struct attribute **default_attrs;
70023 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70024 const void *(*namespace)(struct kobject *kobj);
70025 -};
70026 +} __do_const;
70027
70028 struct kobj_uevent_env {
70029 char *envp[UEVENT_NUM_ENVP];
70030 @@ -134,6 +134,7 @@ struct kobj_attribute {
70031 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70032 const char *buf, size_t count);
70033 };
70034 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70035
70036 extern const struct sysfs_ops kobj_sysfs_ops;
70037
70038 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70039 index f66b065..c2c29b4 100644
70040 --- a/include/linux/kobject_ns.h
70041 +++ b/include/linux/kobject_ns.h
70042 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70043 const void *(*netlink_ns)(struct sock *sk);
70044 const void *(*initial_ns)(void);
70045 void (*drop_ns)(void *);
70046 -};
70047 +} __do_const;
70048
70049 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70050 int kobj_ns_type_registered(enum kobj_ns_type type);
70051 diff --git a/include/linux/kref.h b/include/linux/kref.h
70052 index 4972e6e..de4d19b 100644
70053 --- a/include/linux/kref.h
70054 +++ b/include/linux/kref.h
70055 @@ -64,7 +64,7 @@ static inline void kref_get(struct kref *kref)
70056 static inline int kref_sub(struct kref *kref, unsigned int count,
70057 void (*release)(struct kref *kref))
70058 {
70059 - WARN_ON(release == NULL);
70060 + BUG_ON(release == NULL);
70061
70062 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70063 release(kref);
70064 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70065 index 2c497ab..afe32f5 100644
70066 --- a/include/linux/kvm_host.h
70067 +++ b/include/linux/kvm_host.h
70068 @@ -418,7 +418,7 @@ void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
70069 int __must_check vcpu_load(struct kvm_vcpu *vcpu);
70070 void vcpu_put(struct kvm_vcpu *vcpu);
70071
70072 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70073 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70074 struct module *module);
70075 void kvm_exit(void);
70076
70077 @@ -574,7 +574,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70078 struct kvm_guest_debug *dbg);
70079 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70080
70081 -int kvm_arch_init(void *opaque);
70082 +int kvm_arch_init(const void *opaque);
70083 void kvm_arch_exit(void);
70084
70085 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70086 diff --git a/include/linux/libata.h b/include/linux/libata.h
70087 index 0621bca..24d6851 100644
70088 --- a/include/linux/libata.h
70089 +++ b/include/linux/libata.h
70090 @@ -916,7 +916,7 @@ struct ata_port_operations {
70091 * fields must be pointers.
70092 */
70093 const struct ata_port_operations *inherits;
70094 -};
70095 +} __do_const;
70096
70097 struct ata_port_info {
70098 unsigned long flags;
70099 diff --git a/include/linux/list.h b/include/linux/list.h
70100 index cc6d2aa..c10ee83 100644
70101 --- a/include/linux/list.h
70102 +++ b/include/linux/list.h
70103 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70104 extern void list_del(struct list_head *entry);
70105 #endif
70106
70107 +extern void __pax_list_add(struct list_head *new,
70108 + struct list_head *prev,
70109 + struct list_head *next);
70110 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70111 +{
70112 + __pax_list_add(new, head, head->next);
70113 +}
70114 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70115 +{
70116 + __pax_list_add(new, head->prev, head);
70117 +}
70118 +extern void pax_list_del(struct list_head *entry);
70119 +
70120 /**
70121 * list_replace - replace old entry by new one
70122 * @old : the element to be replaced
70123 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70124 INIT_LIST_HEAD(entry);
70125 }
70126
70127 +extern void pax_list_del_init(struct list_head *entry);
70128 +
70129 /**
70130 * list_move - delete from one list and add as another's head
70131 * @list: the entry to move
70132 diff --git a/include/linux/math64.h b/include/linux/math64.h
70133 index b8ba855..0148090 100644
70134 --- a/include/linux/math64.h
70135 +++ b/include/linux/math64.h
70136 @@ -14,7 +14,7 @@
70137 * This is commonly provided by 32bit archs to provide an optimized 64bit
70138 * divide.
70139 */
70140 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70141 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70142 {
70143 *remainder = dividend % divisor;
70144 return dividend / divisor;
70145 @@ -50,7 +50,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70146 #define div64_long(x,y) div_s64((x),(y))
70147
70148 #ifndef div_u64_rem
70149 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70150 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70151 {
70152 *remainder = do_div(dividend, divisor);
70153 return dividend;
70154 @@ -79,7 +79,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70155 * divide.
70156 */
70157 #ifndef div_u64
70158 -static inline u64 div_u64(u64 dividend, u32 divisor)
70159 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70160 {
70161 u32 remainder;
70162 return div_u64_rem(dividend, divisor, &remainder);
70163 diff --git a/include/linux/mm.h b/include/linux/mm.h
70164 index 66e2f7c..b916b9a 100644
70165 --- a/include/linux/mm.h
70166 +++ b/include/linux/mm.h
70167 @@ -101,6 +101,11 @@ extern unsigned int kobjsize(const void *objp);
70168 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70169 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70170 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70171 +
70172 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70173 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70174 +#endif
70175 +
70176 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70177
70178 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70179 @@ -200,8 +205,8 @@ struct vm_operations_struct {
70180 /* called by access_process_vm when get_user_pages() fails, typically
70181 * for use by special VMAs that can switch between memory and hardware
70182 */
70183 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70184 - void *buf, int len, int write);
70185 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70186 + void *buf, size_t len, int write);
70187 #ifdef CONFIG_NUMA
70188 /*
70189 * set_policy() op must add a reference to any non-NULL @new mempolicy
70190 @@ -231,6 +236,7 @@ struct vm_operations_struct {
70191 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70192 unsigned long size, pgoff_t pgoff);
70193 };
70194 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70195
70196 struct mmu_gather;
70197 struct inode;
70198 @@ -995,8 +1001,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70199 unsigned long *pfn);
70200 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70201 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70202 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70203 - void *buf, int len, int write);
70204 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70205 + void *buf, size_t len, int write);
70206
70207 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70208 loff_t const holebegin, loff_t const holelen)
70209 @@ -1035,10 +1041,10 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70210 }
70211 #endif
70212
70213 -extern int make_pages_present(unsigned long addr, unsigned long end);
70214 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70215 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70216 - void *buf, int len, int write);
70217 +extern ssize_t make_pages_present(unsigned long addr, unsigned long end);
70218 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70219 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70220 + void *buf, size_t len, int write);
70221
70222 int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70223 unsigned long start, int len, unsigned int foll_flags,
70224 @@ -1068,34 +1074,6 @@ int set_page_dirty(struct page *page);
70225 int set_page_dirty_lock(struct page *page);
70226 int clear_page_dirty_for_io(struct page *page);
70227
70228 -/* Is the vma a continuation of the stack vma above it? */
70229 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70230 -{
70231 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70232 -}
70233 -
70234 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70235 - unsigned long addr)
70236 -{
70237 - return (vma->vm_flags & VM_GROWSDOWN) &&
70238 - (vma->vm_start == addr) &&
70239 - !vma_growsdown(vma->vm_prev, addr);
70240 -}
70241 -
70242 -/* Is the vma a continuation of the stack vma below it? */
70243 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70244 -{
70245 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70246 -}
70247 -
70248 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70249 - unsigned long addr)
70250 -{
70251 - return (vma->vm_flags & VM_GROWSUP) &&
70252 - (vma->vm_end == addr) &&
70253 - !vma_growsup(vma->vm_next, addr);
70254 -}
70255 -
70256 extern pid_t
70257 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70258
70259 @@ -1198,6 +1176,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70260 }
70261 #endif
70262
70263 +#ifdef CONFIG_MMU
70264 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70265 +#else
70266 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70267 +{
70268 + return __pgprot(0);
70269 +}
70270 +#endif
70271 +
70272 int vma_wants_writenotify(struct vm_area_struct *vma);
70273
70274 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70275 @@ -1216,8 +1203,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70276 {
70277 return 0;
70278 }
70279 +
70280 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70281 + unsigned long address)
70282 +{
70283 + return 0;
70284 +}
70285 #else
70286 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70287 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70288 #endif
70289
70290 #ifdef __PAGETABLE_PMD_FOLDED
70291 @@ -1226,8 +1220,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70292 {
70293 return 0;
70294 }
70295 +
70296 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70297 + unsigned long address)
70298 +{
70299 + return 0;
70300 +}
70301 #else
70302 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70303 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70304 #endif
70305
70306 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70307 @@ -1245,11 +1246,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70308 NULL: pud_offset(pgd, address);
70309 }
70310
70311 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70312 +{
70313 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70314 + NULL: pud_offset(pgd, address);
70315 +}
70316 +
70317 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70318 {
70319 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70320 NULL: pmd_offset(pud, address);
70321 }
70322 +
70323 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70324 +{
70325 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70326 + NULL: pmd_offset(pud, address);
70327 +}
70328 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70329
70330 #if USE_SPLIT_PTLOCKS
70331 @@ -1479,6 +1492,7 @@ extern unsigned long do_mmap_pgoff(struct file *, unsigned long,
70332 unsigned long, unsigned long,
70333 unsigned long, unsigned long);
70334 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70335 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70336
70337 /* These take the mm semaphore themselves */
70338 extern unsigned long vm_brk(unsigned long, unsigned long);
70339 @@ -1573,6 +1587,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70340 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70341 struct vm_area_struct **pprev);
70342
70343 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70344 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70345 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70346 +
70347 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70348 NULL if none. Assume start_addr < end_addr. */
70349 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70350 @@ -1601,15 +1619,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70351 return vma;
70352 }
70353
70354 -#ifdef CONFIG_MMU
70355 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70356 -#else
70357 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70358 -{
70359 - return __pgprot(0);
70360 -}
70361 -#endif
70362 -
70363 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70364 unsigned long change_prot_numa(struct vm_area_struct *vma,
70365 unsigned long start, unsigned long end);
70366 @@ -1649,6 +1658,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70367 static inline void vm_stat_account(struct mm_struct *mm,
70368 unsigned long flags, struct file *file, long pages)
70369 {
70370 +
70371 +#ifdef CONFIG_PAX_RANDMMAP
70372 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70373 +#endif
70374 +
70375 mm->total_vm += pages;
70376 }
70377 #endif /* CONFIG_PROC_FS */
70378 @@ -1721,7 +1735,7 @@ extern int unpoison_memory(unsigned long pfn);
70379 extern int sysctl_memory_failure_early_kill;
70380 extern int sysctl_memory_failure_recovery;
70381 extern void shake_page(struct page *p, int access);
70382 -extern atomic_long_t mce_bad_pages;
70383 +extern atomic_long_unchecked_t mce_bad_pages;
70384 extern int soft_offline_page(struct page *page, int flags);
70385
70386 extern void dump_page(struct page *page);
70387 @@ -1752,5 +1766,11 @@ static inline unsigned int debug_guardpage_minorder(void) { return 0; }
70388 static inline bool page_is_guard(struct page *page) { return false; }
70389 #endif /* CONFIG_DEBUG_PAGEALLOC */
70390
70391 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70392 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70393 +#else
70394 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70395 +#endif
70396 +
70397 #endif /* __KERNEL__ */
70398 #endif /* _LINUX_MM_H */
70399 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70400 index f8f5162..3aaf20f 100644
70401 --- a/include/linux/mm_types.h
70402 +++ b/include/linux/mm_types.h
70403 @@ -288,6 +288,8 @@ struct vm_area_struct {
70404 #ifdef CONFIG_NUMA
70405 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70406 #endif
70407 +
70408 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70409 };
70410
70411 struct core_thread {
70412 @@ -436,6 +438,24 @@ struct mm_struct {
70413 int first_nid;
70414 #endif
70415 struct uprobes_state uprobes_state;
70416 +
70417 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70418 + unsigned long pax_flags;
70419 +#endif
70420 +
70421 +#ifdef CONFIG_PAX_DLRESOLVE
70422 + unsigned long call_dl_resolve;
70423 +#endif
70424 +
70425 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70426 + unsigned long call_syscall;
70427 +#endif
70428 +
70429 +#ifdef CONFIG_PAX_ASLR
70430 + unsigned long delta_mmap; /* randomized offset */
70431 + unsigned long delta_stack; /* randomized offset */
70432 +#endif
70433 +
70434 };
70435
70436 /* first nid will either be a valid NID or one of these values */
70437 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70438 index c5d5278..f0b68c8 100644
70439 --- a/include/linux/mmiotrace.h
70440 +++ b/include/linux/mmiotrace.h
70441 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70442 /* Called from ioremap.c */
70443 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70444 void __iomem *addr);
70445 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70446 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70447
70448 /* For anyone to insert markers. Remember trailing newline. */
70449 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70450 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70451 {
70452 }
70453
70454 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70455 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70456 {
70457 }
70458
70459 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70460 index 73b64a3..6562925 100644
70461 --- a/include/linux/mmzone.h
70462 +++ b/include/linux/mmzone.h
70463 @@ -412,7 +412,7 @@ struct zone {
70464 unsigned long flags; /* zone flags, see below */
70465
70466 /* Zone statistics */
70467 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70468 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70469
70470 /*
70471 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70472 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70473 index fed3def..c933f99 100644
70474 --- a/include/linux/mod_devicetable.h
70475 +++ b/include/linux/mod_devicetable.h
70476 @@ -12,7 +12,7 @@
70477 typedef unsigned long kernel_ulong_t;
70478 #endif
70479
70480 -#define PCI_ANY_ID (~0)
70481 +#define PCI_ANY_ID ((__u16)~0)
70482
70483 struct pci_device_id {
70484 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70485 @@ -139,7 +139,7 @@ struct usb_device_id {
70486 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70487 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70488
70489 -#define HID_ANY_ID (~0)
70490 +#define HID_ANY_ID (~0U)
70491 #define HID_BUS_ANY 0xffff
70492 #define HID_GROUP_ANY 0x0000
70493
70494 @@ -498,7 +498,7 @@ struct dmi_system_id {
70495 const char *ident;
70496 struct dmi_strmatch matches[4];
70497 void *driver_data;
70498 -};
70499 +} __do_const;
70500 /*
70501 * struct dmi_device_id appears during expansion of
70502 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70503 diff --git a/include/linux/module.h b/include/linux/module.h
70504 index 1375ee3..ced8177 100644
70505 --- a/include/linux/module.h
70506 +++ b/include/linux/module.h
70507 @@ -17,9 +17,11 @@
70508 #include <linux/moduleparam.h>
70509 #include <linux/tracepoint.h>
70510 #include <linux/export.h>
70511 +#include <linux/fs.h>
70512
70513 #include <linux/percpu.h>
70514 #include <asm/module.h>
70515 +#include <asm/pgtable.h>
70516
70517 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70518 #define MODULE_SIG_STRING "~Module signature appended~\n"
70519 @@ -54,12 +56,13 @@ struct module_attribute {
70520 int (*test)(struct module *);
70521 void (*free)(struct module *);
70522 };
70523 +typedef struct module_attribute __no_const module_attribute_no_const;
70524
70525 struct module_version_attribute {
70526 struct module_attribute mattr;
70527 const char *module_name;
70528 const char *version;
70529 -} __attribute__ ((__aligned__(sizeof(void *))));
70530 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70531
70532 extern ssize_t __modver_version_show(struct module_attribute *,
70533 struct module_kobject *, char *);
70534 @@ -232,7 +235,7 @@ struct module
70535
70536 /* Sysfs stuff. */
70537 struct module_kobject mkobj;
70538 - struct module_attribute *modinfo_attrs;
70539 + module_attribute_no_const *modinfo_attrs;
70540 const char *version;
70541 const char *srcversion;
70542 struct kobject *holders_dir;
70543 @@ -281,19 +284,16 @@ struct module
70544 int (*init)(void);
70545
70546 /* If this is non-NULL, vfree after init() returns */
70547 - void *module_init;
70548 + void *module_init_rx, *module_init_rw;
70549
70550 /* Here is the actual code + data, vfree'd on unload. */
70551 - void *module_core;
70552 + void *module_core_rx, *module_core_rw;
70553
70554 /* Here are the sizes of the init and core sections */
70555 - unsigned int init_size, core_size;
70556 + unsigned int init_size_rw, core_size_rw;
70557
70558 /* The size of the executable code in each section. */
70559 - unsigned int init_text_size, core_text_size;
70560 -
70561 - /* Size of RO sections of the module (text+rodata) */
70562 - unsigned int init_ro_size, core_ro_size;
70563 + unsigned int init_size_rx, core_size_rx;
70564
70565 /* Arch-specific module values */
70566 struct mod_arch_specific arch;
70567 @@ -349,6 +349,10 @@ struct module
70568 #ifdef CONFIG_EVENT_TRACING
70569 struct ftrace_event_call **trace_events;
70570 unsigned int num_trace_events;
70571 + struct file_operations trace_id;
70572 + struct file_operations trace_enable;
70573 + struct file_operations trace_format;
70574 + struct file_operations trace_filter;
70575 #endif
70576 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70577 unsigned int num_ftrace_callsites;
70578 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70579 bool is_module_percpu_address(unsigned long addr);
70580 bool is_module_text_address(unsigned long addr);
70581
70582 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70583 +{
70584 +
70585 +#ifdef CONFIG_PAX_KERNEXEC
70586 + if (ktla_ktva(addr) >= (unsigned long)start &&
70587 + ktla_ktva(addr) < (unsigned long)start + size)
70588 + return 1;
70589 +#endif
70590 +
70591 + return ((void *)addr >= start && (void *)addr < start + size);
70592 +}
70593 +
70594 +static inline int within_module_core_rx(unsigned long addr, struct module *mod)
70595 +{
70596 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70597 +}
70598 +
70599 +static inline int within_module_core_rw(unsigned long addr, struct module *mod)
70600 +{
70601 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70602 +}
70603 +
70604 +static inline int within_module_init_rx(unsigned long addr, struct module *mod)
70605 +{
70606 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70607 +}
70608 +
70609 +static inline int within_module_init_rw(unsigned long addr, struct module *mod)
70610 +{
70611 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70612 +}
70613 +
70614 static inline int within_module_core(unsigned long addr, struct module *mod)
70615 {
70616 - return (unsigned long)mod->module_core <= addr &&
70617 - addr < (unsigned long)mod->module_core + mod->core_size;
70618 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70619 }
70620
70621 static inline int within_module_init(unsigned long addr, struct module *mod)
70622 {
70623 - return (unsigned long)mod->module_init <= addr &&
70624 - addr < (unsigned long)mod->module_init + mod->init_size;
70625 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70626 }
70627
70628 /* Search for module by name: must hold module_mutex. */
70629 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70630 index 560ca53..ef621ef 100644
70631 --- a/include/linux/moduleloader.h
70632 +++ b/include/linux/moduleloader.h
70633 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70634 sections. Returns NULL on failure. */
70635 void *module_alloc(unsigned long size);
70636
70637 +#ifdef CONFIG_PAX_KERNEXEC
70638 +void *module_alloc_exec(unsigned long size);
70639 +#else
70640 +#define module_alloc_exec(x) module_alloc(x)
70641 +#endif
70642 +
70643 /* Free memory returned from module_alloc. */
70644 void module_free(struct module *mod, void *module_region);
70645
70646 +#ifdef CONFIG_PAX_KERNEXEC
70647 +void module_free_exec(struct module *mod, void *module_region);
70648 +#else
70649 +#define module_free_exec(x, y) module_free((x), (y))
70650 +#endif
70651 +
70652 /*
70653 * Apply the given relocation to the (simplified) ELF. Return -error
70654 * or 0.
70655 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70656 unsigned int relsec,
70657 struct module *me)
70658 {
70659 +#ifdef CONFIG_MODULES
70660 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70661 +#endif
70662 return -ENOEXEC;
70663 }
70664 #endif
70665 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70666 unsigned int relsec,
70667 struct module *me)
70668 {
70669 +#ifdef CONFIG_MODULES
70670 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70671 +#endif
70672 return -ENOEXEC;
70673 }
70674 #endif
70675 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70676 index 137b419..fe663ec 100644
70677 --- a/include/linux/moduleparam.h
70678 +++ b/include/linux/moduleparam.h
70679 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70680 * @len is usually just sizeof(string).
70681 */
70682 #define module_param_string(name, string, len, perm) \
70683 - static const struct kparam_string __param_string_##name \
70684 + static const struct kparam_string __param_string_##name __used \
70685 = { len, string }; \
70686 __module_param_call(MODULE_PARAM_PREFIX, name, \
70687 &param_ops_string, \
70688 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70689 */
70690 #define module_param_array_named(name, array, type, nump, perm) \
70691 param_check_##type(name, &(array)[0]); \
70692 - static const struct kparam_array __param_arr_##name \
70693 + static const struct kparam_array __param_arr_##name __used \
70694 = { .max = ARRAY_SIZE(array), .num = nump, \
70695 .ops = &param_ops_##type, \
70696 .elemsize = sizeof(array[0]), .elem = array }; \
70697 diff --git a/include/linux/namei.h b/include/linux/namei.h
70698 index 5a5ff57..5ae5070 100644
70699 --- a/include/linux/namei.h
70700 +++ b/include/linux/namei.h
70701 @@ -19,7 +19,7 @@ struct nameidata {
70702 unsigned seq;
70703 int last_type;
70704 unsigned depth;
70705 - char *saved_names[MAX_NESTED_LINKS + 1];
70706 + const char *saved_names[MAX_NESTED_LINKS + 1];
70707 };
70708
70709 /*
70710 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70711
70712 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70713
70714 -static inline void nd_set_link(struct nameidata *nd, char *path)
70715 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70716 {
70717 nd->saved_names[nd->depth] = path;
70718 }
70719
70720 -static inline char *nd_get_link(struct nameidata *nd)
70721 +static inline const char *nd_get_link(const struct nameidata *nd)
70722 {
70723 return nd->saved_names[nd->depth];
70724 }
70725 diff --git a/include/linux/net.h b/include/linux/net.h
70726 index aa16731..514b875 100644
70727 --- a/include/linux/net.h
70728 +++ b/include/linux/net.h
70729 @@ -183,7 +183,7 @@ struct net_proto_family {
70730 int (*create)(struct net *net, struct socket *sock,
70731 int protocol, int kern);
70732 struct module *owner;
70733 -};
70734 +} __do_const;
70735
70736 struct iovec;
70737 struct kvec;
70738 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70739 index 9ef07d0..130a5d9 100644
70740 --- a/include/linux/netdevice.h
70741 +++ b/include/linux/netdevice.h
70742 @@ -1012,6 +1012,7 @@ struct net_device_ops {
70743 u32 pid, u32 seq,
70744 struct net_device *dev);
70745 };
70746 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70747
70748 /*
70749 * The DEVICE structure.
70750 @@ -1078,7 +1079,7 @@ struct net_device {
70751 int iflink;
70752
70753 struct net_device_stats stats;
70754 - atomic_long_t rx_dropped; /* dropped packets by core network
70755 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70756 * Do not use this in drivers.
70757 */
70758
70759 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70760 index ee14284..bc65d63 100644
70761 --- a/include/linux/netfilter.h
70762 +++ b/include/linux/netfilter.h
70763 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70764 #endif
70765 /* Use the module struct to lock set/get code in place */
70766 struct module *owner;
70767 -};
70768 +} __do_const;
70769
70770 /* Function to register/unregister hook points. */
70771 int nf_register_hook(struct nf_hook_ops *reg);
70772 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70773 index 7958e84..ed74d7a 100644
70774 --- a/include/linux/netfilter/ipset/ip_set.h
70775 +++ b/include/linux/netfilter/ipset/ip_set.h
70776 @@ -98,7 +98,7 @@ struct ip_set_type_variant {
70777 /* Return true if "b" set is the same as "a"
70778 * according to the create set parameters */
70779 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70780 -};
70781 +} __do_const;
70782
70783 /* The core set type structure */
70784 struct ip_set_type {
70785 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70786 index 4966dde..7d8ce06 100644
70787 --- a/include/linux/netfilter/nfnetlink.h
70788 +++ b/include/linux/netfilter/nfnetlink.h
70789 @@ -16,7 +16,7 @@ struct nfnl_callback {
70790 const struct nlattr * const cda[]);
70791 const struct nla_policy *policy; /* netlink attribute policy */
70792 const u_int16_t attr_count; /* number of nlattr's */
70793 -};
70794 +} __do_const;
70795
70796 struct nfnetlink_subsystem {
70797 const char *name;
70798 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70799 new file mode 100644
70800 index 0000000..33f4af8
70801 --- /dev/null
70802 +++ b/include/linux/netfilter/xt_gradm.h
70803 @@ -0,0 +1,9 @@
70804 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70805 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70806 +
70807 +struct xt_gradm_mtinfo {
70808 + __u16 flags;
70809 + __u16 invflags;
70810 +};
70811 +
70812 +#endif
70813 diff --git a/include/linux/nls.h b/include/linux/nls.h
70814 index 5dc635f..35f5e11 100644
70815 --- a/include/linux/nls.h
70816 +++ b/include/linux/nls.h
70817 @@ -31,7 +31,7 @@ struct nls_table {
70818 const unsigned char *charset2upper;
70819 struct module *owner;
70820 struct nls_table *next;
70821 -};
70822 +} __do_const;
70823
70824 /* this value hold the maximum octet of charset */
70825 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
70826 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
70827 index d65746e..62e72c2 100644
70828 --- a/include/linux/notifier.h
70829 +++ b/include/linux/notifier.h
70830 @@ -51,7 +51,8 @@ struct notifier_block {
70831 int (*notifier_call)(struct notifier_block *, unsigned long, void *);
70832 struct notifier_block __rcu *next;
70833 int priority;
70834 -};
70835 +} __do_const;
70836 +typedef struct notifier_block __no_const notifier_block_no_const;
70837
70838 struct atomic_notifier_head {
70839 spinlock_t lock;
70840 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
70841 index a4c5624..79d6d88 100644
70842 --- a/include/linux/oprofile.h
70843 +++ b/include/linux/oprofile.h
70844 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
70845 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
70846 char const * name, ulong * val);
70847
70848 -/** Create a file for read-only access to an atomic_t. */
70849 +/** Create a file for read-only access to an atomic_unchecked_t. */
70850 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
70851 - char const * name, atomic_t * val);
70852 + char const * name, atomic_unchecked_t * val);
70853
70854 /** create a directory */
70855 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
70856 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
70857 index 45fc162..01a4068 100644
70858 --- a/include/linux/pci_hotplug.h
70859 +++ b/include/linux/pci_hotplug.h
70860 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
70861 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
70862 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
70863 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
70864 -};
70865 +} __do_const;
70866 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
70867
70868 /**
70869 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
70870 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
70871 index a280650..2b67b91 100644
70872 --- a/include/linux/perf_event.h
70873 +++ b/include/linux/perf_event.h
70874 @@ -328,8 +328,8 @@ struct perf_event {
70875
70876 enum perf_event_active_state state;
70877 unsigned int attach_state;
70878 - local64_t count;
70879 - atomic64_t child_count;
70880 + local64_t count; /* PaX: fix it one day */
70881 + atomic64_unchecked_t child_count;
70882
70883 /*
70884 * These are the total time in nanoseconds that the event
70885 @@ -380,8 +380,8 @@ struct perf_event {
70886 * These accumulate total time (in nanoseconds) that children
70887 * events have been enabled and running, respectively.
70888 */
70889 - atomic64_t child_total_time_enabled;
70890 - atomic64_t child_total_time_running;
70891 + atomic64_unchecked_t child_total_time_enabled;
70892 + atomic64_unchecked_t child_total_time_running;
70893
70894 /*
70895 * Protect attach/detach and child_list:
70896 @@ -807,7 +807,7 @@ static inline void perf_restore_debug_store(void) { }
70897 */
70898 #define perf_cpu_notifier(fn) \
70899 do { \
70900 - static struct notifier_block fn##_nb __cpuinitdata = \
70901 + static struct notifier_block fn##_nb = \
70902 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
70903 unsigned long cpu = smp_processor_id(); \
70904 unsigned long flags; \
70905 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
70906 index ad1a427..6419649 100644
70907 --- a/include/linux/pipe_fs_i.h
70908 +++ b/include/linux/pipe_fs_i.h
70909 @@ -45,9 +45,9 @@ struct pipe_buffer {
70910 struct pipe_inode_info {
70911 wait_queue_head_t wait;
70912 unsigned int nrbufs, curbuf, buffers;
70913 - unsigned int readers;
70914 - unsigned int writers;
70915 - unsigned int waiting_writers;
70916 + atomic_t readers;
70917 + atomic_t writers;
70918 + atomic_t waiting_writers;
70919 unsigned int r_counter;
70920 unsigned int w_counter;
70921 struct page *tmp_page;
70922 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
70923 index 5f28cae..3d23723 100644
70924 --- a/include/linux/platform_data/usb-ehci-s5p.h
70925 +++ b/include/linux/platform_data/usb-ehci-s5p.h
70926 @@ -14,7 +14,7 @@
70927 struct s5p_ehci_platdata {
70928 int (*phy_init)(struct platform_device *pdev, int type);
70929 int (*phy_exit)(struct platform_device *pdev, int type);
70930 -};
70931 +} __no_const;
70932
70933 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
70934
70935 diff --git a/include/linux/platform_data/usb-exynos.h b/include/linux/platform_data/usb-exynos.h
70936 index c256c59..8ea94c7 100644
70937 --- a/include/linux/platform_data/usb-exynos.h
70938 +++ b/include/linux/platform_data/usb-exynos.h
70939 @@ -14,7 +14,7 @@
70940 struct exynos4_ohci_platdata {
70941 int (*phy_init)(struct platform_device *pdev, int type);
70942 int (*phy_exit)(struct platform_device *pdev, int type);
70943 -};
70944 +} __no_const;
70945
70946 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
70947
70948 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
70949 index 7c1d252..c5c773e 100644
70950 --- a/include/linux/pm_domain.h
70951 +++ b/include/linux/pm_domain.h
70952 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
70953
70954 struct gpd_cpu_data {
70955 unsigned int saved_exit_latency;
70956 - struct cpuidle_state *idle_state;
70957 + cpuidle_state_no_const *idle_state;
70958 };
70959
70960 struct generic_pm_domain {
70961 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
70962 index f271860..6b3bec5 100644
70963 --- a/include/linux/pm_runtime.h
70964 +++ b/include/linux/pm_runtime.h
70965 @@ -97,7 +97,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
70966
70967 static inline void pm_runtime_mark_last_busy(struct device *dev)
70968 {
70969 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
70970 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
70971 }
70972
70973 #else /* !CONFIG_PM_RUNTIME */
70974 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
70975 index 195aafc..49a7bc2 100644
70976 --- a/include/linux/pnp.h
70977 +++ b/include/linux/pnp.h
70978 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
70979 struct pnp_fixup {
70980 char id[7];
70981 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
70982 -};
70983 +} __do_const;
70984
70985 /* config parameters */
70986 #define PNP_CONFIG_NORMAL 0x0001
70987 diff --git a/include/linux/poison.h b/include/linux/poison.h
70988 index 2110a81..13a11bb 100644
70989 --- a/include/linux/poison.h
70990 +++ b/include/linux/poison.h
70991 @@ -19,8 +19,8 @@
70992 * under normal circumstances, used to verify that nobody uses
70993 * non-initialized list entries.
70994 */
70995 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
70996 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
70997 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
70998 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
70999
71000 /********** include/linux/timer.h **********/
71001 /*
71002 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71003 index c0f44c2..1572583 100644
71004 --- a/include/linux/power/smartreflex.h
71005 +++ b/include/linux/power/smartreflex.h
71006 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71007 int (*notify)(struct omap_sr *sr, u32 status);
71008 u8 notify_flags;
71009 u8 class_type;
71010 -};
71011 +} __do_const;
71012
71013 /**
71014 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71015 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71016 index 4ea1d37..80f4b33 100644
71017 --- a/include/linux/ppp-comp.h
71018 +++ b/include/linux/ppp-comp.h
71019 @@ -84,7 +84,7 @@ struct compressor {
71020 struct module *owner;
71021 /* Extra skb space needed by the compressor algorithm */
71022 unsigned int comp_extra;
71023 -};
71024 +} __do_const;
71025
71026 /*
71027 * The return value from decompress routine is the length of the
71028 diff --git a/include/linux/printk.h b/include/linux/printk.h
71029 index 9afc01e..92c32e8 100644
71030 --- a/include/linux/printk.h
71031 +++ b/include/linux/printk.h
71032 @@ -101,6 +101,8 @@ void early_printk(const char *fmt, ...);
71033 extern int printk_needs_cpu(int cpu);
71034 extern void printk_tick(void);
71035
71036 +extern int kptr_restrict;
71037 +
71038 #ifdef CONFIG_PRINTK
71039 asmlinkage __printf(5, 0)
71040 int vprintk_emit(int facility, int level,
71041 @@ -135,7 +137,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71042
71043 extern int printk_delay_msec;
71044 extern int dmesg_restrict;
71045 -extern int kptr_restrict;
71046
71047 void log_buf_kexec_setup(void);
71048 void __init setup_log_buf(int early);
71049 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71050 index 32676b3..e46f2c0 100644
71051 --- a/include/linux/proc_fs.h
71052 +++ b/include/linux/proc_fs.h
71053 @@ -159,6 +159,18 @@ static inline struct proc_dir_entry *proc_create(const char *name, umode_t mode,
71054 return proc_create_data(name, mode, parent, proc_fops, NULL);
71055 }
71056
71057 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71058 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71059 +{
71060 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71061 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71062 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71063 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71064 +#else
71065 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71066 +#endif
71067 +}
71068 +
71069 static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
71070 umode_t mode, struct proc_dir_entry *base,
71071 read_proc_t *read_proc, void * data)
71072 @@ -268,7 +280,7 @@ struct proc_ns_operations {
71073 void (*put)(void *ns);
71074 int (*install)(struct nsproxy *nsproxy, void *ns);
71075 unsigned int (*inum)(void *ns);
71076 -};
71077 +} __do_const;
71078 extern const struct proc_ns_operations netns_operations;
71079 extern const struct proc_ns_operations utsns_operations;
71080 extern const struct proc_ns_operations ipcns_operations;
71081 diff --git a/include/linux/random.h b/include/linux/random.h
71082 index d984608..d6f0042 100644
71083 --- a/include/linux/random.h
71084 +++ b/include/linux/random.h
71085 @@ -39,6 +39,11 @@ void prandom_seed(u32 seed);
71086 u32 prandom_u32_state(struct rnd_state *);
71087 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71088
71089 +static inline unsigned long pax_get_random_long(void)
71090 +{
71091 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71092 +}
71093 +
71094 /*
71095 * Handle minimum values for seeds
71096 */
71097 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71098 index c92dd28..08f4eab 100644
71099 --- a/include/linux/rculist.h
71100 +++ b/include/linux/rculist.h
71101 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71102 struct list_head *prev, struct list_head *next);
71103 #endif
71104
71105 +extern void __pax_list_add_rcu(struct list_head *new,
71106 + struct list_head *prev, struct list_head *next);
71107 +
71108 /**
71109 * list_add_rcu - add a new entry to rcu-protected list
71110 * @new: new entry to be added
71111 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71112 __list_add_rcu(new, head, head->next);
71113 }
71114
71115 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71116 +{
71117 + __pax_list_add_rcu(new, head, head->next);
71118 +}
71119 +
71120 /**
71121 * list_add_tail_rcu - add a new entry to rcu-protected list
71122 * @new: new entry to be added
71123 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71124 __list_add_rcu(new, head->prev, head);
71125 }
71126
71127 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71128 + struct list_head *head)
71129 +{
71130 + __pax_list_add_rcu(new, head->prev, head);
71131 +}
71132 +
71133 /**
71134 * list_del_rcu - deletes entry from list without re-initialization
71135 * @entry: the element to delete from the list.
71136 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71137 entry->prev = LIST_POISON2;
71138 }
71139
71140 +extern void pax_list_del_rcu(struct list_head *entry);
71141 +
71142 /**
71143 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71144 * @n: the element to delete from the hash list.
71145 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71146 index 23b3630..e1bc12b 100644
71147 --- a/include/linux/reboot.h
71148 +++ b/include/linux/reboot.h
71149 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71150 * Architecture-specific implementations of sys_reboot commands.
71151 */
71152
71153 -extern void machine_restart(char *cmd);
71154 -extern void machine_halt(void);
71155 -extern void machine_power_off(void);
71156 +extern void machine_restart(char *cmd) __noreturn;
71157 +extern void machine_halt(void) __noreturn;
71158 +extern void machine_power_off(void) __noreturn;
71159
71160 extern void machine_shutdown(void);
71161 struct pt_regs;
71162 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71163 */
71164
71165 extern void kernel_restart_prepare(char *cmd);
71166 -extern void kernel_restart(char *cmd);
71167 -extern void kernel_halt(void);
71168 -extern void kernel_power_off(void);
71169 +extern void kernel_restart(char *cmd) __noreturn;
71170 +extern void kernel_halt(void) __noreturn;
71171 +extern void kernel_power_off(void) __noreturn;
71172
71173 extern int C_A_D; /* for sysctl */
71174 void ctrl_alt_del(void);
71175 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71176 * Emergency restart, callable from an interrupt handler.
71177 */
71178
71179 -extern void emergency_restart(void);
71180 +extern void emergency_restart(void) __noreturn;
71181 #include <asm/emergency-restart.h>
71182
71183 #endif /* _LINUX_REBOOT_H */
71184 diff --git a/include/linux/regset.h b/include/linux/regset.h
71185 index 8e0c9fe..ac4d221 100644
71186 --- a/include/linux/regset.h
71187 +++ b/include/linux/regset.h
71188 @@ -161,7 +161,8 @@ struct user_regset {
71189 unsigned int align;
71190 unsigned int bias;
71191 unsigned int core_note_type;
71192 -};
71193 +} __do_const;
71194 +typedef struct user_regset __no_const user_regset_no_const;
71195
71196 /**
71197 * struct user_regset_view - available regsets
71198 diff --git a/include/linux/relay.h b/include/linux/relay.h
71199 index 91cacc3..b55ff74 100644
71200 --- a/include/linux/relay.h
71201 +++ b/include/linux/relay.h
71202 @@ -160,7 +160,7 @@ struct rchan_callbacks
71203 * The callback should return 0 if successful, negative if not.
71204 */
71205 int (*remove_buf_file)(struct dentry *dentry);
71206 -};
71207 +} __no_const;
71208
71209 /*
71210 * CONFIG_RELAY kernel API, kernel/relay.c
71211 diff --git a/include/linux/rio.h b/include/linux/rio.h
71212 index a3e7842..d973ca6 100644
71213 --- a/include/linux/rio.h
71214 +++ b/include/linux/rio.h
71215 @@ -339,7 +339,7 @@ struct rio_ops {
71216 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71217 u64 rstart, u32 size, u32 flags);
71218 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71219 -};
71220 +} __no_const;
71221
71222 #define RIO_RESOURCE_MEM 0x00000100
71223 #define RIO_RESOURCE_DOORBELL 0x00000200
71224 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71225 index c20635c..2f5def4 100644
71226 --- a/include/linux/rmap.h
71227 +++ b/include/linux/rmap.h
71228 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71229 void anon_vma_init(void); /* create anon_vma_cachep */
71230 int anon_vma_prepare(struct vm_area_struct *);
71231 void unlink_anon_vmas(struct vm_area_struct *);
71232 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71233 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71234 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71235 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71236
71237 static inline void anon_vma_merge(struct vm_area_struct *vma,
71238 struct vm_area_struct *next)
71239 diff --git a/include/linux/sched.h b/include/linux/sched.h
71240 index d211247..eac6c2c 100644
71241 --- a/include/linux/sched.h
71242 +++ b/include/linux/sched.h
71243 @@ -61,6 +61,7 @@ struct bio_list;
71244 struct fs_struct;
71245 struct perf_event_context;
71246 struct blk_plug;
71247 +struct linux_binprm;
71248
71249 /*
71250 * List of flags we want to share for kernel threads,
71251 @@ -327,7 +328,7 @@ extern char __sched_text_start[], __sched_text_end[];
71252 extern int in_sched_functions(unsigned long addr);
71253
71254 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71255 -extern signed long schedule_timeout(signed long timeout);
71256 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71257 extern signed long schedule_timeout_interruptible(signed long timeout);
71258 extern signed long schedule_timeout_killable(signed long timeout);
71259 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71260 @@ -354,10 +355,23 @@ struct user_namespace;
71261 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71262
71263 extern int sysctl_max_map_count;
71264 +extern unsigned long sysctl_heap_stack_gap;
71265
71266 #include <linux/aio.h>
71267
71268 #ifdef CONFIG_MMU
71269 +
71270 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71271 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71272 +#else
71273 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71274 +{
71275 + return 0;
71276 +}
71277 +#endif
71278 +
71279 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71280 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71281 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71282 extern unsigned long
71283 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71284 @@ -639,6 +653,17 @@ struct signal_struct {
71285 #ifdef CONFIG_TASKSTATS
71286 struct taskstats *stats;
71287 #endif
71288 +
71289 +#ifdef CONFIG_GRKERNSEC
71290 + u32 curr_ip;
71291 + u32 saved_ip;
71292 + u32 gr_saddr;
71293 + u32 gr_daddr;
71294 + u16 gr_sport;
71295 + u16 gr_dport;
71296 + u8 used_accept:1;
71297 +#endif
71298 +
71299 #ifdef CONFIG_AUDIT
71300 unsigned audit_tty;
71301 struct tty_audit_buf *tty_audit_buf;
71302 @@ -717,6 +742,11 @@ struct user_struct {
71303 struct key *session_keyring; /* UID's default session keyring */
71304 #endif
71305
71306 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT) || defined(CONFIG_GRKERNSEC_BRUTE)
71307 + unsigned int banned;
71308 + unsigned long ban_expires;
71309 +#endif
71310 +
71311 /* Hash table maintenance information */
71312 struct hlist_node uidhash_node;
71313 kuid_t uid;
71314 @@ -1116,7 +1146,7 @@ struct sched_class {
71315 #ifdef CONFIG_FAIR_GROUP_SCHED
71316 void (*task_move_group) (struct task_struct *p, int on_rq);
71317 #endif
71318 -};
71319 +} __do_const;
71320
71321 struct load_weight {
71322 unsigned long weight, inv_weight;
71323 @@ -1360,8 +1390,8 @@ struct task_struct {
71324 struct list_head thread_group;
71325
71326 struct completion *vfork_done; /* for vfork() */
71327 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71328 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71329 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71330 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71331
71332 cputime_t utime, stime, utimescaled, stimescaled;
71333 cputime_t gtime;
71334 @@ -1377,11 +1407,6 @@ struct task_struct {
71335 struct task_cputime cputime_expires;
71336 struct list_head cpu_timers[3];
71337
71338 -/* process credentials */
71339 - const struct cred __rcu *real_cred; /* objective and real subjective task
71340 - * credentials (COW) */
71341 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71342 - * credentials (COW) */
71343 char comm[TASK_COMM_LEN]; /* executable name excluding path
71344 - access with [gs]et_task_comm (which lock
71345 it with task_lock())
71346 @@ -1398,6 +1423,10 @@ struct task_struct {
71347 #endif
71348 /* CPU-specific state of this task */
71349 struct thread_struct thread;
71350 +/* thread_info moved to task_struct */
71351 +#ifdef CONFIG_X86
71352 + struct thread_info tinfo;
71353 +#endif
71354 /* filesystem information */
71355 struct fs_struct *fs;
71356 /* open file information */
71357 @@ -1471,6 +1500,10 @@ struct task_struct {
71358 gfp_t lockdep_reclaim_gfp;
71359 #endif
71360
71361 +/* process credentials */
71362 + const struct cred __rcu *real_cred; /* objective and real subjective task
71363 + * credentials (COW) */
71364 +
71365 /* journalling filesystem info */
71366 void *journal_info;
71367
71368 @@ -1509,6 +1542,10 @@ struct task_struct {
71369 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71370 struct list_head cg_list;
71371 #endif
71372 +
71373 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71374 + * credentials (COW) */
71375 +
71376 #ifdef CONFIG_FUTEX
71377 struct robust_list_head __user *robust_list;
71378 #ifdef CONFIG_COMPAT
71379 @@ -1605,8 +1642,74 @@ struct task_struct {
71380 #ifdef CONFIG_UPROBES
71381 struct uprobe_task *utask;
71382 #endif
71383 +
71384 +#ifdef CONFIG_GRKERNSEC
71385 + /* grsecurity */
71386 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71387 + u64 exec_id;
71388 +#endif
71389 +#ifdef CONFIG_GRKERNSEC_SETXID
71390 + const struct cred *delayed_cred;
71391 +#endif
71392 + struct dentry *gr_chroot_dentry;
71393 + struct acl_subject_label *acl;
71394 + struct acl_role_label *role;
71395 + struct file *exec_file;
71396 + unsigned long brute_expires;
71397 + u16 acl_role_id;
71398 + /* is this the task that authenticated to the special role */
71399 + u8 acl_sp_role;
71400 + u8 is_writable;
71401 + u8 brute;
71402 + u8 gr_is_chrooted;
71403 +#endif
71404 +
71405 };
71406
71407 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71408 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71409 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71410 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71411 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71412 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71413 +
71414 +#ifdef CONFIG_PAX_SOFTMODE
71415 +extern int pax_softmode;
71416 +#endif
71417 +
71418 +extern int pax_check_flags(unsigned long *);
71419 +
71420 +/* if tsk != current then task_lock must be held on it */
71421 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71422 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71423 +{
71424 + if (likely(tsk->mm))
71425 + return tsk->mm->pax_flags;
71426 + else
71427 + return 0UL;
71428 +}
71429 +
71430 +/* if tsk != current then task_lock must be held on it */
71431 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71432 +{
71433 + if (likely(tsk->mm)) {
71434 + tsk->mm->pax_flags = flags;
71435 + return 0;
71436 + }
71437 + return -EINVAL;
71438 +}
71439 +#endif
71440 +
71441 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71442 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71443 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71444 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71445 +#endif
71446 +
71447 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71448 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71449 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71450 +
71451 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71452 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71453
71454 @@ -1696,7 +1799,7 @@ struct pid_namespace;
71455 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71456 struct pid_namespace *ns);
71457
71458 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71459 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71460 {
71461 return tsk->pid;
71462 }
71463 @@ -2155,7 +2258,9 @@ void yield(void);
71464 extern struct exec_domain default_exec_domain;
71465
71466 union thread_union {
71467 +#ifndef CONFIG_X86
71468 struct thread_info thread_info;
71469 +#endif
71470 unsigned long stack[THREAD_SIZE/sizeof(long)];
71471 };
71472
71473 @@ -2188,6 +2293,7 @@ extern struct pid_namespace init_pid_ns;
71474 */
71475
71476 extern struct task_struct *find_task_by_vpid(pid_t nr);
71477 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71478 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71479 struct pid_namespace *ns);
71480
71481 @@ -2344,7 +2450,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71482 extern void exit_itimers(struct signal_struct *);
71483 extern void flush_itimer_signals(void);
71484
71485 -extern void do_group_exit(int);
71486 +extern __noreturn void do_group_exit(int);
71487
71488 extern int allow_signal(int);
71489 extern int disallow_signal(int);
71490 @@ -2545,9 +2651,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71491
71492 #endif
71493
71494 -static inline int object_is_on_stack(void *obj)
71495 +static inline int object_starts_on_stack(void *obj)
71496 {
71497 - void *stack = task_stack_page(current);
71498 + const void *stack = task_stack_page(current);
71499
71500 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71501 }
71502 diff --git a/include/linux/security.h b/include/linux/security.h
71503 index eee7478..290f7ba 100644
71504 --- a/include/linux/security.h
71505 +++ b/include/linux/security.h
71506 @@ -26,6 +26,7 @@
71507 #include <linux/capability.h>
71508 #include <linux/slab.h>
71509 #include <linux/err.h>
71510 +#include <linux/grsecurity.h>
71511
71512 struct linux_binprm;
71513 struct cred;
71514 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71515 index 68a04a3..866e6a1 100644
71516 --- a/include/linux/seq_file.h
71517 +++ b/include/linux/seq_file.h
71518 @@ -26,6 +26,9 @@ struct seq_file {
71519 struct mutex lock;
71520 const struct seq_operations *op;
71521 int poll_event;
71522 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71523 + u64 exec_id;
71524 +#endif
71525 #ifdef CONFIG_USER_NS
71526 struct user_namespace *user_ns;
71527 #endif
71528 @@ -38,6 +41,7 @@ struct seq_operations {
71529 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71530 int (*show) (struct seq_file *m, void *v);
71531 };
71532 +typedef struct seq_operations __no_const seq_operations_no_const;
71533
71534 #define SEQ_SKIP 1
71535
71536 diff --git a/include/linux/shm.h b/include/linux/shm.h
71537 index 429c199..4d42e38 100644
71538 --- a/include/linux/shm.h
71539 +++ b/include/linux/shm.h
71540 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71541
71542 /* The task created the shm object. NULL if the task is dead. */
71543 struct task_struct *shm_creator;
71544 +#ifdef CONFIG_GRKERNSEC
71545 + time_t shm_createtime;
71546 + pid_t shm_lapid;
71547 +#endif
71548 };
71549
71550 /* shm_mode upper byte flags */
71551 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71552 index 98399e2..7c74c41 100644
71553 --- a/include/linux/skbuff.h
71554 +++ b/include/linux/skbuff.h
71555 @@ -590,7 +590,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71556 extern struct sk_buff *__alloc_skb(unsigned int size,
71557 gfp_t priority, int flags, int node);
71558 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71559 -static inline struct sk_buff *alloc_skb(unsigned int size,
71560 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71561 gfp_t priority)
71562 {
71563 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71564 @@ -700,7 +700,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71565 */
71566 static inline int skb_queue_empty(const struct sk_buff_head *list)
71567 {
71568 - return list->next == (struct sk_buff *)list;
71569 + return list->next == (const struct sk_buff *)list;
71570 }
71571
71572 /**
71573 @@ -713,7 +713,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71574 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71575 const struct sk_buff *skb)
71576 {
71577 - return skb->next == (struct sk_buff *)list;
71578 + return skb->next == (const struct sk_buff *)list;
71579 }
71580
71581 /**
71582 @@ -726,7 +726,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71583 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71584 const struct sk_buff *skb)
71585 {
71586 - return skb->prev == (struct sk_buff *)list;
71587 + return skb->prev == (const struct sk_buff *)list;
71588 }
71589
71590 /**
71591 @@ -1727,7 +1727,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71592 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71593 */
71594 #ifndef NET_SKB_PAD
71595 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71596 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71597 #endif
71598
71599 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71600 @@ -2305,7 +2305,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71601 int noblock, int *err);
71602 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71603 struct poll_table_struct *wait);
71604 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71605 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71606 int offset, struct iovec *to,
71607 int size);
71608 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71609 @@ -2595,6 +2595,9 @@ static inline void nf_reset(struct sk_buff *skb)
71610 nf_bridge_put(skb->nf_bridge);
71611 skb->nf_bridge = NULL;
71612 #endif
71613 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71614 + skb->nf_trace = 0;
71615 +#endif
71616 }
71617
71618 /* Note: This doesn't put any conntrack and bridge info in dst. */
71619 diff --git a/include/linux/slab.h b/include/linux/slab.h
71620 index 5d168d7..720bff3 100644
71621 --- a/include/linux/slab.h
71622 +++ b/include/linux/slab.h
71623 @@ -12,13 +12,20 @@
71624 #include <linux/gfp.h>
71625 #include <linux/types.h>
71626 #include <linux/workqueue.h>
71627 -
71628 +#include <linux/err.h>
71629
71630 /*
71631 * Flags to pass to kmem_cache_create().
71632 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71633 */
71634 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71635 +
71636 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71637 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71638 +#else
71639 +#define SLAB_USERCOPY 0x00000000UL
71640 +#endif
71641 +
71642 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71643 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71644 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71645 @@ -89,10 +96,13 @@
71646 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71647 * Both make kfree a no-op.
71648 */
71649 -#define ZERO_SIZE_PTR ((void *)16)
71650 +#define ZERO_SIZE_PTR \
71651 +({ \
71652 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71653 + (void *)(-MAX_ERRNO-1L); \
71654 +})
71655
71656 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71657 - (unsigned long)ZERO_SIZE_PTR)
71658 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71659
71660 /*
71661 * Common fields provided in kmem_cache by all slab allocators
71662 @@ -112,7 +122,7 @@ struct kmem_cache {
71663 unsigned int align; /* Alignment as calculated */
71664 unsigned long flags; /* Active flags on the slab */
71665 const char *name; /* Slab name for sysfs */
71666 - int refcount; /* Use counter */
71667 + atomic_t refcount; /* Use counter */
71668 void (*ctor)(void *); /* Called on object slot creation */
71669 struct list_head list; /* List of all slab caches on the system */
71670 };
71671 @@ -232,6 +242,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71672 void kfree(const void *);
71673 void kzfree(const void *);
71674 size_t ksize(const void *);
71675 +const char *check_heap_object(const void *ptr, unsigned long n);
71676 +bool is_usercopy_object(const void *ptr);
71677
71678 /*
71679 * Allocator specific definitions. These are mainly used to establish optimized
71680 @@ -311,6 +323,7 @@ size_t ksize(const void *);
71681 * for general use, and so are not documented here. For a full list of
71682 * potential flags, always refer to linux/gfp.h.
71683 */
71684 +
71685 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71686 {
71687 if (size != 0 && n > SIZE_MAX / size)
71688 @@ -370,7 +383,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71689 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71690 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71691 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71692 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71693 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71694 #define kmalloc_track_caller(size, flags) \
71695 __kmalloc_track_caller(size, flags, _RET_IP_)
71696 #else
71697 @@ -390,7 +403,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71698 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71699 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71700 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71701 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71702 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71703 #define kmalloc_node_track_caller(size, flags, node) \
71704 __kmalloc_node_track_caller(size, flags, node, \
71705 _RET_IP_)
71706 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71707 index 8bb6e0e..8eb0dbe 100644
71708 --- a/include/linux/slab_def.h
71709 +++ b/include/linux/slab_def.h
71710 @@ -52,7 +52,7 @@ struct kmem_cache {
71711 /* 4) cache creation/removal */
71712 const char *name;
71713 struct list_head list;
71714 - int refcount;
71715 + atomic_t refcount;
71716 int object_size;
71717 int align;
71718
71719 @@ -68,10 +68,10 @@ struct kmem_cache {
71720 unsigned long node_allocs;
71721 unsigned long node_frees;
71722 unsigned long node_overflow;
71723 - atomic_t allochit;
71724 - atomic_t allocmiss;
71725 - atomic_t freehit;
71726 - atomic_t freemiss;
71727 + atomic_unchecked_t allochit;
71728 + atomic_unchecked_t allocmiss;
71729 + atomic_unchecked_t freehit;
71730 + atomic_unchecked_t freemiss;
71731
71732 /*
71733 * If debugging is enabled, then the allocator can add additional
71734 @@ -111,11 +111,16 @@ struct cache_sizes {
71735 #ifdef CONFIG_ZONE_DMA
71736 struct kmem_cache *cs_dmacachep;
71737 #endif
71738 +
71739 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71740 + struct kmem_cache *cs_usercopycachep;
71741 +#endif
71742 +
71743 };
71744 extern struct cache_sizes malloc_sizes[];
71745
71746 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71747 -void *__kmalloc(size_t size, gfp_t flags);
71748 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71749
71750 #ifdef CONFIG_TRACING
71751 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71752 @@ -152,6 +157,13 @@ found:
71753 cachep = malloc_sizes[i].cs_dmacachep;
71754 else
71755 #endif
71756 +
71757 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71758 + if (flags & GFP_USERCOPY)
71759 + cachep = malloc_sizes[i].cs_usercopycachep;
71760 + else
71761 +#endif
71762 +
71763 cachep = malloc_sizes[i].cs_cachep;
71764
71765 ret = kmem_cache_alloc_trace(cachep, flags, size);
71766 @@ -162,7 +174,7 @@ found:
71767 }
71768
71769 #ifdef CONFIG_NUMA
71770 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
71771 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71772 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71773
71774 #ifdef CONFIG_TRACING
71775 @@ -205,6 +217,13 @@ found:
71776 cachep = malloc_sizes[i].cs_dmacachep;
71777 else
71778 #endif
71779 +
71780 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71781 + if (flags & GFP_USERCOPY)
71782 + cachep = malloc_sizes[i].cs_usercopycachep;
71783 + else
71784 +#endif
71785 +
71786 cachep = malloc_sizes[i].cs_cachep;
71787
71788 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
71789 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
71790 index f28e14a..7831211 100644
71791 --- a/include/linux/slob_def.h
71792 +++ b/include/linux/slob_def.h
71793 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
71794 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
71795 }
71796
71797 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71798 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71799
71800 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
71801 {
71802 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71803 return __kmalloc_node(size, flags, NUMA_NO_NODE);
71804 }
71805
71806 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
71807 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
71808 {
71809 return kmalloc(size, flags);
71810 }
71811 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
71812 index 9db4825..ed42fb5 100644
71813 --- a/include/linux/slub_def.h
71814 +++ b/include/linux/slub_def.h
71815 @@ -91,7 +91,7 @@ struct kmem_cache {
71816 struct kmem_cache_order_objects max;
71817 struct kmem_cache_order_objects min;
71818 gfp_t allocflags; /* gfp flags to use on each alloc */
71819 - int refcount; /* Refcount for slab cache destroy */
71820 + atomic_t refcount; /* Refcount for slab cache destroy */
71821 void (*ctor)(void *);
71822 int inuse; /* Offset to metadata */
71823 int align; /* Alignment */
71824 @@ -156,7 +156,7 @@ extern struct kmem_cache *kmalloc_caches[SLUB_PAGE_SHIFT];
71825 * Sorry that the following has to be that ugly but some versions of GCC
71826 * have trouble with constant propagation and loops.
71827 */
71828 -static __always_inline int kmalloc_index(size_t size)
71829 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71830 {
71831 if (!size)
71832 return 0;
71833 @@ -221,7 +221,7 @@ static __always_inline struct kmem_cache *kmalloc_slab(size_t size)
71834 }
71835
71836 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71837 -void *__kmalloc(size_t size, gfp_t flags);
71838 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
71839
71840 static __always_inline void *
71841 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
71842 @@ -265,7 +265,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
71843 }
71844 #endif
71845
71846 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
71847 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
71848 {
71849 unsigned int order = get_order(size);
71850 return kmalloc_order_trace(size, flags, order);
71851 @@ -290,7 +290,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71852 }
71853
71854 #ifdef CONFIG_NUMA
71855 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
71856 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
71857 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
71858
71859 #ifdef CONFIG_TRACING
71860 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
71861 index e8d702e..0a56eb4 100644
71862 --- a/include/linux/sock_diag.h
71863 +++ b/include/linux/sock_diag.h
71864 @@ -10,7 +10,7 @@ struct sock;
71865 struct sock_diag_handler {
71866 __u8 family;
71867 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
71868 -};
71869 +} __do_const;
71870
71871 int sock_diag_register(const struct sock_diag_handler *h);
71872 void sock_diag_unregister(const struct sock_diag_handler *h);
71873 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
71874 index 680f9a3..f13aeb0 100644
71875 --- a/include/linux/sonet.h
71876 +++ b/include/linux/sonet.h
71877 @@ -7,7 +7,7 @@
71878 #include <uapi/linux/sonet.h>
71879
71880 struct k_sonet_stats {
71881 -#define __HANDLE_ITEM(i) atomic_t i
71882 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
71883 __SONET_ITEMS
71884 #undef __HANDLE_ITEM
71885 };
71886 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
71887 index 34206b8..3db7f1c 100644
71888 --- a/include/linux/sunrpc/clnt.h
71889 +++ b/include/linux/sunrpc/clnt.h
71890 @@ -96,7 +96,7 @@ struct rpc_procinfo {
71891 unsigned int p_timer; /* Which RTT timer to use */
71892 u32 p_statidx; /* Which procedure to account */
71893 const char * p_name; /* name of procedure */
71894 -};
71895 +} __do_const;
71896
71897 #ifdef __KERNEL__
71898
71899 @@ -176,9 +176,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
71900 {
71901 switch (sap->sa_family) {
71902 case AF_INET:
71903 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
71904 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
71905 case AF_INET6:
71906 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
71907 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
71908 }
71909 return 0;
71910 }
71911 @@ -211,7 +211,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
71912 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
71913 const struct sockaddr *src)
71914 {
71915 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
71916 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
71917 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
71918
71919 dsin->sin_family = ssin->sin_family;
71920 @@ -314,7 +314,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
71921 if (sa->sa_family != AF_INET6)
71922 return 0;
71923
71924 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
71925 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
71926 }
71927
71928 #endif /* __KERNEL__ */
71929 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
71930 index 676ddf5..4c519a1 100644
71931 --- a/include/linux/sunrpc/svc.h
71932 +++ b/include/linux/sunrpc/svc.h
71933 @@ -410,7 +410,7 @@ struct svc_procedure {
71934 unsigned int pc_count; /* call count */
71935 unsigned int pc_cachetype; /* cache info (NFS) */
71936 unsigned int pc_xdrressize; /* maximum size of XDR reply */
71937 -};
71938 +} __do_const;
71939
71940 /*
71941 * Function prototypes.
71942 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
71943 index 0b8e3e6..33e0a01 100644
71944 --- a/include/linux/sunrpc/svc_rdma.h
71945 +++ b/include/linux/sunrpc/svc_rdma.h
71946 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
71947 extern unsigned int svcrdma_max_requests;
71948 extern unsigned int svcrdma_max_req_size;
71949
71950 -extern atomic_t rdma_stat_recv;
71951 -extern atomic_t rdma_stat_read;
71952 -extern atomic_t rdma_stat_write;
71953 -extern atomic_t rdma_stat_sq_starve;
71954 -extern atomic_t rdma_stat_rq_starve;
71955 -extern atomic_t rdma_stat_rq_poll;
71956 -extern atomic_t rdma_stat_rq_prod;
71957 -extern atomic_t rdma_stat_sq_poll;
71958 -extern atomic_t rdma_stat_sq_prod;
71959 +extern atomic_unchecked_t rdma_stat_recv;
71960 +extern atomic_unchecked_t rdma_stat_read;
71961 +extern atomic_unchecked_t rdma_stat_write;
71962 +extern atomic_unchecked_t rdma_stat_sq_starve;
71963 +extern atomic_unchecked_t rdma_stat_rq_starve;
71964 +extern atomic_unchecked_t rdma_stat_rq_poll;
71965 +extern atomic_unchecked_t rdma_stat_rq_prod;
71966 +extern atomic_unchecked_t rdma_stat_sq_poll;
71967 +extern atomic_unchecked_t rdma_stat_sq_prod;
71968
71969 #define RPCRDMA_VERSION 1
71970
71971 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
71972 index dd74084a..7f509d5 100644
71973 --- a/include/linux/sunrpc/svcauth.h
71974 +++ b/include/linux/sunrpc/svcauth.h
71975 @@ -109,7 +109,7 @@ struct auth_ops {
71976 int (*release)(struct svc_rqst *rq);
71977 void (*domain_release)(struct auth_domain *);
71978 int (*set_client)(struct svc_rqst *rq);
71979 -};
71980 +} __do_const;
71981
71982 #define SVC_GARBAGE 1
71983 #define SVC_SYSERR 2
71984 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
71985 index 071d62c..4ccc7ac 100644
71986 --- a/include/linux/swiotlb.h
71987 +++ b/include/linux/swiotlb.h
71988 @@ -59,7 +59,8 @@ extern void
71989
71990 extern void
71991 swiotlb_free_coherent(struct device *hwdev, size_t size,
71992 - void *vaddr, dma_addr_t dma_handle);
71993 + void *vaddr, dma_addr_t dma_handle,
71994 + struct dma_attrs *attrs);
71995
71996 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
71997 unsigned long offset, size_t size,
71998 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
71999 index 45e2db2..1635156a 100644
72000 --- a/include/linux/syscalls.h
72001 +++ b/include/linux/syscalls.h
72002 @@ -615,7 +615,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72003 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72004 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72005 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72006 - struct sockaddr __user *, int);
72007 + struct sockaddr __user *, int) __intentional_overflow(0);
72008 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72009 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72010 unsigned int vlen, unsigned flags);
72011 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72012 index 27b3b0b..e093dd9 100644
72013 --- a/include/linux/syscore_ops.h
72014 +++ b/include/linux/syscore_ops.h
72015 @@ -16,7 +16,7 @@ struct syscore_ops {
72016 int (*suspend)(void);
72017 void (*resume)(void);
72018 void (*shutdown)(void);
72019 -};
72020 +} __do_const;
72021
72022 extern void register_syscore_ops(struct syscore_ops *ops);
72023 extern void unregister_syscore_ops(struct syscore_ops *ops);
72024 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72025 index 14a8ff2..af52bad 100644
72026 --- a/include/linux/sysctl.h
72027 +++ b/include/linux/sysctl.h
72028 @@ -34,13 +34,13 @@ struct ctl_table_root;
72029 struct ctl_table_header;
72030 struct ctl_dir;
72031
72032 -typedef struct ctl_table ctl_table;
72033 -
72034 typedef int proc_handler (struct ctl_table *ctl, int write,
72035 void __user *buffer, size_t *lenp, loff_t *ppos);
72036
72037 extern int proc_dostring(struct ctl_table *, int,
72038 void __user *, size_t *, loff_t *);
72039 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72040 + void __user *, size_t *, loff_t *);
72041 extern int proc_dointvec(struct ctl_table *, int,
72042 void __user *, size_t *, loff_t *);
72043 extern int proc_dointvec_minmax(struct ctl_table *, int,
72044 @@ -115,7 +115,9 @@ struct ctl_table
72045 struct ctl_table_poll *poll;
72046 void *extra1;
72047 void *extra2;
72048 -};
72049 +} __do_const;
72050 +typedef struct ctl_table __no_const ctl_table_no_const;
72051 +typedef struct ctl_table ctl_table;
72052
72053 struct ctl_node {
72054 struct rb_node node;
72055 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72056 index 381f06d..dc16cc7 100644
72057 --- a/include/linux/sysfs.h
72058 +++ b/include/linux/sysfs.h
72059 @@ -31,7 +31,8 @@ struct attribute {
72060 struct lock_class_key *key;
72061 struct lock_class_key skey;
72062 #endif
72063 -};
72064 +} __do_const;
72065 +typedef struct attribute __no_const attribute_no_const;
72066
72067 /**
72068 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72069 @@ -59,8 +60,8 @@ struct attribute_group {
72070 umode_t (*is_visible)(struct kobject *,
72071 struct attribute *, int);
72072 struct attribute **attrs;
72073 -};
72074 -
72075 +} __do_const;
72076 +typedef struct attribute_group __no_const attribute_group_no_const;
72077
72078
72079 /**
72080 @@ -107,7 +108,8 @@ struct bin_attribute {
72081 char *, loff_t, size_t);
72082 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72083 struct vm_area_struct *vma);
72084 -};
72085 +} __do_const;
72086 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72087
72088 /**
72089 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72090 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72091 index 7faf933..9b85a0c 100644
72092 --- a/include/linux/sysrq.h
72093 +++ b/include/linux/sysrq.h
72094 @@ -16,6 +16,7 @@
72095
72096 #include <linux/errno.h>
72097 #include <linux/types.h>
72098 +#include <linux/compiler.h>
72099
72100 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72101 #define SYSRQ_DEFAULT_ENABLE 1
72102 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72103 char *help_msg;
72104 char *action_msg;
72105 int enable_mask;
72106 -};
72107 +} __do_const;
72108
72109 #ifdef CONFIG_MAGIC_SYSRQ
72110
72111 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72112 index e7e0473..7989295 100644
72113 --- a/include/linux/thread_info.h
72114 +++ b/include/linux/thread_info.h
72115 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72116 #error "no set_restore_sigmask() provided and default one won't work"
72117 #endif
72118
72119 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72120 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72121 +{
72122 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72123 + if (!__builtin_constant_p(n))
72124 +#endif
72125 + __check_object_size(ptr, n, to_user);
72126 +}
72127 +
72128 #endif /* __KERNEL__ */
72129
72130 #endif /* _LINUX_THREAD_INFO_H */
72131 diff --git a/include/linux/tty.h b/include/linux/tty.h
72132 index 8db1b56..c16a040 100644
72133 --- a/include/linux/tty.h
72134 +++ b/include/linux/tty.h
72135 @@ -194,7 +194,7 @@ struct tty_port {
72136 const struct tty_port_operations *ops; /* Port operations */
72137 spinlock_t lock; /* Lock protecting tty field */
72138 int blocked_open; /* Waiting to open */
72139 - int count; /* Usage count */
72140 + atomic_t count; /* Usage count */
72141 wait_queue_head_t open_wait; /* Open waiters */
72142 wait_queue_head_t close_wait; /* Close waiters */
72143 wait_queue_head_t delta_msr_wait; /* Modem status change */
72144 @@ -490,7 +490,7 @@ extern int tty_port_open(struct tty_port *port,
72145 struct tty_struct *tty, struct file *filp);
72146 static inline int tty_port_users(struct tty_port *port)
72147 {
72148 - return port->count + port->blocked_open;
72149 + return atomic_read(&port->count) + port->blocked_open;
72150 }
72151
72152 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72153 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72154 index dd976cf..e272742 100644
72155 --- a/include/linux/tty_driver.h
72156 +++ b/include/linux/tty_driver.h
72157 @@ -284,7 +284,7 @@ struct tty_operations {
72158 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72159 #endif
72160 const struct file_operations *proc_fops;
72161 -};
72162 +} __do_const;
72163
72164 struct tty_driver {
72165 int magic; /* magic number for this structure */
72166 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72167 index fb79dd8d..07d4773 100644
72168 --- a/include/linux/tty_ldisc.h
72169 +++ b/include/linux/tty_ldisc.h
72170 @@ -149,7 +149,7 @@ struct tty_ldisc_ops {
72171
72172 struct module *owner;
72173
72174 - int refcount;
72175 + atomic_t refcount;
72176 };
72177
72178 struct tty_ldisc {
72179 diff --git a/include/linux/types.h b/include/linux/types.h
72180 index 4d118ba..c3ee9bf 100644
72181 --- a/include/linux/types.h
72182 +++ b/include/linux/types.h
72183 @@ -176,10 +176,26 @@ typedef struct {
72184 int counter;
72185 } atomic_t;
72186
72187 +#ifdef CONFIG_PAX_REFCOUNT
72188 +typedef struct {
72189 + int counter;
72190 +} atomic_unchecked_t;
72191 +#else
72192 +typedef atomic_t atomic_unchecked_t;
72193 +#endif
72194 +
72195 #ifdef CONFIG_64BIT
72196 typedef struct {
72197 long counter;
72198 } atomic64_t;
72199 +
72200 +#ifdef CONFIG_PAX_REFCOUNT
72201 +typedef struct {
72202 + long counter;
72203 +} atomic64_unchecked_t;
72204 +#else
72205 +typedef atomic64_t atomic64_unchecked_t;
72206 +#endif
72207 #endif
72208
72209 struct list_head {
72210 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72211 index 5ca0951..ab496a5 100644
72212 --- a/include/linux/uaccess.h
72213 +++ b/include/linux/uaccess.h
72214 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72215 long ret; \
72216 mm_segment_t old_fs = get_fs(); \
72217 \
72218 - set_fs(KERNEL_DS); \
72219 pagefault_disable(); \
72220 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72221 - pagefault_enable(); \
72222 + set_fs(KERNEL_DS); \
72223 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72224 set_fs(old_fs); \
72225 + pagefault_enable(); \
72226 ret; \
72227 })
72228
72229 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72230 index 8e522cbc..aa8572d 100644
72231 --- a/include/linux/uidgid.h
72232 +++ b/include/linux/uidgid.h
72233 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72234
72235 #endif /* CONFIG_USER_NS */
72236
72237 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72238 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72239 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72240 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72241 +
72242 #endif /* _LINUX_UIDGID_H */
72243 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72244 index 99c1b4d..562e6f3 100644
72245 --- a/include/linux/unaligned/access_ok.h
72246 +++ b/include/linux/unaligned/access_ok.h
72247 @@ -4,34 +4,34 @@
72248 #include <linux/kernel.h>
72249 #include <asm/byteorder.h>
72250
72251 -static inline u16 get_unaligned_le16(const void *p)
72252 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72253 {
72254 - return le16_to_cpup((__le16 *)p);
72255 + return le16_to_cpup((const __le16 *)p);
72256 }
72257
72258 -static inline u32 get_unaligned_le32(const void *p)
72259 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72260 {
72261 - return le32_to_cpup((__le32 *)p);
72262 + return le32_to_cpup((const __le32 *)p);
72263 }
72264
72265 -static inline u64 get_unaligned_le64(const void *p)
72266 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72267 {
72268 - return le64_to_cpup((__le64 *)p);
72269 + return le64_to_cpup((const __le64 *)p);
72270 }
72271
72272 -static inline u16 get_unaligned_be16(const void *p)
72273 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72274 {
72275 - return be16_to_cpup((__be16 *)p);
72276 + return be16_to_cpup((const __be16 *)p);
72277 }
72278
72279 -static inline u32 get_unaligned_be32(const void *p)
72280 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72281 {
72282 - return be32_to_cpup((__be32 *)p);
72283 + return be32_to_cpup((const __be32 *)p);
72284 }
72285
72286 -static inline u64 get_unaligned_be64(const void *p)
72287 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72288 {
72289 - return be64_to_cpup((__be64 *)p);
72290 + return be64_to_cpup((const __be64 *)p);
72291 }
72292
72293 static inline void put_unaligned_le16(u16 val, void *p)
72294 diff --git a/include/linux/usb.h b/include/linux/usb.h
72295 index 4d22d0f..8d0e8f8 100644
72296 --- a/include/linux/usb.h
72297 +++ b/include/linux/usb.h
72298 @@ -554,7 +554,7 @@ struct usb_device {
72299 int maxchild;
72300
72301 u32 quirks;
72302 - atomic_t urbnum;
72303 + atomic_unchecked_t urbnum;
72304
72305 unsigned long active_duration;
72306
72307 @@ -1604,7 +1604,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72308
72309 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72310 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72311 - void *data, __u16 size, int timeout);
72312 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72313 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72314 void *data, int len, int *actual_length, int timeout);
72315 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72316 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72317 index c5d36c6..108f4f9 100644
72318 --- a/include/linux/usb/renesas_usbhs.h
72319 +++ b/include/linux/usb/renesas_usbhs.h
72320 @@ -39,7 +39,7 @@ enum {
72321 */
72322 struct renesas_usbhs_driver_callback {
72323 int (*notify_hotplug)(struct platform_device *pdev);
72324 -};
72325 +} __no_const;
72326
72327 /*
72328 * callback functions for platform
72329 diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
72330 index 5209cfe..b6b215f 100644
72331 --- a/include/linux/user_namespace.h
72332 +++ b/include/linux/user_namespace.h
72333 @@ -21,7 +21,7 @@ struct user_namespace {
72334 struct uid_gid_map uid_map;
72335 struct uid_gid_map gid_map;
72336 struct uid_gid_map projid_map;
72337 - struct kref kref;
72338 + atomic_t count;
72339 struct user_namespace *parent;
72340 kuid_t owner;
72341 kgid_t group;
72342 @@ -37,18 +37,18 @@ extern struct user_namespace init_user_ns;
72343 static inline struct user_namespace *get_user_ns(struct user_namespace *ns)
72344 {
72345 if (ns)
72346 - kref_get(&ns->kref);
72347 + atomic_inc(&ns->count);
72348 return ns;
72349 }
72350
72351 extern int create_user_ns(struct cred *new);
72352 extern int unshare_userns(unsigned long unshare_flags, struct cred **new_cred);
72353 -extern void free_user_ns(struct kref *kref);
72354 +extern void free_user_ns(struct user_namespace *ns);
72355
72356 static inline void put_user_ns(struct user_namespace *ns)
72357 {
72358 - if (ns)
72359 - kref_put(&ns->kref, free_user_ns);
72360 + if (ns && atomic_dec_and_test(&ns->count))
72361 + free_user_ns(ns);
72362 }
72363
72364 struct seq_operations;
72365 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72366 index 6f8fbcf..8259001 100644
72367 --- a/include/linux/vermagic.h
72368 +++ b/include/linux/vermagic.h
72369 @@ -25,9 +25,35 @@
72370 #define MODULE_ARCH_VERMAGIC ""
72371 #endif
72372
72373 +#ifdef CONFIG_PAX_REFCOUNT
72374 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72375 +#else
72376 +#define MODULE_PAX_REFCOUNT ""
72377 +#endif
72378 +
72379 +#ifdef CONSTIFY_PLUGIN
72380 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72381 +#else
72382 +#define MODULE_CONSTIFY_PLUGIN ""
72383 +#endif
72384 +
72385 +#ifdef STACKLEAK_PLUGIN
72386 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72387 +#else
72388 +#define MODULE_STACKLEAK_PLUGIN ""
72389 +#endif
72390 +
72391 +#ifdef CONFIG_GRKERNSEC
72392 +#define MODULE_GRSEC "GRSEC "
72393 +#else
72394 +#define MODULE_GRSEC ""
72395 +#endif
72396 +
72397 #define VERMAGIC_STRING \
72398 UTS_RELEASE " " \
72399 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72400 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72401 - MODULE_ARCH_VERMAGIC
72402 + MODULE_ARCH_VERMAGIC \
72403 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72404 + MODULE_GRSEC
72405
72406 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72407 index 6071e91..ca6a489 100644
72408 --- a/include/linux/vmalloc.h
72409 +++ b/include/linux/vmalloc.h
72410 @@ -14,6 +14,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72411 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72412 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72413 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72414 +
72415 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72416 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72417 +#endif
72418 +
72419 /* bits [20..32] reserved for arch specific ioremap internals */
72420
72421 /*
72422 @@ -62,7 +67,7 @@ extern void *vmalloc_32_user(unsigned long size);
72423 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72424 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72425 unsigned long start, unsigned long end, gfp_t gfp_mask,
72426 - pgprot_t prot, int node, const void *caller);
72427 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72428 extern void vfree(const void *addr);
72429
72430 extern void *vmap(struct page **pages, unsigned int count,
72431 @@ -124,8 +129,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72432 extern void free_vm_area(struct vm_struct *area);
72433
72434 /* for /dev/kmem */
72435 -extern long vread(char *buf, char *addr, unsigned long count);
72436 -extern long vwrite(char *buf, char *addr, unsigned long count);
72437 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72438 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72439
72440 /*
72441 * Internals. Dont't use..
72442 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72443 index a13291f..af51fa3 100644
72444 --- a/include/linux/vmstat.h
72445 +++ b/include/linux/vmstat.h
72446 @@ -95,18 +95,18 @@ static inline void vm_events_fold_cpu(int cpu)
72447 /*
72448 * Zone based page accounting with per cpu differentials.
72449 */
72450 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72451 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72452
72453 static inline void zone_page_state_add(long x, struct zone *zone,
72454 enum zone_stat_item item)
72455 {
72456 - atomic_long_add(x, &zone->vm_stat[item]);
72457 - atomic_long_add(x, &vm_stat[item]);
72458 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72459 + atomic_long_add_unchecked(x, &vm_stat[item]);
72460 }
72461
72462 static inline unsigned long global_page_state(enum zone_stat_item item)
72463 {
72464 - long x = atomic_long_read(&vm_stat[item]);
72465 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72466 #ifdef CONFIG_SMP
72467 if (x < 0)
72468 x = 0;
72469 @@ -117,7 +117,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72470 static inline unsigned long zone_page_state(struct zone *zone,
72471 enum zone_stat_item item)
72472 {
72473 - long x = atomic_long_read(&zone->vm_stat[item]);
72474 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72475 #ifdef CONFIG_SMP
72476 if (x < 0)
72477 x = 0;
72478 @@ -134,7 +134,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72479 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72480 enum zone_stat_item item)
72481 {
72482 - long x = atomic_long_read(&zone->vm_stat[item]);
72483 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72484
72485 #ifdef CONFIG_SMP
72486 int cpu;
72487 @@ -226,8 +226,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72488
72489 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72490 {
72491 - atomic_long_inc(&zone->vm_stat[item]);
72492 - atomic_long_inc(&vm_stat[item]);
72493 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72494 + atomic_long_inc_unchecked(&vm_stat[item]);
72495 }
72496
72497 static inline void __inc_zone_page_state(struct page *page,
72498 @@ -238,8 +238,8 @@ static inline void __inc_zone_page_state(struct page *page,
72499
72500 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72501 {
72502 - atomic_long_dec(&zone->vm_stat[item]);
72503 - atomic_long_dec(&vm_stat[item]);
72504 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72505 + atomic_long_dec_unchecked(&vm_stat[item]);
72506 }
72507
72508 static inline void __dec_zone_page_state(struct page *page,
72509 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72510 index fdbafc6..b7ffd47 100644
72511 --- a/include/linux/xattr.h
72512 +++ b/include/linux/xattr.h
72513 @@ -28,7 +28,7 @@ struct xattr_handler {
72514 size_t size, int handler_flags);
72515 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72516 size_t size, int flags, int handler_flags);
72517 -};
72518 +} __do_const;
72519
72520 struct xattr {
72521 char *name;
72522 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72523 index 9c5a6b4..09c9438 100644
72524 --- a/include/linux/zlib.h
72525 +++ b/include/linux/zlib.h
72526 @@ -31,6 +31,7 @@
72527 #define _ZLIB_H
72528
72529 #include <linux/zconf.h>
72530 +#include <linux/compiler.h>
72531
72532 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72533 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72534 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72535
72536 /* basic functions */
72537
72538 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72539 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72540 /*
72541 Returns the number of bytes that needs to be allocated for a per-
72542 stream workspace with the specified parameters. A pointer to this
72543 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72544 index 95d1c91..6798cca 100644
72545 --- a/include/media/v4l2-dev.h
72546 +++ b/include/media/v4l2-dev.h
72547 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72548 int (*mmap) (struct file *, struct vm_area_struct *);
72549 int (*open) (struct file *);
72550 int (*release) (struct file *);
72551 -};
72552 +} __do_const;
72553
72554 /*
72555 * Newer version of video_device, handled by videodev2.c
72556 diff --git a/include/media/v4l2-ioctl.h b/include/media/v4l2-ioctl.h
72557 index 4118ad1..cb7e25f 100644
72558 --- a/include/media/v4l2-ioctl.h
72559 +++ b/include/media/v4l2-ioctl.h
72560 @@ -284,7 +284,6 @@ struct v4l2_ioctl_ops {
72561 bool valid_prio, int cmd, void *arg);
72562 };
72563
72564 -
72565 /* v4l debugging and diagnostics */
72566
72567 /* Debug bitmask flags to be used on V4L2 */
72568 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72569 index adcbb20..62c2559 100644
72570 --- a/include/net/9p/transport.h
72571 +++ b/include/net/9p/transport.h
72572 @@ -57,7 +57,7 @@ struct p9_trans_module {
72573 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72574 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72575 char *, char *, int , int, int, int);
72576 -};
72577 +} __do_const;
72578
72579 void v9fs_register_trans(struct p9_trans_module *m);
72580 void v9fs_unregister_trans(struct p9_trans_module *m);
72581 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72582 index 7588ef4..e62d35f 100644
72583 --- a/include/net/bluetooth/l2cap.h
72584 +++ b/include/net/bluetooth/l2cap.h
72585 @@ -552,7 +552,7 @@ struct l2cap_ops {
72586 void (*defer) (struct l2cap_chan *chan);
72587 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72588 unsigned long len, int nb);
72589 -};
72590 +} __do_const;
72591
72592 struct l2cap_conn {
72593 struct hci_conn *hcon;
72594 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72595 index 9e5425b..8136ffc 100644
72596 --- a/include/net/caif/cfctrl.h
72597 +++ b/include/net/caif/cfctrl.h
72598 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72599 void (*radioset_rsp)(void);
72600 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72601 struct cflayer *client_layer);
72602 -};
72603 +} __no_const;
72604
72605 /* Link Setup Parameters for CAIF-Links. */
72606 struct cfctrl_link_param {
72607 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72608 struct cfctrl {
72609 struct cfsrvl serv;
72610 struct cfctrl_rsp res;
72611 - atomic_t req_seq_no;
72612 - atomic_t rsp_seq_no;
72613 + atomic_unchecked_t req_seq_no;
72614 + atomic_unchecked_t rsp_seq_no;
72615 struct list_head list;
72616 /* Protects from simultaneous access to first_req list */
72617 spinlock_t info_list_lock;
72618 diff --git a/include/net/flow.h b/include/net/flow.h
72619 index 628e11b..4c475df 100644
72620 --- a/include/net/flow.h
72621 +++ b/include/net/flow.h
72622 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72623
72624 extern void flow_cache_flush(void);
72625 extern void flow_cache_flush_deferred(void);
72626 -extern atomic_t flow_cache_genid;
72627 +extern atomic_unchecked_t flow_cache_genid;
72628
72629 #endif
72630 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72631 index bdfbe68..4402ebe 100644
72632 --- a/include/net/genetlink.h
72633 +++ b/include/net/genetlink.h
72634 @@ -118,7 +118,7 @@ struct genl_ops {
72635 struct netlink_callback *cb);
72636 int (*done)(struct netlink_callback *cb);
72637 struct list_head ops_list;
72638 -};
72639 +} __do_const;
72640
72641 extern int genl_register_family(struct genl_family *family);
72642 extern int genl_register_family_with_ops(struct genl_family *family,
72643 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72644 index e5062c9..48a9a4b 100644
72645 --- a/include/net/gro_cells.h
72646 +++ b/include/net/gro_cells.h
72647 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72648 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72649
72650 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72651 - atomic_long_inc(&dev->rx_dropped);
72652 + atomic_long_inc_unchecked(&dev->rx_dropped);
72653 kfree_skb(skb);
72654 return;
72655 }
72656 @@ -73,8 +73,8 @@ static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *de
72657 int i;
72658
72659 gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1;
72660 - gcells->cells = kcalloc(sizeof(struct gro_cell),
72661 - gcells->gro_cells_mask + 1,
72662 + gcells->cells = kcalloc(gcells->gro_cells_mask + 1,
72663 + sizeof(struct gro_cell),
72664 GFP_KERNEL);
72665 if (!gcells->cells)
72666 return -ENOMEM;
72667 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72668 index 1832927..ce39aea 100644
72669 --- a/include/net/inet_connection_sock.h
72670 +++ b/include/net/inet_connection_sock.h
72671 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72672 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72673 int (*bind_conflict)(const struct sock *sk,
72674 const struct inet_bind_bucket *tb, bool relax);
72675 -};
72676 +} __do_const;
72677
72678 /** inet_connection_sock - INET connection oriented sock
72679 *
72680 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72681 index 53f464d..ba76aaa 100644
72682 --- a/include/net/inetpeer.h
72683 +++ b/include/net/inetpeer.h
72684 @@ -47,8 +47,8 @@ struct inet_peer {
72685 */
72686 union {
72687 struct {
72688 - atomic_t rid; /* Frag reception counter */
72689 - atomic_t ip_id_count; /* IP ID for the next packet */
72690 + atomic_unchecked_t rid; /* Frag reception counter */
72691 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72692 };
72693 struct rcu_head rcu;
72694 struct inet_peer *gc_next;
72695 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72696 more++;
72697 inet_peer_refcheck(p);
72698 do {
72699 - old = atomic_read(&p->ip_id_count);
72700 + old = atomic_read_unchecked(&p->ip_id_count);
72701 new = old + more;
72702 if (!new)
72703 new = 1;
72704 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72705 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72706 return new;
72707 }
72708
72709 diff --git a/include/net/ip.h b/include/net/ip.h
72710 index a68f838..74518ab 100644
72711 --- a/include/net/ip.h
72712 +++ b/include/net/ip.h
72713 @@ -202,7 +202,7 @@ extern struct local_ports {
72714 } sysctl_local_ports;
72715 extern void inet_get_local_port_range(int *low, int *high);
72716
72717 -extern unsigned long *sysctl_local_reserved_ports;
72718 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72719 static inline int inet_is_reserved_local_port(int port)
72720 {
72721 return test_bit(port, sysctl_local_reserved_ports);
72722 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72723 index e49db91..76a81de 100644
72724 --- a/include/net/ip_fib.h
72725 +++ b/include/net/ip_fib.h
72726 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72727
72728 #define FIB_RES_SADDR(net, res) \
72729 ((FIB_RES_NH(res).nh_saddr_genid == \
72730 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72731 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72732 FIB_RES_NH(res).nh_saddr : \
72733 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72734 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72735 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72736 index 68c69d5..bdab192 100644
72737 --- a/include/net/ip_vs.h
72738 +++ b/include/net/ip_vs.h
72739 @@ -599,7 +599,7 @@ struct ip_vs_conn {
72740 struct ip_vs_conn *control; /* Master control connection */
72741 atomic_t n_control; /* Number of controlled ones */
72742 struct ip_vs_dest *dest; /* real server */
72743 - atomic_t in_pkts; /* incoming packet counter */
72744 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72745
72746 /* packet transmitter for different forwarding methods. If it
72747 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72748 @@ -737,7 +737,7 @@ struct ip_vs_dest {
72749 __be16 port; /* port number of the server */
72750 union nf_inet_addr addr; /* IP address of the server */
72751 volatile unsigned int flags; /* dest status flags */
72752 - atomic_t conn_flags; /* flags to copy to conn */
72753 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72754 atomic_t weight; /* server weight */
72755
72756 atomic_t refcnt; /* reference counter */
72757 @@ -980,11 +980,11 @@ struct netns_ipvs {
72758 /* ip_vs_lblc */
72759 int sysctl_lblc_expiration;
72760 struct ctl_table_header *lblc_ctl_header;
72761 - struct ctl_table *lblc_ctl_table;
72762 + ctl_table_no_const *lblc_ctl_table;
72763 /* ip_vs_lblcr */
72764 int sysctl_lblcr_expiration;
72765 struct ctl_table_header *lblcr_ctl_header;
72766 - struct ctl_table *lblcr_ctl_table;
72767 + ctl_table_no_const *lblcr_ctl_table;
72768 /* ip_vs_est */
72769 struct list_head est_list; /* estimator list */
72770 spinlock_t est_lock;
72771 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72772 index 80ffde3..968b0f4 100644
72773 --- a/include/net/irda/ircomm_tty.h
72774 +++ b/include/net/irda/ircomm_tty.h
72775 @@ -35,6 +35,7 @@
72776 #include <linux/termios.h>
72777 #include <linux/timer.h>
72778 #include <linux/tty.h> /* struct tty_struct */
72779 +#include <asm/local.h>
72780
72781 #include <net/irda/irias_object.h>
72782 #include <net/irda/ircomm_core.h>
72783 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72784 index cc7c197..9f2da2a 100644
72785 --- a/include/net/iucv/af_iucv.h
72786 +++ b/include/net/iucv/af_iucv.h
72787 @@ -141,7 +141,7 @@ struct iucv_sock {
72788 struct iucv_sock_list {
72789 struct hlist_head head;
72790 rwlock_t lock;
72791 - atomic_t autobind_name;
72792 + atomic_unchecked_t autobind_name;
72793 };
72794
72795 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
72796 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
72797 index df83f69..9b640b8 100644
72798 --- a/include/net/llc_c_ac.h
72799 +++ b/include/net/llc_c_ac.h
72800 @@ -87,7 +87,7 @@
72801 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
72802 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
72803
72804 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72805 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
72806
72807 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
72808 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
72809 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
72810 index 6ca3113..f8026dd 100644
72811 --- a/include/net/llc_c_ev.h
72812 +++ b/include/net/llc_c_ev.h
72813 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
72814 return (struct llc_conn_state_ev *)skb->cb;
72815 }
72816
72817 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72818 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72819 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
72820 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
72821
72822 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
72823 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
72824 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
72825 index 0e79cfb..f46db31 100644
72826 --- a/include/net/llc_c_st.h
72827 +++ b/include/net/llc_c_st.h
72828 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
72829 u8 next_state;
72830 llc_conn_ev_qfyr_t *ev_qualifiers;
72831 llc_conn_action_t *ev_actions;
72832 -};
72833 +} __do_const;
72834
72835 struct llc_conn_state {
72836 u8 current_state;
72837 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
72838 index 37a3bbd..55a4241 100644
72839 --- a/include/net/llc_s_ac.h
72840 +++ b/include/net/llc_s_ac.h
72841 @@ -23,7 +23,7 @@
72842 #define SAP_ACT_TEST_IND 9
72843
72844 /* All action functions must look like this */
72845 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72846 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
72847
72848 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
72849 struct sk_buff *skb);
72850 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
72851 index 567c681..cd73ac0 100644
72852 --- a/include/net/llc_s_st.h
72853 +++ b/include/net/llc_s_st.h
72854 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
72855 llc_sap_ev_t ev;
72856 u8 next_state;
72857 llc_sap_action_t *ev_actions;
72858 -};
72859 +} __do_const;
72860
72861 struct llc_sap_state {
72862 u8 curr_state;
72863 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
72864 index ee50c5e..1bc3b1a 100644
72865 --- a/include/net/mac80211.h
72866 +++ b/include/net/mac80211.h
72867 @@ -3996,7 +3996,7 @@ struct rate_control_ops {
72868 void (*add_sta_debugfs)(void *priv, void *priv_sta,
72869 struct dentry *dir);
72870 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
72871 -};
72872 +} __do_const;
72873
72874 static inline int rate_supported(struct ieee80211_sta *sta,
72875 enum ieee80211_band band,
72876 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
72877 index 0dab173..1b76af0 100644
72878 --- a/include/net/neighbour.h
72879 +++ b/include/net/neighbour.h
72880 @@ -123,7 +123,7 @@ struct neigh_ops {
72881 void (*error_report)(struct neighbour *, struct sk_buff *);
72882 int (*output)(struct neighbour *, struct sk_buff *);
72883 int (*connected_output)(struct neighbour *, struct sk_buff *);
72884 -};
72885 +} __do_const;
72886
72887 struct pneigh_entry {
72888 struct pneigh_entry *next;
72889 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
72890 index de644bc..dfbcc4c 100644
72891 --- a/include/net/net_namespace.h
72892 +++ b/include/net/net_namespace.h
72893 @@ -115,7 +115,7 @@ struct net {
72894 #endif
72895 struct netns_ipvs *ipvs;
72896 struct sock *diag_nlsk;
72897 - atomic_t rt_genid;
72898 + atomic_unchecked_t rt_genid;
72899 };
72900
72901 /*
72902 @@ -272,7 +272,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
72903 #define __net_init __init
72904 #define __net_exit __exit_refok
72905 #define __net_initdata __initdata
72906 +#ifdef CONSTIFY_PLUGIN
72907 #define __net_initconst __initconst
72908 +#else
72909 +#define __net_initconst __initdata
72910 +#endif
72911 #endif
72912
72913 struct pernet_operations {
72914 @@ -282,7 +286,7 @@ struct pernet_operations {
72915 void (*exit_batch)(struct list_head *net_exit_list);
72916 int *id;
72917 size_t size;
72918 -};
72919 +} __do_const;
72920
72921 /*
72922 * Use these carefully. If you implement a network device and it
72923 @@ -330,12 +334,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
72924
72925 static inline int rt_genid(struct net *net)
72926 {
72927 - return atomic_read(&net->rt_genid);
72928 + return atomic_read_unchecked(&net->rt_genid);
72929 }
72930
72931 static inline void rt_genid_bump(struct net *net)
72932 {
72933 - atomic_inc(&net->rt_genid);
72934 + atomic_inc_unchecked(&net->rt_genid);
72935 }
72936
72937 #endif /* __NET_NET_NAMESPACE_H */
72938 diff --git a/include/net/netdma.h b/include/net/netdma.h
72939 index 8ba8ce2..99b7fff 100644
72940 --- a/include/net/netdma.h
72941 +++ b/include/net/netdma.h
72942 @@ -24,7 +24,7 @@
72943 #include <linux/dmaengine.h>
72944 #include <linux/skbuff.h>
72945
72946 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72947 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
72948 struct sk_buff *skb, int offset, struct iovec *to,
72949 size_t len, struct dma_pinned_list *pinned_list);
72950
72951 diff --git a/include/net/netlink.h b/include/net/netlink.h
72952 index 9690b0f..87aded7 100644
72953 --- a/include/net/netlink.h
72954 +++ b/include/net/netlink.h
72955 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
72956 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
72957 {
72958 if (mark)
72959 - skb_trim(skb, (unsigned char *) mark - skb->data);
72960 + skb_trim(skb, (const unsigned char *) mark - skb->data);
72961 }
72962
72963 /**
72964 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
72965 index 923cb20..deae816 100644
72966 --- a/include/net/netns/conntrack.h
72967 +++ b/include/net/netns/conntrack.h
72968 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
72969 struct nf_proto_net {
72970 #ifdef CONFIG_SYSCTL
72971 struct ctl_table_header *ctl_table_header;
72972 - struct ctl_table *ctl_table;
72973 + ctl_table_no_const *ctl_table;
72974 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
72975 struct ctl_table_header *ctl_compat_header;
72976 - struct ctl_table *ctl_compat_table;
72977 + ctl_table_no_const *ctl_compat_table;
72978 #endif
72979 #endif
72980 unsigned int users;
72981 @@ -58,7 +58,7 @@ struct nf_ip_net {
72982 struct nf_icmp_net icmpv6;
72983 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
72984 struct ctl_table_header *ctl_table_header;
72985 - struct ctl_table *ctl_table;
72986 + ctl_table_no_const *ctl_table;
72987 #endif
72988 };
72989
72990 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
72991 index 2ae2b83..dbdc85e 100644
72992 --- a/include/net/netns/ipv4.h
72993 +++ b/include/net/netns/ipv4.h
72994 @@ -64,7 +64,7 @@ struct netns_ipv4 {
72995 kgid_t sysctl_ping_group_range[2];
72996 long sysctl_tcp_mem[3];
72997
72998 - atomic_t dev_addr_genid;
72999 + atomic_unchecked_t dev_addr_genid;
73000
73001 #ifdef CONFIG_IP_MROUTE
73002 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73003 diff --git a/include/net/protocol.h b/include/net/protocol.h
73004 index 047c047..b9dad15 100644
73005 --- a/include/net/protocol.h
73006 +++ b/include/net/protocol.h
73007 @@ -44,7 +44,7 @@ struct net_protocol {
73008 void (*err_handler)(struct sk_buff *skb, u32 info);
73009 unsigned int no_policy:1,
73010 netns_ok:1;
73011 -};
73012 +} __do_const;
73013
73014 #if IS_ENABLED(CONFIG_IPV6)
73015 struct inet6_protocol {
73016 @@ -57,7 +57,7 @@ struct inet6_protocol {
73017 u8 type, u8 code, int offset,
73018 __be32 info);
73019 unsigned int flags; /* INET6_PROTO_xxx */
73020 -};
73021 +} __do_const;
73022
73023 #define INET6_PROTO_NOPOLICY 0x1
73024 #define INET6_PROTO_FINAL 0x2
73025 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73026 index 5a15fab..d799ea7 100644
73027 --- a/include/net/rtnetlink.h
73028 +++ b/include/net/rtnetlink.h
73029 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73030 const struct net_device *dev);
73031 unsigned int (*get_num_tx_queues)(void);
73032 unsigned int (*get_num_rx_queues)(void);
73033 -};
73034 +} __do_const;
73035
73036 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73037 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73038 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73039 index 7fdf298..197e9f7 100644
73040 --- a/include/net/sctp/sctp.h
73041 +++ b/include/net/sctp/sctp.h
73042 @@ -330,9 +330,9 @@ do { \
73043
73044 #else /* SCTP_DEBUG */
73045
73046 -#define SCTP_DEBUG_PRINTK(whatever...)
73047 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73048 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73049 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73050 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73051 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73052 #define SCTP_ENABLE_DEBUG
73053 #define SCTP_DISABLE_DEBUG
73054 #define SCTP_ASSERT(expr, str, func)
73055 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73056 index 2a82d13..62a31c2 100644
73057 --- a/include/net/sctp/sm.h
73058 +++ b/include/net/sctp/sm.h
73059 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73060 typedef struct {
73061 sctp_state_fn_t *fn;
73062 const char *name;
73063 -} sctp_sm_table_entry_t;
73064 +} __do_const sctp_sm_table_entry_t;
73065
73066 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73067 * currently in use.
73068 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73069 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73070
73071 /* Extern declarations for major data structures. */
73072 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73073 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73074
73075
73076 /* Get the size of a DATA chunk payload. */
73077 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73078 index fdeb85a..1329d95 100644
73079 --- a/include/net/sctp/structs.h
73080 +++ b/include/net/sctp/structs.h
73081 @@ -517,7 +517,7 @@ struct sctp_pf {
73082 struct sctp_association *asoc);
73083 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73084 struct sctp_af *af;
73085 -};
73086 +} __do_const;
73087
73088
73089 /* Structure to track chunk fragments that have been acked, but peer
73090 diff --git a/include/net/sock.h b/include/net/sock.h
73091 index 25afaa0..8bb0070 100644
73092 --- a/include/net/sock.h
73093 +++ b/include/net/sock.h
73094 @@ -322,7 +322,7 @@ struct sock {
73095 #ifdef CONFIG_RPS
73096 __u32 sk_rxhash;
73097 #endif
73098 - atomic_t sk_drops;
73099 + atomic_unchecked_t sk_drops;
73100 int sk_rcvbuf;
73101
73102 struct sk_filter __rcu *sk_filter;
73103 @@ -1781,7 +1781,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73104 }
73105
73106 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73107 - char __user *from, char *to,
73108 + char __user *from, unsigned char *to,
73109 int copy, int offset)
73110 {
73111 if (skb->ip_summed == CHECKSUM_NONE) {
73112 @@ -2040,7 +2040,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73113 }
73114 }
73115
73116 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73117 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73118
73119 /**
73120 * sk_page_frag - return an appropriate page_frag
73121 diff --git a/include/net/tcp.h b/include/net/tcp.h
73122 index aed42c7..43890c6 100644
73123 --- a/include/net/tcp.h
73124 +++ b/include/net/tcp.h
73125 @@ -530,7 +530,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73126 extern void tcp_xmit_retransmit_queue(struct sock *);
73127 extern void tcp_simple_retransmit(struct sock *);
73128 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73129 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73130 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73131
73132 extern void tcp_send_probe0(struct sock *);
73133 extern void tcp_send_partial(struct sock *);
73134 @@ -701,8 +701,8 @@ struct tcp_skb_cb {
73135 struct inet6_skb_parm h6;
73136 #endif
73137 } header; /* For incoming frames */
73138 - __u32 seq; /* Starting sequence number */
73139 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73140 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73141 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73142 __u32 when; /* used to compute rtt's */
73143 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73144
73145 @@ -716,7 +716,7 @@ struct tcp_skb_cb {
73146
73147 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73148 /* 1 byte hole */
73149 - __u32 ack_seq; /* Sequence number ACK'd */
73150 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73151 };
73152
73153 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73154 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73155 index 63445ed..d6fc34f 100644
73156 --- a/include/net/xfrm.h
73157 +++ b/include/net/xfrm.h
73158 @@ -304,7 +304,7 @@ struct xfrm_policy_afinfo {
73159 struct net_device *dev,
73160 const struct flowi *fl);
73161 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73162 -};
73163 +} __do_const;
73164
73165 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73166 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73167 @@ -340,7 +340,7 @@ struct xfrm_state_afinfo {
73168 struct sk_buff *skb);
73169 int (*transport_finish)(struct sk_buff *skb,
73170 int async);
73171 -};
73172 +} __do_const;
73173
73174 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73175 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73176 @@ -423,7 +423,7 @@ struct xfrm_mode {
73177 struct module *owner;
73178 unsigned int encap;
73179 int flags;
73180 -};
73181 +} __do_const;
73182
73183 /* Flags for xfrm_mode. */
73184 enum {
73185 @@ -514,7 +514,7 @@ struct xfrm_policy {
73186 struct timer_list timer;
73187
73188 struct flow_cache_object flo;
73189 - atomic_t genid;
73190 + atomic_unchecked_t genid;
73191 u32 priority;
73192 u32 index;
73193 struct xfrm_mark mark;
73194 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73195 index 1a046b1..ee0bef0 100644
73196 --- a/include/rdma/iw_cm.h
73197 +++ b/include/rdma/iw_cm.h
73198 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73199 int backlog);
73200
73201 int (*destroy_listen)(struct iw_cm_id *cm_id);
73202 -};
73203 +} __no_const;
73204
73205 /**
73206 * iw_create_cm_id - Create an IW CM identifier.
73207 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73208 index 399162b..b337f1a 100644
73209 --- a/include/scsi/libfc.h
73210 +++ b/include/scsi/libfc.h
73211 @@ -762,6 +762,7 @@ struct libfc_function_template {
73212 */
73213 void (*disc_stop_final) (struct fc_lport *);
73214 };
73215 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73216
73217 /**
73218 * struct fc_disc - Discovery context
73219 @@ -866,7 +867,7 @@ struct fc_lport {
73220 struct fc_vport *vport;
73221
73222 /* Operational Information */
73223 - struct libfc_function_template tt;
73224 + libfc_function_template_no_const tt;
73225 u8 link_up;
73226 u8 qfull;
73227 enum fc_lport_state state;
73228 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73229 index e65c62e..aa2e5a2 100644
73230 --- a/include/scsi/scsi_device.h
73231 +++ b/include/scsi/scsi_device.h
73232 @@ -170,9 +170,9 @@ struct scsi_device {
73233 unsigned int max_device_blocked; /* what device_blocked counts down from */
73234 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73235
73236 - atomic_t iorequest_cnt;
73237 - atomic_t iodone_cnt;
73238 - atomic_t ioerr_cnt;
73239 + atomic_unchecked_t iorequest_cnt;
73240 + atomic_unchecked_t iodone_cnt;
73241 + atomic_unchecked_t ioerr_cnt;
73242
73243 struct device sdev_gendev,
73244 sdev_dev;
73245 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73246 index b797e8f..8e2c3aa 100644
73247 --- a/include/scsi/scsi_transport_fc.h
73248 +++ b/include/scsi/scsi_transport_fc.h
73249 @@ -751,7 +751,8 @@ struct fc_function_template {
73250 unsigned long show_host_system_hostname:1;
73251
73252 unsigned long disable_target_scan:1;
73253 -};
73254 +} __do_const;
73255 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73256
73257
73258 /**
73259 diff --git a/include/sound/soc.h b/include/sound/soc.h
73260 index bc56738..a4be132 100644
73261 --- a/include/sound/soc.h
73262 +++ b/include/sound/soc.h
73263 @@ -771,7 +771,7 @@ struct snd_soc_codec_driver {
73264 /* probe ordering - for components with runtime dependencies */
73265 int probe_order;
73266 int remove_order;
73267 -};
73268 +} __do_const;
73269
73270 /* SoC platform interface */
73271 struct snd_soc_platform_driver {
73272 @@ -817,7 +817,7 @@ struct snd_soc_platform_driver {
73273 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73274 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73275 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73276 -};
73277 +} __do_const;
73278
73279 struct snd_soc_platform {
73280 const char *name;
73281 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73282 index 663e34a..91b306a 100644
73283 --- a/include/target/target_core_base.h
73284 +++ b/include/target/target_core_base.h
73285 @@ -654,7 +654,7 @@ struct se_device {
73286 spinlock_t stats_lock;
73287 /* Active commands on this virtual SE device */
73288 atomic_t simple_cmds;
73289 - atomic_t dev_ordered_id;
73290 + atomic_unchecked_t dev_ordered_id;
73291 atomic_t dev_ordered_sync;
73292 atomic_t dev_qf_count;
73293 int export_count;
73294 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73295 new file mode 100644
73296 index 0000000..fb634b7
73297 --- /dev/null
73298 +++ b/include/trace/events/fs.h
73299 @@ -0,0 +1,53 @@
73300 +#undef TRACE_SYSTEM
73301 +#define TRACE_SYSTEM fs
73302 +
73303 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73304 +#define _TRACE_FS_H
73305 +
73306 +#include <linux/fs.h>
73307 +#include <linux/tracepoint.h>
73308 +
73309 +TRACE_EVENT(do_sys_open,
73310 +
73311 + TP_PROTO(const char *filename, int flags, int mode),
73312 +
73313 + TP_ARGS(filename, flags, mode),
73314 +
73315 + TP_STRUCT__entry(
73316 + __string( filename, filename )
73317 + __field( int, flags )
73318 + __field( int, mode )
73319 + ),
73320 +
73321 + TP_fast_assign(
73322 + __assign_str(filename, filename);
73323 + __entry->flags = flags;
73324 + __entry->mode = mode;
73325 + ),
73326 +
73327 + TP_printk("\"%s\" %x %o",
73328 + __get_str(filename), __entry->flags, __entry->mode)
73329 +);
73330 +
73331 +TRACE_EVENT(open_exec,
73332 +
73333 + TP_PROTO(const char *filename),
73334 +
73335 + TP_ARGS(filename),
73336 +
73337 + TP_STRUCT__entry(
73338 + __string( filename, filename )
73339 + ),
73340 +
73341 + TP_fast_assign(
73342 + __assign_str(filename, filename);
73343 + ),
73344 +
73345 + TP_printk("\"%s\"",
73346 + __get_str(filename))
73347 +);
73348 +
73349 +#endif /* _TRACE_FS_H */
73350 +
73351 +/* This part must be outside protection */
73352 +#include <trace/define_trace.h>
73353 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73354 index 1c09820..7f5ec79 100644
73355 --- a/include/trace/events/irq.h
73356 +++ b/include/trace/events/irq.h
73357 @@ -36,7 +36,7 @@ struct softirq_action;
73358 */
73359 TRACE_EVENT(irq_handler_entry,
73360
73361 - TP_PROTO(int irq, struct irqaction *action),
73362 + TP_PROTO(int irq, const struct irqaction *action),
73363
73364 TP_ARGS(irq, action),
73365
73366 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73367 */
73368 TRACE_EVENT(irq_handler_exit,
73369
73370 - TP_PROTO(int irq, struct irqaction *action, int ret),
73371 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73372
73373 TP_ARGS(irq, action, ret),
73374
73375 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73376 index 7caf44c..23c6f27 100644
73377 --- a/include/uapi/linux/a.out.h
73378 +++ b/include/uapi/linux/a.out.h
73379 @@ -39,6 +39,14 @@ enum machine_type {
73380 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73381 };
73382
73383 +/* Constants for the N_FLAGS field */
73384 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73385 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73386 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73387 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73388 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73389 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73390 +
73391 #if !defined (N_MAGIC)
73392 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73393 #endif
73394 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73395 index d876736..ccce5c0 100644
73396 --- a/include/uapi/linux/byteorder/little_endian.h
73397 +++ b/include/uapi/linux/byteorder/little_endian.h
73398 @@ -42,51 +42,51 @@
73399
73400 static inline __le64 __cpu_to_le64p(const __u64 *p)
73401 {
73402 - return (__force __le64)*p;
73403 + return (__force const __le64)*p;
73404 }
73405 -static inline __u64 __le64_to_cpup(const __le64 *p)
73406 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73407 {
73408 - return (__force __u64)*p;
73409 + return (__force const __u64)*p;
73410 }
73411 static inline __le32 __cpu_to_le32p(const __u32 *p)
73412 {
73413 - return (__force __le32)*p;
73414 + return (__force const __le32)*p;
73415 }
73416 static inline __u32 __le32_to_cpup(const __le32 *p)
73417 {
73418 - return (__force __u32)*p;
73419 + return (__force const __u32)*p;
73420 }
73421 static inline __le16 __cpu_to_le16p(const __u16 *p)
73422 {
73423 - return (__force __le16)*p;
73424 + return (__force const __le16)*p;
73425 }
73426 static inline __u16 __le16_to_cpup(const __le16 *p)
73427 {
73428 - return (__force __u16)*p;
73429 + return (__force const __u16)*p;
73430 }
73431 static inline __be64 __cpu_to_be64p(const __u64 *p)
73432 {
73433 - return (__force __be64)__swab64p(p);
73434 + return (__force const __be64)__swab64p(p);
73435 }
73436 static inline __u64 __be64_to_cpup(const __be64 *p)
73437 {
73438 - return __swab64p((__u64 *)p);
73439 + return __swab64p((const __u64 *)p);
73440 }
73441 static inline __be32 __cpu_to_be32p(const __u32 *p)
73442 {
73443 - return (__force __be32)__swab32p(p);
73444 + return (__force const __be32)__swab32p(p);
73445 }
73446 -static inline __u32 __be32_to_cpup(const __be32 *p)
73447 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73448 {
73449 - return __swab32p((__u32 *)p);
73450 + return __swab32p((const __u32 *)p);
73451 }
73452 static inline __be16 __cpu_to_be16p(const __u16 *p)
73453 {
73454 - return (__force __be16)__swab16p(p);
73455 + return (__force const __be16)__swab16p(p);
73456 }
73457 static inline __u16 __be16_to_cpup(const __be16 *p)
73458 {
73459 - return __swab16p((__u16 *)p);
73460 + return __swab16p((const __u16 *)p);
73461 }
73462 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73463 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73464 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73465 index 126a817..d522bd1 100644
73466 --- a/include/uapi/linux/elf.h
73467 +++ b/include/uapi/linux/elf.h
73468 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73469 #define PT_GNU_EH_FRAME 0x6474e550
73470
73471 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73472 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73473 +
73474 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73475 +
73476 +/* Constants for the e_flags field */
73477 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73478 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73479 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73480 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73481 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73482 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73483
73484 /*
73485 * Extended Numbering
73486 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73487 #define DT_DEBUG 21
73488 #define DT_TEXTREL 22
73489 #define DT_JMPREL 23
73490 +#define DT_FLAGS 30
73491 + #define DF_TEXTREL 0x00000004
73492 #define DT_ENCODING 32
73493 #define OLD_DT_LOOS 0x60000000
73494 #define DT_LOOS 0x6000000d
73495 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73496 #define PF_W 0x2
73497 #define PF_X 0x1
73498
73499 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73500 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73501 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73502 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73503 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73504 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73505 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73506 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73507 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73508 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73509 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73510 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73511 +
73512 typedef struct elf32_phdr{
73513 Elf32_Word p_type;
73514 Elf32_Off p_offset;
73515 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73516 #define EI_OSABI 7
73517 #define EI_PAD 8
73518
73519 +#define EI_PAX 14
73520 +
73521 #define ELFMAG0 0x7f /* EI_MAG */
73522 #define ELFMAG1 'E'
73523 #define ELFMAG2 'L'
73524 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73525 index aa169c4..6a2771d 100644
73526 --- a/include/uapi/linux/personality.h
73527 +++ b/include/uapi/linux/personality.h
73528 @@ -30,6 +30,7 @@ enum {
73529 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73530 ADDR_NO_RANDOMIZE | \
73531 ADDR_COMPAT_LAYOUT | \
73532 + ADDR_LIMIT_3GB | \
73533 MMAP_PAGE_ZERO)
73534
73535 /*
73536 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73537 index 7530e74..e714828 100644
73538 --- a/include/uapi/linux/screen_info.h
73539 +++ b/include/uapi/linux/screen_info.h
73540 @@ -43,7 +43,8 @@ struct screen_info {
73541 __u16 pages; /* 0x32 */
73542 __u16 vesa_attributes; /* 0x34 */
73543 __u32 capabilities; /* 0x36 */
73544 - __u8 _reserved[6]; /* 0x3a */
73545 + __u16 vesapm_size; /* 0x3a */
73546 + __u8 _reserved[4]; /* 0x3c */
73547 } __attribute__((packed));
73548
73549 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73550 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73551 index 0e011eb..82681b1 100644
73552 --- a/include/uapi/linux/swab.h
73553 +++ b/include/uapi/linux/swab.h
73554 @@ -43,7 +43,7 @@
73555 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73556 */
73557
73558 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73559 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73560 {
73561 #ifdef __HAVE_BUILTIN_BSWAP16__
73562 return __builtin_bswap16(val);
73563 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73564 #endif
73565 }
73566
73567 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73568 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73569 {
73570 #ifdef __HAVE_BUILTIN_BSWAP32__
73571 return __builtin_bswap32(val);
73572 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73573 #endif
73574 }
73575
73576 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73577 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73578 {
73579 #ifdef __HAVE_BUILTIN_BSWAP64__
73580 return __builtin_bswap64(val);
73581 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73582 index 6d67213..8dab561 100644
73583 --- a/include/uapi/linux/sysctl.h
73584 +++ b/include/uapi/linux/sysctl.h
73585 @@ -155,7 +155,11 @@ enum
73586 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73587 };
73588
73589 -
73590 +#ifdef CONFIG_PAX_SOFTMODE
73591 +enum {
73592 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73593 +};
73594 +#endif
73595
73596 /* CTL_VM names: */
73597 enum
73598 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73599 index 26607bd..588b65f 100644
73600 --- a/include/uapi/linux/xattr.h
73601 +++ b/include/uapi/linux/xattr.h
73602 @@ -60,5 +60,9 @@
73603 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73604 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73605
73606 +/* User namespace */
73607 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73608 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73609 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73610
73611 #endif /* _UAPI_LINUX_XATTR_H */
73612 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73613 index f9466fa..f4e2b81 100644
73614 --- a/include/video/udlfb.h
73615 +++ b/include/video/udlfb.h
73616 @@ -53,10 +53,10 @@ struct dlfb_data {
73617 u32 pseudo_palette[256];
73618 int blank_mode; /*one of FB_BLANK_ */
73619 /* blit-only rendering path metrics, exposed through sysfs */
73620 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73621 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73622 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73623 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73624 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73625 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73626 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73627 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73628 };
73629
73630 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73631 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73632 index 0993a22..32ba2fe 100644
73633 --- a/include/video/uvesafb.h
73634 +++ b/include/video/uvesafb.h
73635 @@ -177,6 +177,7 @@ struct uvesafb_par {
73636 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73637 u8 pmi_setpal; /* PMI for palette changes */
73638 u16 *pmi_base; /* protected mode interface location */
73639 + u8 *pmi_code; /* protected mode code location */
73640 void *pmi_start;
73641 void *pmi_pal;
73642 u8 *vbe_state_orig; /*
73643 diff --git a/init/Kconfig b/init/Kconfig
73644 index be8b7f5..1eeca9b 100644
73645 --- a/init/Kconfig
73646 +++ b/init/Kconfig
73647 @@ -990,6 +990,7 @@ endif # CGROUPS
73648
73649 config CHECKPOINT_RESTORE
73650 bool "Checkpoint/restore support" if EXPERT
73651 + depends on !GRKERNSEC
73652 default n
73653 help
73654 Enables additional kernel features in a sake of checkpoint/restore.
73655 @@ -1468,7 +1469,7 @@ config SLUB_DEBUG
73656
73657 config COMPAT_BRK
73658 bool "Disable heap randomization"
73659 - default y
73660 + default n
73661 help
73662 Randomizing heap placement makes heap exploits harder, but it
73663 also breaks ancient binaries (including anything libc5 based).
73664 @@ -1711,7 +1712,7 @@ config INIT_ALL_POSSIBLE
73665 config STOP_MACHINE
73666 bool
73667 default y
73668 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73669 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73670 help
73671 Need stop_machine() primitive.
73672
73673 diff --git a/init/Makefile b/init/Makefile
73674 index 7bc47ee..6da2dc7 100644
73675 --- a/init/Makefile
73676 +++ b/init/Makefile
73677 @@ -2,6 +2,9 @@
73678 # Makefile for the linux kernel.
73679 #
73680
73681 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73682 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73683 +
73684 obj-y := main.o version.o mounts.o
73685 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73686 obj-y += noinitramfs.o
73687 diff --git a/init/do_mounts.c b/init/do_mounts.c
73688 index 1d1b634..a1c810f 100644
73689 --- a/init/do_mounts.c
73690 +++ b/init/do_mounts.c
73691 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73692 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73693 {
73694 struct super_block *s;
73695 - int err = sys_mount(name, "/root", fs, flags, data);
73696 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73697 if (err)
73698 return err;
73699
73700 - sys_chdir("/root");
73701 + sys_chdir((const char __force_user *)"/root");
73702 s = current->fs->pwd.dentry->d_sb;
73703 ROOT_DEV = s->s_dev;
73704 printk(KERN_INFO
73705 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73706 va_start(args, fmt);
73707 vsprintf(buf, fmt, args);
73708 va_end(args);
73709 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73710 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73711 if (fd >= 0) {
73712 sys_ioctl(fd, FDEJECT, 0);
73713 sys_close(fd);
73714 }
73715 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73716 - fd = sys_open("/dev/console", O_RDWR, 0);
73717 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73718 if (fd >= 0) {
73719 sys_ioctl(fd, TCGETS, (long)&termios);
73720 termios.c_lflag &= ~ICANON;
73721 sys_ioctl(fd, TCSETSF, (long)&termios);
73722 - sys_read(fd, &c, 1);
73723 + sys_read(fd, (char __user *)&c, 1);
73724 termios.c_lflag |= ICANON;
73725 sys_ioctl(fd, TCSETSF, (long)&termios);
73726 sys_close(fd);
73727 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73728 mount_root();
73729 out:
73730 devtmpfs_mount("dev");
73731 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73732 - sys_chroot(".");
73733 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73734 + sys_chroot((const char __force_user *)".");
73735 }
73736 diff --git a/init/do_mounts.h b/init/do_mounts.h
73737 index f5b978a..69dbfe8 100644
73738 --- a/init/do_mounts.h
73739 +++ b/init/do_mounts.h
73740 @@ -15,15 +15,15 @@ extern int root_mountflags;
73741
73742 static inline int create_dev(char *name, dev_t dev)
73743 {
73744 - sys_unlink(name);
73745 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73746 + sys_unlink((char __force_user *)name);
73747 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73748 }
73749
73750 #if BITS_PER_LONG == 32
73751 static inline u32 bstat(char *name)
73752 {
73753 struct stat64 stat;
73754 - if (sys_stat64(name, &stat) != 0)
73755 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73756 return 0;
73757 if (!S_ISBLK(stat.st_mode))
73758 return 0;
73759 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73760 static inline u32 bstat(char *name)
73761 {
73762 struct stat stat;
73763 - if (sys_newstat(name, &stat) != 0)
73764 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73765 return 0;
73766 if (!S_ISBLK(stat.st_mode))
73767 return 0;
73768 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
73769 index f9acf71..1e19144 100644
73770 --- a/init/do_mounts_initrd.c
73771 +++ b/init/do_mounts_initrd.c
73772 @@ -58,8 +58,8 @@ static void __init handle_initrd(void)
73773 create_dev("/dev/root.old", Root_RAM0);
73774 /* mount initrd on rootfs' /root */
73775 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
73776 - sys_mkdir("/old", 0700);
73777 - sys_chdir("/old");
73778 + sys_mkdir((const char __force_user *)"/old", 0700);
73779 + sys_chdir((const char __force_user *)"/old");
73780
73781 /*
73782 * In case that a resume from disk is carried out by linuxrc or one of
73783 @@ -73,31 +73,31 @@ static void __init handle_initrd(void)
73784 current->flags &= ~PF_FREEZER_SKIP;
73785
73786 /* move initrd to rootfs' /old */
73787 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
73788 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
73789 /* switch root and cwd back to / of rootfs */
73790 - sys_chroot("..");
73791 + sys_chroot((const char __force_user *)"..");
73792
73793 if (new_decode_dev(real_root_dev) == Root_RAM0) {
73794 - sys_chdir("/old");
73795 + sys_chdir((const char __force_user *)"/old");
73796 return;
73797 }
73798
73799 - sys_chdir("/");
73800 + sys_chdir((const char __force_user *)"/");
73801 ROOT_DEV = new_decode_dev(real_root_dev);
73802 mount_root();
73803
73804 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
73805 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
73806 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
73807 if (!error)
73808 printk("okay\n");
73809 else {
73810 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
73811 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
73812 if (error == -ENOENT)
73813 printk("/initrd does not exist. Ignored.\n");
73814 else
73815 printk("failed\n");
73816 printk(KERN_NOTICE "Unmounting old root\n");
73817 - sys_umount("/old", MNT_DETACH);
73818 + sys_umount((char __force_user *)"/old", MNT_DETACH);
73819 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
73820 if (fd < 0) {
73821 error = fd;
73822 @@ -120,11 +120,11 @@ int __init initrd_load(void)
73823 * mounted in the normal path.
73824 */
73825 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
73826 - sys_unlink("/initrd.image");
73827 + sys_unlink((const char __force_user *)"/initrd.image");
73828 handle_initrd();
73829 return 1;
73830 }
73831 }
73832 - sys_unlink("/initrd.image");
73833 + sys_unlink((const char __force_user *)"/initrd.image");
73834 return 0;
73835 }
73836 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
73837 index 8cb6db5..d729f50 100644
73838 --- a/init/do_mounts_md.c
73839 +++ b/init/do_mounts_md.c
73840 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
73841 partitioned ? "_d" : "", minor,
73842 md_setup_args[ent].device_names);
73843
73844 - fd = sys_open(name, 0, 0);
73845 + fd = sys_open((char __force_user *)name, 0, 0);
73846 if (fd < 0) {
73847 printk(KERN_ERR "md: open failed - cannot start "
73848 "array %s\n", name);
73849 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
73850 * array without it
73851 */
73852 sys_close(fd);
73853 - fd = sys_open(name, 0, 0);
73854 + fd = sys_open((char __force_user *)name, 0, 0);
73855 sys_ioctl(fd, BLKRRPART, 0);
73856 }
73857 sys_close(fd);
73858 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
73859
73860 wait_for_device_probe();
73861
73862 - fd = sys_open("/dev/md0", 0, 0);
73863 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
73864 if (fd >= 0) {
73865 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
73866 sys_close(fd);
73867 diff --git a/init/init_task.c b/init/init_task.c
73868 index 8b2f399..f0797c9 100644
73869 --- a/init/init_task.c
73870 +++ b/init/init_task.c
73871 @@ -20,5 +20,9 @@ EXPORT_SYMBOL(init_task);
73872 * Initial thread structure. Alignment of this is handled by a special
73873 * linker map entry.
73874 */
73875 +#ifdef CONFIG_X86
73876 +union thread_union init_thread_union __init_task_data;
73877 +#else
73878 union thread_union init_thread_union __init_task_data =
73879 { INIT_THREAD_INFO(init_task) };
73880 +#endif
73881 diff --git a/init/initramfs.c b/init/initramfs.c
73882 index 84c6bf1..8899338 100644
73883 --- a/init/initramfs.c
73884 +++ b/init/initramfs.c
73885 @@ -84,7 +84,7 @@ static void __init free_hash(void)
73886 }
73887 }
73888
73889 -static long __init do_utime(char *filename, time_t mtime)
73890 +static long __init do_utime(char __force_user *filename, time_t mtime)
73891 {
73892 struct timespec t[2];
73893
73894 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
73895 struct dir_entry *de, *tmp;
73896 list_for_each_entry_safe(de, tmp, &dir_list, list) {
73897 list_del(&de->list);
73898 - do_utime(de->name, de->mtime);
73899 + do_utime((char __force_user *)de->name, de->mtime);
73900 kfree(de->name);
73901 kfree(de);
73902 }
73903 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
73904 if (nlink >= 2) {
73905 char *old = find_link(major, minor, ino, mode, collected);
73906 if (old)
73907 - return (sys_link(old, collected) < 0) ? -1 : 1;
73908 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
73909 }
73910 return 0;
73911 }
73912 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
73913 {
73914 struct stat st;
73915
73916 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
73917 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
73918 if (S_ISDIR(st.st_mode))
73919 - sys_rmdir(path);
73920 + sys_rmdir((char __force_user *)path);
73921 else
73922 - sys_unlink(path);
73923 + sys_unlink((char __force_user *)path);
73924 }
73925 }
73926
73927 @@ -315,7 +315,7 @@ static int __init do_name(void)
73928 int openflags = O_WRONLY|O_CREAT;
73929 if (ml != 1)
73930 openflags |= O_TRUNC;
73931 - wfd = sys_open(collected, openflags, mode);
73932 + wfd = sys_open((char __force_user *)collected, openflags, mode);
73933
73934 if (wfd >= 0) {
73935 sys_fchown(wfd, uid, gid);
73936 @@ -327,17 +327,17 @@ static int __init do_name(void)
73937 }
73938 }
73939 } else if (S_ISDIR(mode)) {
73940 - sys_mkdir(collected, mode);
73941 - sys_chown(collected, uid, gid);
73942 - sys_chmod(collected, mode);
73943 + sys_mkdir((char __force_user *)collected, mode);
73944 + sys_chown((char __force_user *)collected, uid, gid);
73945 + sys_chmod((char __force_user *)collected, mode);
73946 dir_add(collected, mtime);
73947 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
73948 S_ISFIFO(mode) || S_ISSOCK(mode)) {
73949 if (maybe_link() == 0) {
73950 - sys_mknod(collected, mode, rdev);
73951 - sys_chown(collected, uid, gid);
73952 - sys_chmod(collected, mode);
73953 - do_utime(collected, mtime);
73954 + sys_mknod((char __force_user *)collected, mode, rdev);
73955 + sys_chown((char __force_user *)collected, uid, gid);
73956 + sys_chmod((char __force_user *)collected, mode);
73957 + do_utime((char __force_user *)collected, mtime);
73958 }
73959 }
73960 return 0;
73961 @@ -346,15 +346,15 @@ static int __init do_name(void)
73962 static int __init do_copy(void)
73963 {
73964 if (count >= body_len) {
73965 - sys_write(wfd, victim, body_len);
73966 + sys_write(wfd, (char __force_user *)victim, body_len);
73967 sys_close(wfd);
73968 - do_utime(vcollected, mtime);
73969 + do_utime((char __force_user *)vcollected, mtime);
73970 kfree(vcollected);
73971 eat(body_len);
73972 state = SkipIt;
73973 return 0;
73974 } else {
73975 - sys_write(wfd, victim, count);
73976 + sys_write(wfd, (char __force_user *)victim, count);
73977 body_len -= count;
73978 eat(count);
73979 return 1;
73980 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
73981 {
73982 collected[N_ALIGN(name_len) + body_len] = '\0';
73983 clean_path(collected, 0);
73984 - sys_symlink(collected + N_ALIGN(name_len), collected);
73985 - sys_lchown(collected, uid, gid);
73986 - do_utime(collected, mtime);
73987 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
73988 + sys_lchown((char __force_user *)collected, uid, gid);
73989 + do_utime((char __force_user *)collected, mtime);
73990 state = SkipIt;
73991 next_state = Reset;
73992 return 0;
73993 diff --git a/init/main.c b/init/main.c
73994 index cee4b5c..360e10a 100644
73995 --- a/init/main.c
73996 +++ b/init/main.c
73997 @@ -96,6 +96,8 @@ static inline void mark_rodata_ro(void) { }
73998 extern void tc_init(void);
73999 #endif
74000
74001 +extern void grsecurity_init(void);
74002 +
74003 /*
74004 * Debug helper: via this flag we know that we are in 'early bootup code'
74005 * where only the boot processor is running with IRQ disabled. This means
74006 @@ -149,6 +151,61 @@ static int __init set_reset_devices(char *str)
74007
74008 __setup("reset_devices", set_reset_devices);
74009
74010 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74011 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74012 +static int __init setup_grsec_proc_gid(char *str)
74013 +{
74014 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74015 + return 1;
74016 +}
74017 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74018 +#endif
74019 +
74020 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74021 +extern char pax_enter_kernel_user[];
74022 +extern char pax_exit_kernel_user[];
74023 +extern pgdval_t clone_pgd_mask;
74024 +#endif
74025 +
74026 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74027 +static int __init setup_pax_nouderef(char *str)
74028 +{
74029 +#ifdef CONFIG_X86_32
74030 + unsigned int cpu;
74031 + struct desc_struct *gdt;
74032 +
74033 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74034 + gdt = get_cpu_gdt_table(cpu);
74035 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74036 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74037 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74038 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74039 + }
74040 + loadsegment(ds, __KERNEL_DS);
74041 + loadsegment(es, __KERNEL_DS);
74042 + loadsegment(ss, __KERNEL_DS);
74043 +#else
74044 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74045 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74046 + clone_pgd_mask = ~(pgdval_t)0UL;
74047 +#endif
74048 +
74049 + return 0;
74050 +}
74051 +early_param("pax_nouderef", setup_pax_nouderef);
74052 +#endif
74053 +
74054 +#ifdef CONFIG_PAX_SOFTMODE
74055 +int pax_softmode;
74056 +
74057 +static int __init setup_pax_softmode(char *str)
74058 +{
74059 + get_option(&str, &pax_softmode);
74060 + return 1;
74061 +}
74062 +__setup("pax_softmode=", setup_pax_softmode);
74063 +#endif
74064 +
74065 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74066 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74067 static const char *panic_later, *panic_param;
74068 @@ -681,6 +738,7 @@ int __init_or_module do_one_initcall(initcall_t fn)
74069 {
74070 int count = preempt_count();
74071 int ret;
74072 + const char *msg1 = "", *msg2 = "";
74073
74074 if (initcall_debug)
74075 ret = do_one_initcall_debug(fn);
74076 @@ -693,15 +751,15 @@ int __init_or_module do_one_initcall(initcall_t fn)
74077 sprintf(msgbuf, "error code %d ", ret);
74078
74079 if (preempt_count() != count) {
74080 - strlcat(msgbuf, "preemption imbalance ", sizeof(msgbuf));
74081 + msg1 = " preemption imbalance";
74082 preempt_count() = count;
74083 }
74084 if (irqs_disabled()) {
74085 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74086 + msg2 = " disabled interrupts";
74087 local_irq_enable();
74088 }
74089 - if (msgbuf[0]) {
74090 - printk("initcall %pF returned with %s\n", fn, msgbuf);
74091 + if (msgbuf[0] || *msg1 || *msg2) {
74092 + printk("initcall %pF returned with %s%s%s\n", fn, msgbuf, msg1, msg2);
74093 }
74094
74095 return ret;
74096 @@ -755,8 +813,14 @@ static void __init do_initcall_level(int level)
74097 level, level,
74098 &repair_env_string);
74099
74100 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74101 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74102 do_one_initcall(*fn);
74103 +
74104 +#ifdef LATENT_ENTROPY_PLUGIN
74105 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74106 +#endif
74107 +
74108 + }
74109 }
74110
74111 static void __init do_initcalls(void)
74112 @@ -790,8 +854,14 @@ static void __init do_pre_smp_initcalls(void)
74113 {
74114 initcall_t *fn;
74115
74116 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74117 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74118 do_one_initcall(*fn);
74119 +
74120 +#ifdef LATENT_ENTROPY_PLUGIN
74121 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74122 +#endif
74123 +
74124 + }
74125 }
74126
74127 static int run_init_process(const char *init_filename)
74128 @@ -877,7 +947,7 @@ static noinline void __init kernel_init_freeable(void)
74129 do_basic_setup();
74130
74131 /* Open the /dev/console on the rootfs, this should never fail */
74132 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74133 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74134 printk(KERN_WARNING "Warning: unable to open an initial console.\n");
74135
74136 (void) sys_dup(0);
74137 @@ -890,11 +960,13 @@ static noinline void __init kernel_init_freeable(void)
74138 if (!ramdisk_execute_command)
74139 ramdisk_execute_command = "/init";
74140
74141 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74142 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74143 ramdisk_execute_command = NULL;
74144 prepare_namespace();
74145 }
74146
74147 + grsecurity_init();
74148 +
74149 /*
74150 * Ok, we have completed the initial bootup, and
74151 * we're essentially up and running. Get rid of the
74152 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74153 index 130dfec..cc88451 100644
74154 --- a/ipc/ipc_sysctl.c
74155 +++ b/ipc/ipc_sysctl.c
74156 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74157 static int proc_ipc_dointvec(ctl_table *table, int write,
74158 void __user *buffer, size_t *lenp, loff_t *ppos)
74159 {
74160 - struct ctl_table ipc_table;
74161 + ctl_table_no_const ipc_table;
74162
74163 memcpy(&ipc_table, table, sizeof(ipc_table));
74164 ipc_table.data = get_ipc(table);
74165 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74166 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74167 void __user *buffer, size_t *lenp, loff_t *ppos)
74168 {
74169 - struct ctl_table ipc_table;
74170 + ctl_table_no_const ipc_table;
74171
74172 memcpy(&ipc_table, table, sizeof(ipc_table));
74173 ipc_table.data = get_ipc(table);
74174 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74175 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74176 void __user *buffer, size_t *lenp, loff_t *ppos)
74177 {
74178 - struct ctl_table ipc_table;
74179 + ctl_table_no_const ipc_table;
74180 size_t lenp_bef = *lenp;
74181 int rc;
74182
74183 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74184 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74185 void __user *buffer, size_t *lenp, loff_t *ppos)
74186 {
74187 - struct ctl_table ipc_table;
74188 + ctl_table_no_const ipc_table;
74189 memcpy(&ipc_table, table, sizeof(ipc_table));
74190 ipc_table.data = get_ipc(table);
74191
74192 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74193 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74194 void __user *buffer, size_t *lenp, loff_t *ppos)
74195 {
74196 - struct ctl_table ipc_table;
74197 + ctl_table_no_const ipc_table;
74198 size_t lenp_bef = *lenp;
74199 int oldval;
74200 int rc;
74201 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74202 index 383d638..943fdbb 100644
74203 --- a/ipc/mq_sysctl.c
74204 +++ b/ipc/mq_sysctl.c
74205 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74206 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74207 void __user *buffer, size_t *lenp, loff_t *ppos)
74208 {
74209 - struct ctl_table mq_table;
74210 + ctl_table_no_const mq_table;
74211 memcpy(&mq_table, table, sizeof(mq_table));
74212 mq_table.data = get_mq(table);
74213
74214 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74215 index f3f40dc..ffe5a3a 100644
74216 --- a/ipc/mqueue.c
74217 +++ b/ipc/mqueue.c
74218 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74219 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74220 info->attr.mq_msgsize);
74221
74222 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74223 spin_lock(&mq_lock);
74224 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74225 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74226 diff --git a/ipc/msg.c b/ipc/msg.c
74227 index 31cd1bf..9778e0f8 100644
74228 --- a/ipc/msg.c
74229 +++ b/ipc/msg.c
74230 @@ -309,18 +309,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74231 return security_msg_queue_associate(msq, msgflg);
74232 }
74233
74234 +static struct ipc_ops msg_ops = {
74235 + .getnew = newque,
74236 + .associate = msg_security,
74237 + .more_checks = NULL
74238 +};
74239 +
74240 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74241 {
74242 struct ipc_namespace *ns;
74243 - struct ipc_ops msg_ops;
74244 struct ipc_params msg_params;
74245
74246 ns = current->nsproxy->ipc_ns;
74247
74248 - msg_ops.getnew = newque;
74249 - msg_ops.associate = msg_security;
74250 - msg_ops.more_checks = NULL;
74251 -
74252 msg_params.key = key;
74253 msg_params.flg = msgflg;
74254
74255 @@ -872,6 +873,7 @@ long do_msgrcv(int msqid, void __user *buf, size_t bufsz, long msgtyp,
74256 goto out_unlock;
74257 break;
74258 }
74259 + msg = ERR_PTR(-EAGAIN);
74260 } else
74261 break;
74262 msg_counter++;
74263 diff --git a/ipc/sem.c b/ipc/sem.c
74264 index 58d31f1..cce7a55 100644
74265 --- a/ipc/sem.c
74266 +++ b/ipc/sem.c
74267 @@ -364,10 +364,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74268 return 0;
74269 }
74270
74271 +static struct ipc_ops sem_ops = {
74272 + .getnew = newary,
74273 + .associate = sem_security,
74274 + .more_checks = sem_more_checks
74275 +};
74276 +
74277 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74278 {
74279 struct ipc_namespace *ns;
74280 - struct ipc_ops sem_ops;
74281 struct ipc_params sem_params;
74282
74283 ns = current->nsproxy->ipc_ns;
74284 @@ -375,10 +380,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74285 if (nsems < 0 || nsems > ns->sc_semmsl)
74286 return -EINVAL;
74287
74288 - sem_ops.getnew = newary;
74289 - sem_ops.associate = sem_security;
74290 - sem_ops.more_checks = sem_more_checks;
74291 -
74292 sem_params.key = key;
74293 sem_params.flg = semflg;
74294 sem_params.u.nsems = nsems;
74295 diff --git a/ipc/shm.c b/ipc/shm.c
74296 index 4fa6d8f..55cff14 100644
74297 --- a/ipc/shm.c
74298 +++ b/ipc/shm.c
74299 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74300 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74301 #endif
74302
74303 +#ifdef CONFIG_GRKERNSEC
74304 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74305 + const time_t shm_createtime, const kuid_t cuid,
74306 + const int shmid);
74307 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74308 + const time_t shm_createtime);
74309 +#endif
74310 +
74311 void shm_init_ns(struct ipc_namespace *ns)
74312 {
74313 ns->shm_ctlmax = SHMMAX;
74314 @@ -521,6 +529,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74315 shp->shm_lprid = 0;
74316 shp->shm_atim = shp->shm_dtim = 0;
74317 shp->shm_ctim = get_seconds();
74318 +#ifdef CONFIG_GRKERNSEC
74319 + {
74320 + struct timespec timeval;
74321 + do_posix_clock_monotonic_gettime(&timeval);
74322 +
74323 + shp->shm_createtime = timeval.tv_sec;
74324 + }
74325 +#endif
74326 shp->shm_segsz = size;
74327 shp->shm_nattch = 0;
74328 shp->shm_file = file;
74329 @@ -572,18 +588,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74330 return 0;
74331 }
74332
74333 +static struct ipc_ops shm_ops = {
74334 + .getnew = newseg,
74335 + .associate = shm_security,
74336 + .more_checks = shm_more_checks
74337 +};
74338 +
74339 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74340 {
74341 struct ipc_namespace *ns;
74342 - struct ipc_ops shm_ops;
74343 struct ipc_params shm_params;
74344
74345 ns = current->nsproxy->ipc_ns;
74346
74347 - shm_ops.getnew = newseg;
74348 - shm_ops.associate = shm_security;
74349 - shm_ops.more_checks = shm_more_checks;
74350 -
74351 shm_params.key = key;
74352 shm_params.flg = shmflg;
74353 shm_params.u.size = size;
74354 @@ -1004,6 +1021,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74355 f_mode = FMODE_READ | FMODE_WRITE;
74356 }
74357 if (shmflg & SHM_EXEC) {
74358 +
74359 +#ifdef CONFIG_PAX_MPROTECT
74360 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74361 + goto out;
74362 +#endif
74363 +
74364 prot |= PROT_EXEC;
74365 acc_mode |= S_IXUGO;
74366 }
74367 @@ -1027,9 +1050,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74368 if (err)
74369 goto out_unlock;
74370
74371 +#ifdef CONFIG_GRKERNSEC
74372 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74373 + shp->shm_perm.cuid, shmid) ||
74374 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74375 + err = -EACCES;
74376 + goto out_unlock;
74377 + }
74378 +#endif
74379 +
74380 path = shp->shm_file->f_path;
74381 path_get(&path);
74382 shp->shm_nattch++;
74383 +#ifdef CONFIG_GRKERNSEC
74384 + shp->shm_lapid = current->pid;
74385 +#endif
74386 size = i_size_read(path.dentry->d_inode);
74387 shm_unlock(shp);
74388
74389 diff --git a/kernel/acct.c b/kernel/acct.c
74390 index 051e071..15e0920 100644
74391 --- a/kernel/acct.c
74392 +++ b/kernel/acct.c
74393 @@ -550,7 +550,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74394 */
74395 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74396 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74397 - file->f_op->write(file, (char *)&ac,
74398 + file->f_op->write(file, (char __force_user *)&ac,
74399 sizeof(acct_t), &file->f_pos);
74400 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74401 set_fs(fs);
74402 diff --git a/kernel/audit.c b/kernel/audit.c
74403 index d596e53..dbef3c3 100644
74404 --- a/kernel/audit.c
74405 +++ b/kernel/audit.c
74406 @@ -116,7 +116,7 @@ u32 audit_sig_sid = 0;
74407 3) suppressed due to audit_rate_limit
74408 4) suppressed due to audit_backlog_limit
74409 */
74410 -static atomic_t audit_lost = ATOMIC_INIT(0);
74411 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74412
74413 /* The netlink socket. */
74414 static struct sock *audit_sock;
74415 @@ -238,7 +238,7 @@ void audit_log_lost(const char *message)
74416 unsigned long now;
74417 int print;
74418
74419 - atomic_inc(&audit_lost);
74420 + atomic_inc_unchecked(&audit_lost);
74421
74422 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74423
74424 @@ -257,7 +257,7 @@ void audit_log_lost(const char *message)
74425 printk(KERN_WARNING
74426 "audit: audit_lost=%d audit_rate_limit=%d "
74427 "audit_backlog_limit=%d\n",
74428 - atomic_read(&audit_lost),
74429 + atomic_read_unchecked(&audit_lost),
74430 audit_rate_limit,
74431 audit_backlog_limit);
74432 audit_panic(message);
74433 @@ -681,7 +681,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74434 status_set.pid = audit_pid;
74435 status_set.rate_limit = audit_rate_limit;
74436 status_set.backlog_limit = audit_backlog_limit;
74437 - status_set.lost = atomic_read(&audit_lost);
74438 + status_set.lost = atomic_read_unchecked(&audit_lost);
74439 status_set.backlog = skb_queue_len(&audit_skb_queue);
74440 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74441 &status_set, sizeof(status_set));
74442 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74443 index a371f85..da826c1 100644
74444 --- a/kernel/auditsc.c
74445 +++ b/kernel/auditsc.c
74446 @@ -2292,7 +2292,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74447 }
74448
74449 /* global counter which is incremented every time something logs in */
74450 -static atomic_t session_id = ATOMIC_INIT(0);
74451 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74452
74453 /**
74454 * audit_set_loginuid - set current task's audit_context loginuid
74455 @@ -2316,7 +2316,7 @@ int audit_set_loginuid(kuid_t loginuid)
74456 return -EPERM;
74457 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74458
74459 - sessionid = atomic_inc_return(&session_id);
74460 + sessionid = atomic_inc_return_unchecked(&session_id);
74461 if (context && context->in_syscall) {
74462 struct audit_buffer *ab;
74463
74464 diff --git a/kernel/capability.c b/kernel/capability.c
74465 index 493d972..f87dfbd 100644
74466 --- a/kernel/capability.c
74467 +++ b/kernel/capability.c
74468 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74469 * before modification is attempted and the application
74470 * fails.
74471 */
74472 + if (tocopy > ARRAY_SIZE(kdata))
74473 + return -EFAULT;
74474 +
74475 if (copy_to_user(dataptr, kdata, tocopy
74476 * sizeof(struct __user_cap_data_struct))) {
74477 return -EFAULT;
74478 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74479 int ret;
74480
74481 rcu_read_lock();
74482 - ret = security_capable(__task_cred(t), ns, cap);
74483 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74484 + gr_task_is_capable(t, __task_cred(t), cap);
74485 rcu_read_unlock();
74486
74487 - return (ret == 0);
74488 + return ret;
74489 }
74490
74491 /**
74492 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74493 int ret;
74494
74495 rcu_read_lock();
74496 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74497 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74498 rcu_read_unlock();
74499
74500 - return (ret == 0);
74501 + return ret;
74502 }
74503
74504 /**
74505 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74506 BUG();
74507 }
74508
74509 - if (security_capable(current_cred(), ns, cap) == 0) {
74510 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74511 current->flags |= PF_SUPERPRIV;
74512 return true;
74513 }
74514 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74515 }
74516 EXPORT_SYMBOL(ns_capable);
74517
74518 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74519 +{
74520 + if (unlikely(!cap_valid(cap))) {
74521 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74522 + BUG();
74523 + }
74524 +
74525 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74526 + current->flags |= PF_SUPERPRIV;
74527 + return true;
74528 + }
74529 + return false;
74530 +}
74531 +EXPORT_SYMBOL(ns_capable_nolog);
74532 +
74533 /**
74534 * capable - Determine if the current task has a superior capability in effect
74535 * @cap: The capability to be tested for
74536 @@ -408,6 +427,12 @@ bool capable(int cap)
74537 }
74538 EXPORT_SYMBOL(capable);
74539
74540 +bool capable_nolog(int cap)
74541 +{
74542 + return ns_capable_nolog(&init_user_ns, cap);
74543 +}
74544 +EXPORT_SYMBOL(capable_nolog);
74545 +
74546 /**
74547 * nsown_capable - Check superior capability to one's own user_ns
74548 * @cap: The capability in question
74549 @@ -440,3 +465,10 @@ bool inode_capable(const struct inode *inode, int cap)
74550
74551 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74552 }
74553 +
74554 +bool inode_capable_nolog(const struct inode *inode, int cap)
74555 +{
74556 + struct user_namespace *ns = current_user_ns();
74557 +
74558 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74559 +}
74560 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74561 index 1e23664..570a83d 100644
74562 --- a/kernel/cgroup.c
74563 +++ b/kernel/cgroup.c
74564 @@ -5543,7 +5543,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74565 struct css_set *cg = link->cg;
74566 struct task_struct *task;
74567 int count = 0;
74568 - seq_printf(seq, "css_set %p\n", cg);
74569 + seq_printf(seq, "css_set %pK\n", cg);
74570 list_for_each_entry(task, &cg->tasks, cg_list) {
74571 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74572 seq_puts(seq, " ...\n");
74573 diff --git a/kernel/compat.c b/kernel/compat.c
74574 index 36700e9..73d770c 100644
74575 --- a/kernel/compat.c
74576 +++ b/kernel/compat.c
74577 @@ -13,6 +13,7 @@
74578
74579 #include <linux/linkage.h>
74580 #include <linux/compat.h>
74581 +#include <linux/module.h>
74582 #include <linux/errno.h>
74583 #include <linux/time.h>
74584 #include <linux/signal.h>
74585 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74586 mm_segment_t oldfs;
74587 long ret;
74588
74589 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74590 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74591 oldfs = get_fs();
74592 set_fs(KERNEL_DS);
74593 ret = hrtimer_nanosleep_restart(restart);
74594 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74595 oldfs = get_fs();
74596 set_fs(KERNEL_DS);
74597 ret = hrtimer_nanosleep(&tu,
74598 - rmtp ? (struct timespec __user *)&rmt : NULL,
74599 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74600 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74601 set_fs(oldfs);
74602
74603 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74604 mm_segment_t old_fs = get_fs();
74605
74606 set_fs(KERNEL_DS);
74607 - ret = sys_sigpending((old_sigset_t __user *) &s);
74608 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74609 set_fs(old_fs);
74610 if (ret == 0)
74611 ret = put_user(s, set);
74612 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74613 mm_segment_t old_fs = get_fs();
74614
74615 set_fs(KERNEL_DS);
74616 - ret = sys_old_getrlimit(resource, &r);
74617 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74618 set_fs(old_fs);
74619
74620 if (!ret) {
74621 @@ -523,7 +524,7 @@ asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru)
74622 mm_segment_t old_fs = get_fs();
74623
74624 set_fs(KERNEL_DS);
74625 - ret = sys_getrusage(who, (struct rusage __user *) &r);
74626 + ret = sys_getrusage(who, (struct rusage __force_user *) &r);
74627 set_fs(old_fs);
74628
74629 if (ret)
74630 @@ -552,8 +553,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74631 set_fs (KERNEL_DS);
74632 ret = sys_wait4(pid,
74633 (stat_addr ?
74634 - (unsigned int __user *) &status : NULL),
74635 - options, (struct rusage __user *) &r);
74636 + (unsigned int __force_user *) &status : NULL),
74637 + options, (struct rusage __force_user *) &r);
74638 set_fs (old_fs);
74639
74640 if (ret > 0) {
74641 @@ -579,8 +580,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74642 memset(&info, 0, sizeof(info));
74643
74644 set_fs(KERNEL_DS);
74645 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74646 - uru ? (struct rusage __user *)&ru : NULL);
74647 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74648 + uru ? (struct rusage __force_user *)&ru : NULL);
74649 set_fs(old_fs);
74650
74651 if ((ret < 0) || (info.si_signo == 0))
74652 @@ -714,8 +715,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74653 oldfs = get_fs();
74654 set_fs(KERNEL_DS);
74655 err = sys_timer_settime(timer_id, flags,
74656 - (struct itimerspec __user *) &newts,
74657 - (struct itimerspec __user *) &oldts);
74658 + (struct itimerspec __force_user *) &newts,
74659 + (struct itimerspec __force_user *) &oldts);
74660 set_fs(oldfs);
74661 if (!err && old && put_compat_itimerspec(old, &oldts))
74662 return -EFAULT;
74663 @@ -732,7 +733,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74664 oldfs = get_fs();
74665 set_fs(KERNEL_DS);
74666 err = sys_timer_gettime(timer_id,
74667 - (struct itimerspec __user *) &ts);
74668 + (struct itimerspec __force_user *) &ts);
74669 set_fs(oldfs);
74670 if (!err && put_compat_itimerspec(setting, &ts))
74671 return -EFAULT;
74672 @@ -751,7 +752,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74673 oldfs = get_fs();
74674 set_fs(KERNEL_DS);
74675 err = sys_clock_settime(which_clock,
74676 - (struct timespec __user *) &ts);
74677 + (struct timespec __force_user *) &ts);
74678 set_fs(oldfs);
74679 return err;
74680 }
74681 @@ -766,7 +767,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74682 oldfs = get_fs();
74683 set_fs(KERNEL_DS);
74684 err = sys_clock_gettime(which_clock,
74685 - (struct timespec __user *) &ts);
74686 + (struct timespec __force_user *) &ts);
74687 set_fs(oldfs);
74688 if (!err && put_compat_timespec(&ts, tp))
74689 return -EFAULT;
74690 @@ -786,7 +787,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74691
74692 oldfs = get_fs();
74693 set_fs(KERNEL_DS);
74694 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74695 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74696 set_fs(oldfs);
74697
74698 err = compat_put_timex(utp, &txc);
74699 @@ -806,7 +807,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74700 oldfs = get_fs();
74701 set_fs(KERNEL_DS);
74702 err = sys_clock_getres(which_clock,
74703 - (struct timespec __user *) &ts);
74704 + (struct timespec __force_user *) &ts);
74705 set_fs(oldfs);
74706 if (!err && tp && put_compat_timespec(&ts, tp))
74707 return -EFAULT;
74708 @@ -818,9 +819,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74709 long err;
74710 mm_segment_t oldfs;
74711 struct timespec tu;
74712 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74713 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74714
74715 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74716 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74717 oldfs = get_fs();
74718 set_fs(KERNEL_DS);
74719 err = clock_nanosleep_restart(restart);
74720 @@ -852,8 +853,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74721 oldfs = get_fs();
74722 set_fs(KERNEL_DS);
74723 err = sys_clock_nanosleep(which_clock, flags,
74724 - (struct timespec __user *) &in,
74725 - (struct timespec __user *) &out);
74726 + (struct timespec __force_user *) &in,
74727 + (struct timespec __force_user *) &out);
74728 set_fs(oldfs);
74729
74730 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
74731 diff --git a/kernel/configs.c b/kernel/configs.c
74732 index 42e8fa0..9e7406b 100644
74733 --- a/kernel/configs.c
74734 +++ b/kernel/configs.c
74735 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
74736 struct proc_dir_entry *entry;
74737
74738 /* create the current config file */
74739 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
74740 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
74741 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
74742 + &ikconfig_file_ops);
74743 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74744 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
74745 + &ikconfig_file_ops);
74746 +#endif
74747 +#else
74748 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
74749 &ikconfig_file_ops);
74750 +#endif
74751 +
74752 if (!entry)
74753 return -ENOMEM;
74754
74755 diff --git a/kernel/cred.c b/kernel/cred.c
74756 index e0573a4..3874e41 100644
74757 --- a/kernel/cred.c
74758 +++ b/kernel/cred.c
74759 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
74760 validate_creds(cred);
74761 alter_cred_subscribers(cred, -1);
74762 put_cred(cred);
74763 +
74764 +#ifdef CONFIG_GRKERNSEC_SETXID
74765 + cred = (struct cred *) tsk->delayed_cred;
74766 + if (cred != NULL) {
74767 + tsk->delayed_cred = NULL;
74768 + validate_creds(cred);
74769 + alter_cred_subscribers(cred, -1);
74770 + put_cred(cred);
74771 + }
74772 +#endif
74773 }
74774
74775 /**
74776 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
74777 * Always returns 0 thus allowing this function to be tail-called at the end
74778 * of, say, sys_setgid().
74779 */
74780 -int commit_creds(struct cred *new)
74781 +static int __commit_creds(struct cred *new)
74782 {
74783 struct task_struct *task = current;
74784 const struct cred *old = task->real_cred;
74785 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
74786
74787 get_cred(new); /* we will require a ref for the subj creds too */
74788
74789 + gr_set_role_label(task, new->uid, new->gid);
74790 +
74791 /* dumpability changes */
74792 if (!uid_eq(old->euid, new->euid) ||
74793 !gid_eq(old->egid, new->egid) ||
74794 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
74795 put_cred(old);
74796 return 0;
74797 }
74798 +#ifdef CONFIG_GRKERNSEC_SETXID
74799 +extern int set_user(struct cred *new);
74800 +
74801 +void gr_delayed_cred_worker(void)
74802 +{
74803 + const struct cred *new = current->delayed_cred;
74804 + struct cred *ncred;
74805 +
74806 + current->delayed_cred = NULL;
74807 +
74808 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
74809 + // from doing get_cred on it when queueing this
74810 + put_cred(new);
74811 + return;
74812 + } else if (new == NULL)
74813 + return;
74814 +
74815 + ncred = prepare_creds();
74816 + if (!ncred)
74817 + goto die;
74818 + // uids
74819 + ncred->uid = new->uid;
74820 + ncred->euid = new->euid;
74821 + ncred->suid = new->suid;
74822 + ncred->fsuid = new->fsuid;
74823 + // gids
74824 + ncred->gid = new->gid;
74825 + ncred->egid = new->egid;
74826 + ncred->sgid = new->sgid;
74827 + ncred->fsgid = new->fsgid;
74828 + // groups
74829 + if (set_groups(ncred, new->group_info) < 0) {
74830 + abort_creds(ncred);
74831 + goto die;
74832 + }
74833 + // caps
74834 + ncred->securebits = new->securebits;
74835 + ncred->cap_inheritable = new->cap_inheritable;
74836 + ncred->cap_permitted = new->cap_permitted;
74837 + ncred->cap_effective = new->cap_effective;
74838 + ncred->cap_bset = new->cap_bset;
74839 +
74840 + if (set_user(ncred)) {
74841 + abort_creds(ncred);
74842 + goto die;
74843 + }
74844 +
74845 + // from doing get_cred on it when queueing this
74846 + put_cred(new);
74847 +
74848 + __commit_creds(ncred);
74849 + return;
74850 +die:
74851 + // from doing get_cred on it when queueing this
74852 + put_cred(new);
74853 + do_group_exit(SIGKILL);
74854 +}
74855 +#endif
74856 +
74857 +int commit_creds(struct cred *new)
74858 +{
74859 +#ifdef CONFIG_GRKERNSEC_SETXID
74860 + int ret;
74861 + int schedule_it = 0;
74862 + struct task_struct *t;
74863 +
74864 + /* we won't get called with tasklist_lock held for writing
74865 + and interrupts disabled as the cred struct in that case is
74866 + init_cred
74867 + */
74868 + if (grsec_enable_setxid && !current_is_single_threaded() &&
74869 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
74870 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
74871 + schedule_it = 1;
74872 + }
74873 + ret = __commit_creds(new);
74874 + if (schedule_it) {
74875 + rcu_read_lock();
74876 + read_lock(&tasklist_lock);
74877 + for (t = next_thread(current); t != current;
74878 + t = next_thread(t)) {
74879 + if (t->delayed_cred == NULL) {
74880 + t->delayed_cred = get_cred(new);
74881 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
74882 + set_tsk_need_resched(t);
74883 + }
74884 + }
74885 + read_unlock(&tasklist_lock);
74886 + rcu_read_unlock();
74887 + }
74888 + return ret;
74889 +#else
74890 + return __commit_creds(new);
74891 +#endif
74892 +}
74893 +
74894 EXPORT_SYMBOL(commit_creds);
74895
74896 /**
74897 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
74898 index 9a61738..c5c8f3a 100644
74899 --- a/kernel/debug/debug_core.c
74900 +++ b/kernel/debug/debug_core.c
74901 @@ -122,7 +122,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
74902 */
74903 static atomic_t masters_in_kgdb;
74904 static atomic_t slaves_in_kgdb;
74905 -static atomic_t kgdb_break_tasklet_var;
74906 +static atomic_unchecked_t kgdb_break_tasklet_var;
74907 atomic_t kgdb_setting_breakpoint;
74908
74909 struct task_struct *kgdb_usethread;
74910 @@ -132,7 +132,7 @@ int kgdb_single_step;
74911 static pid_t kgdb_sstep_pid;
74912
74913 /* to keep track of the CPU which is doing the single stepping*/
74914 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74915 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
74916
74917 /*
74918 * If you are debugging a problem where roundup (the collection of
74919 @@ -540,7 +540,7 @@ return_normal:
74920 * kernel will only try for the value of sstep_tries before
74921 * giving up and continuing on.
74922 */
74923 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
74924 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
74925 (kgdb_info[cpu].task &&
74926 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
74927 atomic_set(&kgdb_active, -1);
74928 @@ -634,8 +634,8 @@ cpu_master_loop:
74929 }
74930
74931 kgdb_restore:
74932 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
74933 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
74934 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
74935 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
74936 if (kgdb_info[sstep_cpu].task)
74937 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
74938 else
74939 @@ -887,18 +887,18 @@ static void kgdb_unregister_callbacks(void)
74940 static void kgdb_tasklet_bpt(unsigned long ing)
74941 {
74942 kgdb_breakpoint();
74943 - atomic_set(&kgdb_break_tasklet_var, 0);
74944 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
74945 }
74946
74947 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
74948
74949 void kgdb_schedule_breakpoint(void)
74950 {
74951 - if (atomic_read(&kgdb_break_tasklet_var) ||
74952 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
74953 atomic_read(&kgdb_active) != -1 ||
74954 atomic_read(&kgdb_setting_breakpoint))
74955 return;
74956 - atomic_inc(&kgdb_break_tasklet_var);
74957 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
74958 tasklet_schedule(&kgdb_tasklet_breakpoint);
74959 }
74960 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
74961 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
74962 index 8875254..7cf4928 100644
74963 --- a/kernel/debug/kdb/kdb_main.c
74964 +++ b/kernel/debug/kdb/kdb_main.c
74965 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
74966 continue;
74967
74968 kdb_printf("%-20s%8u 0x%p ", mod->name,
74969 - mod->core_size, (void *)mod);
74970 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
74971 #ifdef CONFIG_MODULE_UNLOAD
74972 kdb_printf("%4ld ", module_refcount(mod));
74973 #endif
74974 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
74975 kdb_printf(" (Loading)");
74976 else
74977 kdb_printf(" (Live)");
74978 - kdb_printf(" 0x%p", mod->module_core);
74979 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
74980
74981 #ifdef CONFIG_MODULE_UNLOAD
74982 {
74983 diff --git a/kernel/events/core.c b/kernel/events/core.c
74984 index 7b6646a..3cb1135 100644
74985 --- a/kernel/events/core.c
74986 +++ b/kernel/events/core.c
74987 @@ -182,7 +182,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
74988 return 0;
74989 }
74990
74991 -static atomic64_t perf_event_id;
74992 +static atomic64_unchecked_t perf_event_id;
74993
74994 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
74995 enum event_type_t event_type);
74996 @@ -2677,7 +2677,7 @@ static void __perf_event_read(void *info)
74997
74998 static inline u64 perf_event_count(struct perf_event *event)
74999 {
75000 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75001 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75002 }
75003
75004 static u64 perf_event_read(struct perf_event *event)
75005 @@ -3007,9 +3007,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75006 mutex_lock(&event->child_mutex);
75007 total += perf_event_read(event);
75008 *enabled += event->total_time_enabled +
75009 - atomic64_read(&event->child_total_time_enabled);
75010 + atomic64_read_unchecked(&event->child_total_time_enabled);
75011 *running += event->total_time_running +
75012 - atomic64_read(&event->child_total_time_running);
75013 + atomic64_read_unchecked(&event->child_total_time_running);
75014
75015 list_for_each_entry(child, &event->child_list, child_list) {
75016 total += perf_event_read(child);
75017 @@ -3412,10 +3412,10 @@ void perf_event_update_userpage(struct perf_event *event)
75018 userpg->offset -= local64_read(&event->hw.prev_count);
75019
75020 userpg->time_enabled = enabled +
75021 - atomic64_read(&event->child_total_time_enabled);
75022 + atomic64_read_unchecked(&event->child_total_time_enabled);
75023
75024 userpg->time_running = running +
75025 - atomic64_read(&event->child_total_time_running);
75026 + atomic64_read_unchecked(&event->child_total_time_running);
75027
75028 arch_perf_update_userpage(userpg, now);
75029
75030 @@ -3974,11 +3974,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75031 values[n++] = perf_event_count(event);
75032 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75033 values[n++] = enabled +
75034 - atomic64_read(&event->child_total_time_enabled);
75035 + atomic64_read_unchecked(&event->child_total_time_enabled);
75036 }
75037 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75038 values[n++] = running +
75039 - atomic64_read(&event->child_total_time_running);
75040 + atomic64_read_unchecked(&event->child_total_time_running);
75041 }
75042 if (read_format & PERF_FORMAT_ID)
75043 values[n++] = primary_event_id(event);
75044 @@ -4721,12 +4721,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75045 * need to add enough zero bytes after the string to handle
75046 * the 64bit alignment we do later.
75047 */
75048 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75049 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75050 if (!buf) {
75051 name = strncpy(tmp, "//enomem", sizeof(tmp));
75052 goto got_name;
75053 }
75054 - name = d_path(&file->f_path, buf, PATH_MAX);
75055 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75056 if (IS_ERR(name)) {
75057 name = strncpy(tmp, "//toolong", sizeof(tmp));
75058 goto got_name;
75059 @@ -6165,7 +6165,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75060 event->parent = parent_event;
75061
75062 event->ns = get_pid_ns(task_active_pid_ns(current));
75063 - event->id = atomic64_inc_return(&perf_event_id);
75064 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75065
75066 event->state = PERF_EVENT_STATE_INACTIVE;
75067
75068 @@ -6790,10 +6790,10 @@ static void sync_child_event(struct perf_event *child_event,
75069 /*
75070 * Add back the child's count to the parent's count:
75071 */
75072 - atomic64_add(child_val, &parent_event->child_count);
75073 - atomic64_add(child_event->total_time_enabled,
75074 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75075 + atomic64_add_unchecked(child_event->total_time_enabled,
75076 &parent_event->child_total_time_enabled);
75077 - atomic64_add(child_event->total_time_running,
75078 + atomic64_add_unchecked(child_event->total_time_running,
75079 &parent_event->child_total_time_running);
75080
75081 /*
75082 diff --git a/kernel/exit.c b/kernel/exit.c
75083 index b4df219..f13c02d 100644
75084 --- a/kernel/exit.c
75085 +++ b/kernel/exit.c
75086 @@ -170,6 +170,10 @@ void release_task(struct task_struct * p)
75087 struct task_struct *leader;
75088 int zap_leader;
75089 repeat:
75090 +#ifdef CONFIG_NET
75091 + gr_del_task_from_ip_table(p);
75092 +#endif
75093 +
75094 /* don't need to get the RCU readlock here - the process is dead and
75095 * can't be modifying its own credentials. But shut RCU-lockdep up */
75096 rcu_read_lock();
75097 @@ -338,7 +342,7 @@ int allow_signal(int sig)
75098 * know it'll be handled, so that they don't get converted to
75099 * SIGKILL or just silently dropped.
75100 */
75101 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75102 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75103 recalc_sigpending();
75104 spin_unlock_irq(&current->sighand->siglock);
75105 return 0;
75106 @@ -708,6 +712,8 @@ void do_exit(long code)
75107 struct task_struct *tsk = current;
75108 int group_dead;
75109
75110 + set_fs(USER_DS);
75111 +
75112 profile_task_exit(tsk);
75113
75114 WARN_ON(blk_needs_flush_plug(tsk));
75115 @@ -724,7 +730,6 @@ void do_exit(long code)
75116 * mm_release()->clear_child_tid() from writing to a user-controlled
75117 * kernel address.
75118 */
75119 - set_fs(USER_DS);
75120
75121 ptrace_event(PTRACE_EVENT_EXIT, code);
75122
75123 @@ -783,6 +788,9 @@ void do_exit(long code)
75124 tsk->exit_code = code;
75125 taskstats_exit(tsk, group_dead);
75126
75127 + gr_acl_handle_psacct(tsk, code);
75128 + gr_acl_handle_exit();
75129 +
75130 exit_mm(tsk);
75131
75132 if (group_dead)
75133 @@ -903,7 +911,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75134 * Take down every thread in the group. This is called by fatal signals
75135 * as well as by sys_exit_group (below).
75136 */
75137 -void
75138 +__noreturn void
75139 do_group_exit(int exit_code)
75140 {
75141 struct signal_struct *sig = current->signal;
75142 diff --git a/kernel/fork.c b/kernel/fork.c
75143 index 5630e52..0cee608 100644
75144 --- a/kernel/fork.c
75145 +++ b/kernel/fork.c
75146 @@ -318,7 +318,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75147 *stackend = STACK_END_MAGIC; /* for overflow detection */
75148
75149 #ifdef CONFIG_CC_STACKPROTECTOR
75150 - tsk->stack_canary = get_random_int();
75151 + tsk->stack_canary = pax_get_random_long();
75152 #endif
75153
75154 /*
75155 @@ -344,13 +344,81 @@ free_tsk:
75156 }
75157
75158 #ifdef CONFIG_MMU
75159 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75160 +{
75161 + struct vm_area_struct *tmp;
75162 + unsigned long charge;
75163 + struct mempolicy *pol;
75164 + struct file *file;
75165 +
75166 + charge = 0;
75167 + if (mpnt->vm_flags & VM_ACCOUNT) {
75168 + unsigned long len = vma_pages(mpnt);
75169 +
75170 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75171 + goto fail_nomem;
75172 + charge = len;
75173 + }
75174 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75175 + if (!tmp)
75176 + goto fail_nomem;
75177 + *tmp = *mpnt;
75178 + tmp->vm_mm = mm;
75179 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75180 + pol = mpol_dup(vma_policy(mpnt));
75181 + if (IS_ERR(pol))
75182 + goto fail_nomem_policy;
75183 + vma_set_policy(tmp, pol);
75184 + if (anon_vma_fork(tmp, mpnt))
75185 + goto fail_nomem_anon_vma_fork;
75186 + tmp->vm_flags &= ~VM_LOCKED;
75187 + tmp->vm_next = tmp->vm_prev = NULL;
75188 + tmp->vm_mirror = NULL;
75189 + file = tmp->vm_file;
75190 + if (file) {
75191 + struct inode *inode = file->f_path.dentry->d_inode;
75192 + struct address_space *mapping = file->f_mapping;
75193 +
75194 + get_file(file);
75195 + if (tmp->vm_flags & VM_DENYWRITE)
75196 + atomic_dec(&inode->i_writecount);
75197 + mutex_lock(&mapping->i_mmap_mutex);
75198 + if (tmp->vm_flags & VM_SHARED)
75199 + mapping->i_mmap_writable++;
75200 + flush_dcache_mmap_lock(mapping);
75201 + /* insert tmp into the share list, just after mpnt */
75202 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75203 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75204 + else
75205 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75206 + flush_dcache_mmap_unlock(mapping);
75207 + mutex_unlock(&mapping->i_mmap_mutex);
75208 + }
75209 +
75210 + /*
75211 + * Clear hugetlb-related page reserves for children. This only
75212 + * affects MAP_PRIVATE mappings. Faults generated by the child
75213 + * are not guaranteed to succeed, even if read-only
75214 + */
75215 + if (is_vm_hugetlb_page(tmp))
75216 + reset_vma_resv_huge_pages(tmp);
75217 +
75218 + return tmp;
75219 +
75220 +fail_nomem_anon_vma_fork:
75221 + mpol_put(pol);
75222 +fail_nomem_policy:
75223 + kmem_cache_free(vm_area_cachep, tmp);
75224 +fail_nomem:
75225 + vm_unacct_memory(charge);
75226 + return NULL;
75227 +}
75228 +
75229 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75230 {
75231 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75232 struct rb_node **rb_link, *rb_parent;
75233 int retval;
75234 - unsigned long charge;
75235 - struct mempolicy *pol;
75236
75237 uprobe_start_dup_mmap();
75238 down_write(&oldmm->mmap_sem);
75239 @@ -364,8 +432,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75240 mm->locked_vm = 0;
75241 mm->mmap = NULL;
75242 mm->mmap_cache = NULL;
75243 - mm->free_area_cache = oldmm->mmap_base;
75244 - mm->cached_hole_size = ~0UL;
75245 + mm->free_area_cache = oldmm->free_area_cache;
75246 + mm->cached_hole_size = oldmm->cached_hole_size;
75247 mm->map_count = 0;
75248 cpumask_clear(mm_cpumask(mm));
75249 mm->mm_rb = RB_ROOT;
75250 @@ -381,57 +449,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75251
75252 prev = NULL;
75253 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75254 - struct file *file;
75255 -
75256 if (mpnt->vm_flags & VM_DONTCOPY) {
75257 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75258 -vma_pages(mpnt));
75259 continue;
75260 }
75261 - charge = 0;
75262 - if (mpnt->vm_flags & VM_ACCOUNT) {
75263 - unsigned long len = vma_pages(mpnt);
75264 -
75265 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75266 - goto fail_nomem;
75267 - charge = len;
75268 - }
75269 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75270 - if (!tmp)
75271 - goto fail_nomem;
75272 - *tmp = *mpnt;
75273 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75274 - pol = mpol_dup(vma_policy(mpnt));
75275 - retval = PTR_ERR(pol);
75276 - if (IS_ERR(pol))
75277 - goto fail_nomem_policy;
75278 - vma_set_policy(tmp, pol);
75279 - tmp->vm_mm = mm;
75280 - if (anon_vma_fork(tmp, mpnt))
75281 - goto fail_nomem_anon_vma_fork;
75282 - tmp->vm_flags &= ~VM_LOCKED;
75283 - tmp->vm_next = tmp->vm_prev = NULL;
75284 - file = tmp->vm_file;
75285 - if (file) {
75286 - struct inode *inode = file->f_path.dentry->d_inode;
75287 - struct address_space *mapping = file->f_mapping;
75288 -
75289 - get_file(file);
75290 - if (tmp->vm_flags & VM_DENYWRITE)
75291 - atomic_dec(&inode->i_writecount);
75292 - mutex_lock(&mapping->i_mmap_mutex);
75293 - if (tmp->vm_flags & VM_SHARED)
75294 - mapping->i_mmap_writable++;
75295 - flush_dcache_mmap_lock(mapping);
75296 - /* insert tmp into the share list, just after mpnt */
75297 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75298 - vma_nonlinear_insert(tmp,
75299 - &mapping->i_mmap_nonlinear);
75300 - else
75301 - vma_interval_tree_insert_after(tmp, mpnt,
75302 - &mapping->i_mmap);
75303 - flush_dcache_mmap_unlock(mapping);
75304 - mutex_unlock(&mapping->i_mmap_mutex);
75305 + tmp = dup_vma(mm, oldmm, mpnt);
75306 + if (!tmp) {
75307 + retval = -ENOMEM;
75308 + goto out;
75309 }
75310
75311 /*
75312 @@ -463,6 +489,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75313 if (retval)
75314 goto out;
75315 }
75316 +
75317 +#ifdef CONFIG_PAX_SEGMEXEC
75318 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75319 + struct vm_area_struct *mpnt_m;
75320 +
75321 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75322 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75323 +
75324 + if (!mpnt->vm_mirror)
75325 + continue;
75326 +
75327 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75328 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75329 + mpnt->vm_mirror = mpnt_m;
75330 + } else {
75331 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75332 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75333 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75334 + mpnt->vm_mirror->vm_mirror = mpnt;
75335 + }
75336 + }
75337 + BUG_ON(mpnt_m);
75338 + }
75339 +#endif
75340 +
75341 /* a new mm has just been created */
75342 arch_dup_mmap(oldmm, mm);
75343 retval = 0;
75344 @@ -472,14 +523,6 @@ out:
75345 up_write(&oldmm->mmap_sem);
75346 uprobe_end_dup_mmap();
75347 return retval;
75348 -fail_nomem_anon_vma_fork:
75349 - mpol_put(pol);
75350 -fail_nomem_policy:
75351 - kmem_cache_free(vm_area_cachep, tmp);
75352 -fail_nomem:
75353 - retval = -ENOMEM;
75354 - vm_unacct_memory(charge);
75355 - goto out;
75356 }
75357
75358 static inline int mm_alloc_pgd(struct mm_struct *mm)
75359 @@ -694,8 +737,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75360 return ERR_PTR(err);
75361
75362 mm = get_task_mm(task);
75363 - if (mm && mm != current->mm &&
75364 - !ptrace_may_access(task, mode)) {
75365 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75366 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75367 mmput(mm);
75368 mm = ERR_PTR(-EACCES);
75369 }
75370 @@ -917,13 +960,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75371 spin_unlock(&fs->lock);
75372 return -EAGAIN;
75373 }
75374 - fs->users++;
75375 + atomic_inc(&fs->users);
75376 spin_unlock(&fs->lock);
75377 return 0;
75378 }
75379 tsk->fs = copy_fs_struct(fs);
75380 if (!tsk->fs)
75381 return -ENOMEM;
75382 + /* Carry through gr_chroot_dentry and is_chrooted instead
75383 + of recomputing it here. Already copied when the task struct
75384 + is duplicated. This allows pivot_root to not be treated as
75385 + a chroot
75386 + */
75387 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75388 +
75389 return 0;
75390 }
75391
75392 @@ -1196,6 +1246,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75393 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75394 #endif
75395 retval = -EAGAIN;
75396 +
75397 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75398 +
75399 if (atomic_read(&p->real_cred->user->processes) >=
75400 task_rlimit(p, RLIMIT_NPROC)) {
75401 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75402 @@ -1435,6 +1488,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75403 goto bad_fork_free_pid;
75404 }
75405
75406 + /* synchronizes with gr_set_acls()
75407 + we need to call this past the point of no return for fork()
75408 + */
75409 + gr_copy_label(p);
75410 +
75411 if (clone_flags & CLONE_THREAD) {
75412 current->signal->nr_threads++;
75413 atomic_inc(&current->signal->live);
75414 @@ -1518,6 +1576,8 @@ bad_fork_cleanup_count:
75415 bad_fork_free:
75416 free_task(p);
75417 fork_out:
75418 + gr_log_forkfail(retval);
75419 +
75420 return ERR_PTR(retval);
75421 }
75422
75423 @@ -1568,6 +1628,23 @@ long do_fork(unsigned long clone_flags,
75424 return -EINVAL;
75425 }
75426
75427 +#ifdef CONFIG_GRKERNSEC
75428 + if (clone_flags & CLONE_NEWUSER) {
75429 + /*
75430 + * This doesn't really inspire confidence:
75431 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75432 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75433 + * Increases kernel attack surface in areas developers
75434 + * previously cared little about ("low importance due
75435 + * to requiring "root" capability")
75436 + * To be removed when this code receives *proper* review
75437 + */
75438 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75439 + !capable(CAP_SETGID))
75440 + return -EPERM;
75441 + }
75442 +#endif
75443 +
75444 /*
75445 * Determine whether and which event to report to ptracer. When
75446 * called from kernel_thread or CLONE_UNTRACED is explicitly
75447 @@ -1602,6 +1679,8 @@ long do_fork(unsigned long clone_flags,
75448 if (clone_flags & CLONE_PARENT_SETTID)
75449 put_user(nr, parent_tidptr);
75450
75451 + gr_handle_brute_check();
75452 +
75453 if (clone_flags & CLONE_VFORK) {
75454 p->vfork_done = &vfork;
75455 init_completion(&vfork);
75456 @@ -1755,7 +1834,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75457 return 0;
75458
75459 /* don't need lock here; in the worst case we'll do useless copy */
75460 - if (fs->users == 1)
75461 + if (atomic_read(&fs->users) == 1)
75462 return 0;
75463
75464 *new_fsp = copy_fs_struct(fs);
75465 @@ -1869,7 +1948,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75466 fs = current->fs;
75467 spin_lock(&fs->lock);
75468 current->fs = new_fs;
75469 - if (--fs->users)
75470 + gr_set_chroot_entries(current, &current->fs->root);
75471 + if (atomic_dec_return(&fs->users))
75472 new_fs = NULL;
75473 else
75474 new_fs = fs;
75475 diff --git a/kernel/futex.c b/kernel/futex.c
75476 index 8879430..31696f1 100644
75477 --- a/kernel/futex.c
75478 +++ b/kernel/futex.c
75479 @@ -54,6 +54,7 @@
75480 #include <linux/mount.h>
75481 #include <linux/pagemap.h>
75482 #include <linux/syscalls.h>
75483 +#include <linux/ptrace.h>
75484 #include <linux/signal.h>
75485 #include <linux/export.h>
75486 #include <linux/magic.h>
75487 @@ -239,6 +240,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75488 struct page *page, *page_head;
75489 int err, ro = 0;
75490
75491 +#ifdef CONFIG_PAX_SEGMEXEC
75492 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75493 + return -EFAULT;
75494 +#endif
75495 +
75496 /*
75497 * The futex address must be "naturally" aligned.
75498 */
75499 @@ -2731,6 +2737,7 @@ static int __init futex_init(void)
75500 {
75501 u32 curval;
75502 int i;
75503 + mm_segment_t oldfs;
75504
75505 /*
75506 * This will fail and we want it. Some arch implementations do
75507 @@ -2742,8 +2749,11 @@ static int __init futex_init(void)
75508 * implementation, the non-functional ones will return
75509 * -ENOSYS.
75510 */
75511 + oldfs = get_fs();
75512 + set_fs(USER_DS);
75513 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75514 futex_cmpxchg_enabled = 1;
75515 + set_fs(oldfs);
75516
75517 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75518 plist_head_init(&futex_queues[i].chain);
75519 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75520 index a9642d5..51eb98c 100644
75521 --- a/kernel/futex_compat.c
75522 +++ b/kernel/futex_compat.c
75523 @@ -31,7 +31,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75524 return 0;
75525 }
75526
75527 -static void __user *futex_uaddr(struct robust_list __user *entry,
75528 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75529 compat_long_t futex_offset)
75530 {
75531 compat_uptr_t base = ptr_to_compat(entry);
75532 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75533 index 9b22d03..6295b62 100644
75534 --- a/kernel/gcov/base.c
75535 +++ b/kernel/gcov/base.c
75536 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75537 }
75538
75539 #ifdef CONFIG_MODULES
75540 -static inline int within(void *addr, void *start, unsigned long size)
75541 -{
75542 - return ((addr >= start) && (addr < start + size));
75543 -}
75544 -
75545 /* Update list and generate events when modules are unloaded. */
75546 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75547 void *data)
75548 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75549 prev = NULL;
75550 /* Remove entries located in module from linked list. */
75551 for (info = gcov_info_head; info; info = info->next) {
75552 - if (within(info, mod->module_core, mod->core_size)) {
75553 + if (within_module_core_rw((unsigned long)info, mod)) {
75554 if (prev)
75555 prev->next = info->next;
75556 else
75557 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75558 index cdd5607..c3fc919 100644
75559 --- a/kernel/hrtimer.c
75560 +++ b/kernel/hrtimer.c
75561 @@ -1407,7 +1407,7 @@ void hrtimer_peek_ahead_timers(void)
75562 local_irq_restore(flags);
75563 }
75564
75565 -static void run_hrtimer_softirq(struct softirq_action *h)
75566 +static void run_hrtimer_softirq(void)
75567 {
75568 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75569
75570 @@ -1751,7 +1751,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75571 return NOTIFY_OK;
75572 }
75573
75574 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75575 +static struct notifier_block hrtimers_nb = {
75576 .notifier_call = hrtimer_cpu_notify,
75577 };
75578
75579 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75580 index 60f48fa..7f3a770 100644
75581 --- a/kernel/jump_label.c
75582 +++ b/kernel/jump_label.c
75583 @@ -13,6 +13,7 @@
75584 #include <linux/sort.h>
75585 #include <linux/err.h>
75586 #include <linux/static_key.h>
75587 +#include <linux/mm.h>
75588
75589 #ifdef HAVE_JUMP_LABEL
75590
75591 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75592
75593 size = (((unsigned long)stop - (unsigned long)start)
75594 / sizeof(struct jump_entry));
75595 + pax_open_kernel();
75596 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75597 + pax_close_kernel();
75598 }
75599
75600 static void jump_label_update(struct static_key *key, int enable);
75601 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75602 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75603 struct jump_entry *iter;
75604
75605 + pax_open_kernel();
75606 for (iter = iter_start; iter < iter_stop; iter++) {
75607 if (within_module_init(iter->code, mod))
75608 iter->code = 0;
75609 }
75610 + pax_close_kernel();
75611 }
75612
75613 static int
75614 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75615 index 2169fee..706ccca 100644
75616 --- a/kernel/kallsyms.c
75617 +++ b/kernel/kallsyms.c
75618 @@ -11,6 +11,9 @@
75619 * Changed the compression method from stem compression to "table lookup"
75620 * compression (see scripts/kallsyms.c for a more complete description)
75621 */
75622 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75623 +#define __INCLUDED_BY_HIDESYM 1
75624 +#endif
75625 #include <linux/kallsyms.h>
75626 #include <linux/module.h>
75627 #include <linux/init.h>
75628 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
75629
75630 static inline int is_kernel_inittext(unsigned long addr)
75631 {
75632 + if (system_state != SYSTEM_BOOTING)
75633 + return 0;
75634 +
75635 if (addr >= (unsigned long)_sinittext
75636 && addr <= (unsigned long)_einittext)
75637 return 1;
75638 return 0;
75639 }
75640
75641 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75642 +#ifdef CONFIG_MODULES
75643 +static inline int is_module_text(unsigned long addr)
75644 +{
75645 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
75646 + return 1;
75647 +
75648 + addr = ktla_ktva(addr);
75649 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
75650 +}
75651 +#else
75652 +static inline int is_module_text(unsigned long addr)
75653 +{
75654 + return 0;
75655 +}
75656 +#endif
75657 +#endif
75658 +
75659 static inline int is_kernel_text(unsigned long addr)
75660 {
75661 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
75662 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
75663
75664 static inline int is_kernel(unsigned long addr)
75665 {
75666 +
75667 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75668 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
75669 + return 1;
75670 +
75671 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
75672 +#else
75673 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
75674 +#endif
75675 +
75676 return 1;
75677 return in_gate_area_no_mm(addr);
75678 }
75679
75680 static int is_ksym_addr(unsigned long addr)
75681 {
75682 +
75683 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
75684 + if (is_module_text(addr))
75685 + return 0;
75686 +#endif
75687 +
75688 if (all_var)
75689 return is_kernel(addr);
75690
75691 @@ -470,7 +509,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
75692
75693 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
75694 {
75695 - iter->name[0] = '\0';
75696 iter->nameoff = get_symbol_offset(new_pos);
75697 iter->pos = new_pos;
75698 }
75699 @@ -518,6 +556,11 @@ static int s_show(struct seq_file *m, void *p)
75700 {
75701 struct kallsym_iter *iter = m->private;
75702
75703 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75704 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
75705 + return 0;
75706 +#endif
75707 +
75708 /* Some debugging symbols have no name. Ignore them. */
75709 if (!iter->name[0])
75710 return 0;
75711 @@ -531,6 +574,7 @@ static int s_show(struct seq_file *m, void *p)
75712 */
75713 type = iter->exported ? toupper(iter->type) :
75714 tolower(iter->type);
75715 +
75716 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
75717 type, iter->name, iter->module_name);
75718 } else
75719 @@ -556,7 +600,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
75720 struct kallsym_iter *iter;
75721 int ret;
75722
75723 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
75724 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
75725 if (!iter)
75726 return -ENOMEM;
75727 reset_iter(iter, 0);
75728 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
75729 index e30ac0f..3528cac 100644
75730 --- a/kernel/kcmp.c
75731 +++ b/kernel/kcmp.c
75732 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
75733 struct task_struct *task1, *task2;
75734 int ret;
75735
75736 +#ifdef CONFIG_GRKERNSEC
75737 + return -ENOSYS;
75738 +#endif
75739 +
75740 rcu_read_lock();
75741
75742 /*
75743 diff --git a/kernel/kexec.c b/kernel/kexec.c
75744 index 5e4bd78..00c5b91 100644
75745 --- a/kernel/kexec.c
75746 +++ b/kernel/kexec.c
75747 @@ -1045,7 +1045,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
75748 unsigned long flags)
75749 {
75750 struct compat_kexec_segment in;
75751 - struct kexec_segment out, __user *ksegments;
75752 + struct kexec_segment out;
75753 + struct kexec_segment __user *ksegments;
75754 unsigned long i, result;
75755
75756 /* Don't allow clients that don't understand the native
75757 diff --git a/kernel/kmod.c b/kernel/kmod.c
75758 index 0023a87..9c0c068 100644
75759 --- a/kernel/kmod.c
75760 +++ b/kernel/kmod.c
75761 @@ -74,7 +74,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
75762 kfree(info->argv);
75763 }
75764
75765 -static int call_modprobe(char *module_name, int wait)
75766 +static int call_modprobe(char *module_name, char *module_param, int wait)
75767 {
75768 static char *envp[] = {
75769 "HOME=/",
75770 @@ -83,7 +83,7 @@ static int call_modprobe(char *module_name, int wait)
75771 NULL
75772 };
75773
75774 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
75775 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
75776 if (!argv)
75777 goto out;
75778
75779 @@ -95,7 +95,8 @@ static int call_modprobe(char *module_name, int wait)
75780 argv[1] = "-q";
75781 argv[2] = "--";
75782 argv[3] = module_name; /* check free_modprobe_argv() */
75783 - argv[4] = NULL;
75784 + argv[4] = module_param;
75785 + argv[5] = NULL;
75786
75787 return call_usermodehelper_fns(modprobe_path, argv, envp,
75788 wait | UMH_KILLABLE, NULL, free_modprobe_argv, NULL);
75789 @@ -120,9 +121,8 @@ out:
75790 * If module auto-loading support is disabled then this function
75791 * becomes a no-operation.
75792 */
75793 -int __request_module(bool wait, const char *fmt, ...)
75794 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
75795 {
75796 - va_list args;
75797 char module_name[MODULE_NAME_LEN];
75798 unsigned int max_modprobes;
75799 int ret;
75800 @@ -130,9 +130,7 @@ int __request_module(bool wait, const char *fmt, ...)
75801 #define MAX_KMOD_CONCURRENT 50 /* Completely arbitrary value - KAO */
75802 static int kmod_loop_msg;
75803
75804 - va_start(args, fmt);
75805 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
75806 - va_end(args);
75807 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
75808 if (ret >= MODULE_NAME_LEN)
75809 return -ENAMETOOLONG;
75810
75811 @@ -140,6 +138,20 @@ int __request_module(bool wait, const char *fmt, ...)
75812 if (ret)
75813 return ret;
75814
75815 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75816 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75817 + /* hack to workaround consolekit/udisks stupidity */
75818 + read_lock(&tasklist_lock);
75819 + if (!strcmp(current->comm, "mount") &&
75820 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
75821 + read_unlock(&tasklist_lock);
75822 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
75823 + return -EPERM;
75824 + }
75825 + read_unlock(&tasklist_lock);
75826 + }
75827 +#endif
75828 +
75829 /* If modprobe needs a service that is in a module, we get a recursive
75830 * loop. Limit the number of running kmod threads to max_threads/2 or
75831 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
75832 @@ -168,11 +180,52 @@ int __request_module(bool wait, const char *fmt, ...)
75833
75834 trace_module_request(module_name, wait, _RET_IP_);
75835
75836 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75837 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
75838
75839 atomic_dec(&kmod_concurrent);
75840 return ret;
75841 }
75842 +
75843 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
75844 +{
75845 + va_list args;
75846 + int ret;
75847 +
75848 + va_start(args, fmt);
75849 + ret = ____request_module(wait, module_param, fmt, args);
75850 + va_end(args);
75851 +
75852 + return ret;
75853 +}
75854 +
75855 +int __request_module(bool wait, const char *fmt, ...)
75856 +{
75857 + va_list args;
75858 + int ret;
75859 +
75860 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
75861 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
75862 + char module_param[MODULE_NAME_LEN];
75863 +
75864 + memset(module_param, 0, sizeof(module_param));
75865 +
75866 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
75867 +
75868 + va_start(args, fmt);
75869 + ret = ____request_module(wait, module_param, fmt, args);
75870 + va_end(args);
75871 +
75872 + return ret;
75873 + }
75874 +#endif
75875 +
75876 + va_start(args, fmt);
75877 + ret = ____request_module(wait, NULL, fmt, args);
75878 + va_end(args);
75879 +
75880 + return ret;
75881 +}
75882 +
75883 EXPORT_SYMBOL(__request_module);
75884 #endif /* CONFIG_MODULES */
75885
75886 @@ -283,7 +336,7 @@ static int wait_for_helper(void *data)
75887 *
75888 * Thus the __user pointer cast is valid here.
75889 */
75890 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
75891 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
75892
75893 /*
75894 * If ret is 0, either ____call_usermodehelper failed and the
75895 @@ -635,7 +688,7 @@ EXPORT_SYMBOL(call_usermodehelper_fns);
75896 static int proc_cap_handler(struct ctl_table *table, int write,
75897 void __user *buffer, size_t *lenp, loff_t *ppos)
75898 {
75899 - struct ctl_table t;
75900 + ctl_table_no_const t;
75901 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
75902 kernel_cap_t new_cap;
75903 int err, i;
75904 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
75905 index 098f396..fe85ff1 100644
75906 --- a/kernel/kprobes.c
75907 +++ b/kernel/kprobes.c
75908 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
75909 * kernel image and loaded module images reside. This is required
75910 * so x86_64 can correctly handle the %rip-relative fixups.
75911 */
75912 - kip->insns = module_alloc(PAGE_SIZE);
75913 + kip->insns = module_alloc_exec(PAGE_SIZE);
75914 if (!kip->insns) {
75915 kfree(kip);
75916 return NULL;
75917 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
75918 */
75919 if (!list_is_singular(&kip->list)) {
75920 list_del(&kip->list);
75921 - module_free(NULL, kip->insns);
75922 + module_free_exec(NULL, kip->insns);
75923 kfree(kip);
75924 }
75925 return 1;
75926 @@ -2063,7 +2063,7 @@ static int __init init_kprobes(void)
75927 {
75928 int i, err = 0;
75929 unsigned long offset = 0, size = 0;
75930 - char *modname, namebuf[128];
75931 + char *modname, namebuf[KSYM_NAME_LEN];
75932 const char *symbol_name;
75933 void *addr;
75934 struct kprobe_blackpoint *kb;
75935 @@ -2148,11 +2148,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
75936 kprobe_type = "k";
75937
75938 if (sym)
75939 - seq_printf(pi, "%p %s %s+0x%x %s ",
75940 + seq_printf(pi, "%pK %s %s+0x%x %s ",
75941 p->addr, kprobe_type, sym, offset,
75942 (modname ? modname : " "));
75943 else
75944 - seq_printf(pi, "%p %s %p ",
75945 + seq_printf(pi, "%pK %s %pK ",
75946 p->addr, kprobe_type, p->addr);
75947
75948 if (!pp)
75949 @@ -2190,7 +2190,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
75950 const char *sym = NULL;
75951 unsigned int i = *(loff_t *) v;
75952 unsigned long offset = 0;
75953 - char *modname, namebuf[128];
75954 + char *modname, namebuf[KSYM_NAME_LEN];
75955
75956 head = &kprobe_table[i];
75957 preempt_disable();
75958 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
75959 index 6ada93c..dce7d5d 100644
75960 --- a/kernel/ksysfs.c
75961 +++ b/kernel/ksysfs.c
75962 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
75963 {
75964 if (count+1 > UEVENT_HELPER_PATH_LEN)
75965 return -ENOENT;
75966 + if (!capable(CAP_SYS_ADMIN))
75967 + return -EPERM;
75968 memcpy(uevent_helper, buf, count);
75969 uevent_helper[count] = '\0';
75970 if (count && uevent_helper[count-1] == '\n')
75971 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
75972 return count;
75973 }
75974
75975 -static struct bin_attribute notes_attr = {
75976 +static bin_attribute_no_const notes_attr __read_only = {
75977 .attr = {
75978 .name = "notes",
75979 .mode = S_IRUGO,
75980 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
75981 index 7981e5b..7f2105c 100644
75982 --- a/kernel/lockdep.c
75983 +++ b/kernel/lockdep.c
75984 @@ -590,6 +590,10 @@ static int static_obj(void *obj)
75985 end = (unsigned long) &_end,
75986 addr = (unsigned long) obj;
75987
75988 +#ifdef CONFIG_PAX_KERNEXEC
75989 + start = ktla_ktva(start);
75990 +#endif
75991 +
75992 /*
75993 * static variable?
75994 */
75995 @@ -730,6 +734,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
75996 if (!static_obj(lock->key)) {
75997 debug_locks_off();
75998 printk("INFO: trying to register non-static key.\n");
75999 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76000 printk("the code is fine but needs lockdep annotation.\n");
76001 printk("turning off the locking correctness validator.\n");
76002 dump_stack();
76003 @@ -3078,7 +3083,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76004 if (!class)
76005 return 0;
76006 }
76007 - atomic_inc((atomic_t *)&class->ops);
76008 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76009 if (very_verbose(class)) {
76010 printk("\nacquire class [%p] %s", class->key, class->name);
76011 if (class->name_version > 1)
76012 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76013 index b2c71c5..7b88d63 100644
76014 --- a/kernel/lockdep_proc.c
76015 +++ b/kernel/lockdep_proc.c
76016 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76017 return 0;
76018 }
76019
76020 - seq_printf(m, "%p", class->key);
76021 + seq_printf(m, "%pK", class->key);
76022 #ifdef CONFIG_DEBUG_LOCKDEP
76023 seq_printf(m, " OPS:%8ld", class->ops);
76024 #endif
76025 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76026
76027 list_for_each_entry(entry, &class->locks_after, entry) {
76028 if (entry->distance == 1) {
76029 - seq_printf(m, " -> [%p] ", entry->class->key);
76030 + seq_printf(m, " -> [%pK] ", entry->class->key);
76031 print_name(m, entry->class);
76032 seq_puts(m, "\n");
76033 }
76034 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76035 if (!class->key)
76036 continue;
76037
76038 - seq_printf(m, "[%p] ", class->key);
76039 + seq_printf(m, "[%pK] ", class->key);
76040 print_name(m, class);
76041 seq_puts(m, "\n");
76042 }
76043 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76044 if (!i)
76045 seq_line(m, '-', 40-namelen, namelen);
76046
76047 - snprintf(ip, sizeof(ip), "[<%p>]",
76048 + snprintf(ip, sizeof(ip), "[<%pK>]",
76049 (void *)class->contention_point[i]);
76050 seq_printf(m, "%40s %14lu %29s %pS\n",
76051 name, stats->contention_point[i],
76052 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76053 if (!i)
76054 seq_line(m, '-', 40-namelen, namelen);
76055
76056 - snprintf(ip, sizeof(ip), "[<%p>]",
76057 + snprintf(ip, sizeof(ip), "[<%pK>]",
76058 (void *)class->contending_point[i]);
76059 seq_printf(m, "%40s %14lu %29s %pS\n",
76060 name, stats->contending_point[i],
76061 diff --git a/kernel/module.c b/kernel/module.c
76062 index eab0827..f488603 100644
76063 --- a/kernel/module.c
76064 +++ b/kernel/module.c
76065 @@ -61,6 +61,7 @@
76066 #include <linux/pfn.h>
76067 #include <linux/bsearch.h>
76068 #include <linux/fips.h>
76069 +#include <linux/grsecurity.h>
76070 #include <uapi/linux/module.h>
76071 #include "module-internal.h"
76072
76073 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76074
76075 /* Bounds of module allocation, for speeding __module_address.
76076 * Protected by module_mutex. */
76077 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76078 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76079 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76080
76081 int register_module_notifier(struct notifier_block * nb)
76082 {
76083 @@ -322,7 +324,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76084 return true;
76085
76086 list_for_each_entry_rcu(mod, &modules, list) {
76087 - struct symsearch arr[] = {
76088 + struct symsearch modarr[] = {
76089 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76090 NOT_GPL_ONLY, false },
76091 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76092 @@ -347,7 +349,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76093 if (mod->state == MODULE_STATE_UNFORMED)
76094 continue;
76095
76096 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76097 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76098 return true;
76099 }
76100 return false;
76101 @@ -484,7 +486,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76102 static int percpu_modalloc(struct module *mod,
76103 unsigned long size, unsigned long align)
76104 {
76105 - if (align > PAGE_SIZE) {
76106 + if (align-1 >= PAGE_SIZE) {
76107 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76108 mod->name, align, PAGE_SIZE);
76109 align = PAGE_SIZE;
76110 @@ -1088,7 +1090,7 @@ struct module_attribute module_uevent =
76111 static ssize_t show_coresize(struct module_attribute *mattr,
76112 struct module_kobject *mk, char *buffer)
76113 {
76114 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76115 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76116 }
76117
76118 static struct module_attribute modinfo_coresize =
76119 @@ -1097,7 +1099,7 @@ static struct module_attribute modinfo_coresize =
76120 static ssize_t show_initsize(struct module_attribute *mattr,
76121 struct module_kobject *mk, char *buffer)
76122 {
76123 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76124 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76125 }
76126
76127 static struct module_attribute modinfo_initsize =
76128 @@ -1311,7 +1313,7 @@ resolve_symbol_wait(struct module *mod,
76129 */
76130 #ifdef CONFIG_SYSFS
76131
76132 -#ifdef CONFIG_KALLSYMS
76133 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76134 static inline bool sect_empty(const Elf_Shdr *sect)
76135 {
76136 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76137 @@ -1451,7 +1453,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76138 {
76139 unsigned int notes, loaded, i;
76140 struct module_notes_attrs *notes_attrs;
76141 - struct bin_attribute *nattr;
76142 + bin_attribute_no_const *nattr;
76143
76144 /* failed to create section attributes, so can't create notes */
76145 if (!mod->sect_attrs)
76146 @@ -1563,7 +1565,7 @@ static void del_usage_links(struct module *mod)
76147 static int module_add_modinfo_attrs(struct module *mod)
76148 {
76149 struct module_attribute *attr;
76150 - struct module_attribute *temp_attr;
76151 + module_attribute_no_const *temp_attr;
76152 int error = 0;
76153 int i;
76154
76155 @@ -1777,21 +1779,21 @@ static void set_section_ro_nx(void *base,
76156
76157 static void unset_module_core_ro_nx(struct module *mod)
76158 {
76159 - set_page_attributes(mod->module_core + mod->core_text_size,
76160 - mod->module_core + mod->core_size,
76161 + set_page_attributes(mod->module_core_rw,
76162 + mod->module_core_rw + mod->core_size_rw,
76163 set_memory_x);
76164 - set_page_attributes(mod->module_core,
76165 - mod->module_core + mod->core_ro_size,
76166 + set_page_attributes(mod->module_core_rx,
76167 + mod->module_core_rx + mod->core_size_rx,
76168 set_memory_rw);
76169 }
76170
76171 static void unset_module_init_ro_nx(struct module *mod)
76172 {
76173 - set_page_attributes(mod->module_init + mod->init_text_size,
76174 - mod->module_init + mod->init_size,
76175 + set_page_attributes(mod->module_init_rw,
76176 + mod->module_init_rw + mod->init_size_rw,
76177 set_memory_x);
76178 - set_page_attributes(mod->module_init,
76179 - mod->module_init + mod->init_ro_size,
76180 + set_page_attributes(mod->module_init_rx,
76181 + mod->module_init_rx + mod->init_size_rx,
76182 set_memory_rw);
76183 }
76184
76185 @@ -1804,14 +1806,14 @@ void set_all_modules_text_rw(void)
76186 list_for_each_entry_rcu(mod, &modules, list) {
76187 if (mod->state == MODULE_STATE_UNFORMED)
76188 continue;
76189 - if ((mod->module_core) && (mod->core_text_size)) {
76190 - set_page_attributes(mod->module_core,
76191 - mod->module_core + mod->core_text_size,
76192 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76193 + set_page_attributes(mod->module_core_rx,
76194 + mod->module_core_rx + mod->core_size_rx,
76195 set_memory_rw);
76196 }
76197 - if ((mod->module_init) && (mod->init_text_size)) {
76198 - set_page_attributes(mod->module_init,
76199 - mod->module_init + mod->init_text_size,
76200 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76201 + set_page_attributes(mod->module_init_rx,
76202 + mod->module_init_rx + mod->init_size_rx,
76203 set_memory_rw);
76204 }
76205 }
76206 @@ -1827,14 +1829,14 @@ void set_all_modules_text_ro(void)
76207 list_for_each_entry_rcu(mod, &modules, list) {
76208 if (mod->state == MODULE_STATE_UNFORMED)
76209 continue;
76210 - if ((mod->module_core) && (mod->core_text_size)) {
76211 - set_page_attributes(mod->module_core,
76212 - mod->module_core + mod->core_text_size,
76213 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76214 + set_page_attributes(mod->module_core_rx,
76215 + mod->module_core_rx + mod->core_size_rx,
76216 set_memory_ro);
76217 }
76218 - if ((mod->module_init) && (mod->init_text_size)) {
76219 - set_page_attributes(mod->module_init,
76220 - mod->module_init + mod->init_text_size,
76221 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76222 + set_page_attributes(mod->module_init_rx,
76223 + mod->module_init_rx + mod->init_size_rx,
76224 set_memory_ro);
76225 }
76226 }
76227 @@ -1880,16 +1882,19 @@ static void free_module(struct module *mod)
76228
76229 /* This may be NULL, but that's OK */
76230 unset_module_init_ro_nx(mod);
76231 - module_free(mod, mod->module_init);
76232 + module_free(mod, mod->module_init_rw);
76233 + module_free_exec(mod, mod->module_init_rx);
76234 kfree(mod->args);
76235 percpu_modfree(mod);
76236
76237 /* Free lock-classes: */
76238 - lockdep_free_key_range(mod->module_core, mod->core_size);
76239 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76240 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76241
76242 /* Finally, free the core (containing the module structure) */
76243 unset_module_core_ro_nx(mod);
76244 - module_free(mod, mod->module_core);
76245 + module_free_exec(mod, mod->module_core_rx);
76246 + module_free(mod, mod->module_core_rw);
76247
76248 #ifdef CONFIG_MPU
76249 update_protections(current->mm);
76250 @@ -1959,9 +1964,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76251 int ret = 0;
76252 const struct kernel_symbol *ksym;
76253
76254 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76255 + int is_fs_load = 0;
76256 + int register_filesystem_found = 0;
76257 + char *p;
76258 +
76259 + p = strstr(mod->args, "grsec_modharden_fs");
76260 + if (p) {
76261 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76262 + /* copy \0 as well */
76263 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76264 + is_fs_load = 1;
76265 + }
76266 +#endif
76267 +
76268 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76269 const char *name = info->strtab + sym[i].st_name;
76270
76271 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76272 + /* it's a real shame this will never get ripped and copied
76273 + upstream! ;(
76274 + */
76275 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76276 + register_filesystem_found = 1;
76277 +#endif
76278 +
76279 switch (sym[i].st_shndx) {
76280 case SHN_COMMON:
76281 /* We compiled with -fno-common. These are not
76282 @@ -1982,7 +2009,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76283 ksym = resolve_symbol_wait(mod, info, name);
76284 /* Ok if resolved. */
76285 if (ksym && !IS_ERR(ksym)) {
76286 + pax_open_kernel();
76287 sym[i].st_value = ksym->value;
76288 + pax_close_kernel();
76289 break;
76290 }
76291
76292 @@ -2001,11 +2030,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76293 secbase = (unsigned long)mod_percpu(mod);
76294 else
76295 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76296 + pax_open_kernel();
76297 sym[i].st_value += secbase;
76298 + pax_close_kernel();
76299 break;
76300 }
76301 }
76302
76303 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76304 + if (is_fs_load && !register_filesystem_found) {
76305 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76306 + ret = -EPERM;
76307 + }
76308 +#endif
76309 +
76310 return ret;
76311 }
76312
76313 @@ -2089,22 +2127,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76314 || s->sh_entsize != ~0UL
76315 || strstarts(sname, ".init"))
76316 continue;
76317 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76318 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76319 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76320 + else
76321 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76322 pr_debug("\t%s\n", sname);
76323 }
76324 - switch (m) {
76325 - case 0: /* executable */
76326 - mod->core_size = debug_align(mod->core_size);
76327 - mod->core_text_size = mod->core_size;
76328 - break;
76329 - case 1: /* RO: text and ro-data */
76330 - mod->core_size = debug_align(mod->core_size);
76331 - mod->core_ro_size = mod->core_size;
76332 - break;
76333 - case 3: /* whole core */
76334 - mod->core_size = debug_align(mod->core_size);
76335 - break;
76336 - }
76337 }
76338
76339 pr_debug("Init section allocation order:\n");
76340 @@ -2118,23 +2146,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76341 || s->sh_entsize != ~0UL
76342 || !strstarts(sname, ".init"))
76343 continue;
76344 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76345 - | INIT_OFFSET_MASK);
76346 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76347 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76348 + else
76349 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76350 + s->sh_entsize |= INIT_OFFSET_MASK;
76351 pr_debug("\t%s\n", sname);
76352 }
76353 - switch (m) {
76354 - case 0: /* executable */
76355 - mod->init_size = debug_align(mod->init_size);
76356 - mod->init_text_size = mod->init_size;
76357 - break;
76358 - case 1: /* RO: text and ro-data */
76359 - mod->init_size = debug_align(mod->init_size);
76360 - mod->init_ro_size = mod->init_size;
76361 - break;
76362 - case 3: /* whole init */
76363 - mod->init_size = debug_align(mod->init_size);
76364 - break;
76365 - }
76366 }
76367 }
76368
76369 @@ -2306,7 +2324,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76370
76371 /* Put symbol section at end of init part of module. */
76372 symsect->sh_flags |= SHF_ALLOC;
76373 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76374 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76375 info->index.sym) | INIT_OFFSET_MASK;
76376 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76377
76378 @@ -2323,13 +2341,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76379 }
76380
76381 /* Append room for core symbols at end of core part. */
76382 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76383 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76384 - mod->core_size += strtab_size;
76385 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76386 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76387 + mod->core_size_rx += strtab_size;
76388
76389 /* Put string table section at end of init part of module. */
76390 strsect->sh_flags |= SHF_ALLOC;
76391 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76392 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76393 info->index.str) | INIT_OFFSET_MASK;
76394 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76395 }
76396 @@ -2347,12 +2365,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76397 /* Make sure we get permanent strtab: don't use info->strtab. */
76398 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76399
76400 + pax_open_kernel();
76401 +
76402 /* Set types up while we still have access to sections. */
76403 for (i = 0; i < mod->num_symtab; i++)
76404 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76405
76406 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76407 - mod->core_strtab = s = mod->module_core + info->stroffs;
76408 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76409 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76410 src = mod->symtab;
76411 for (ndst = i = 0; i < mod->num_symtab; i++) {
76412 if (i == 0 ||
76413 @@ -2364,6 +2384,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76414 }
76415 }
76416 mod->core_num_syms = ndst;
76417 +
76418 + pax_close_kernel();
76419 }
76420 #else
76421 static inline void layout_symtab(struct module *mod, struct load_info *info)
76422 @@ -2397,17 +2419,33 @@ void * __weak module_alloc(unsigned long size)
76423 return vmalloc_exec(size);
76424 }
76425
76426 -static void *module_alloc_update_bounds(unsigned long size)
76427 +static void *module_alloc_update_bounds_rw(unsigned long size)
76428 {
76429 void *ret = module_alloc(size);
76430
76431 if (ret) {
76432 mutex_lock(&module_mutex);
76433 /* Update module bounds. */
76434 - if ((unsigned long)ret < module_addr_min)
76435 - module_addr_min = (unsigned long)ret;
76436 - if ((unsigned long)ret + size > module_addr_max)
76437 - module_addr_max = (unsigned long)ret + size;
76438 + if ((unsigned long)ret < module_addr_min_rw)
76439 + module_addr_min_rw = (unsigned long)ret;
76440 + if ((unsigned long)ret + size > module_addr_max_rw)
76441 + module_addr_max_rw = (unsigned long)ret + size;
76442 + mutex_unlock(&module_mutex);
76443 + }
76444 + return ret;
76445 +}
76446 +
76447 +static void *module_alloc_update_bounds_rx(unsigned long size)
76448 +{
76449 + void *ret = module_alloc_exec(size);
76450 +
76451 + if (ret) {
76452 + mutex_lock(&module_mutex);
76453 + /* Update module bounds. */
76454 + if ((unsigned long)ret < module_addr_min_rx)
76455 + module_addr_min_rx = (unsigned long)ret;
76456 + if ((unsigned long)ret + size > module_addr_max_rx)
76457 + module_addr_max_rx = (unsigned long)ret + size;
76458 mutex_unlock(&module_mutex);
76459 }
76460 return ret;
76461 @@ -2683,8 +2721,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76462 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76463 {
76464 const char *modmagic = get_modinfo(info, "vermagic");
76465 + const char *license = get_modinfo(info, "license");
76466 int err;
76467
76468 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76469 + if (!license || !license_is_gpl_compatible(license))
76470 + return -ENOEXEC;
76471 +#endif
76472 +
76473 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76474 modmagic = NULL;
76475
76476 @@ -2710,7 +2754,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76477 }
76478
76479 /* Set up license info based on the info section */
76480 - set_license(mod, get_modinfo(info, "license"));
76481 + set_license(mod, license);
76482
76483 return 0;
76484 }
76485 @@ -2804,7 +2848,7 @@ static int move_module(struct module *mod, struct load_info *info)
76486 void *ptr;
76487
76488 /* Do the allocs. */
76489 - ptr = module_alloc_update_bounds(mod->core_size);
76490 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76491 /*
76492 * The pointer to this block is stored in the module structure
76493 * which is inside the block. Just mark it as not being a
76494 @@ -2814,11 +2858,11 @@ static int move_module(struct module *mod, struct load_info *info)
76495 if (!ptr)
76496 return -ENOMEM;
76497
76498 - memset(ptr, 0, mod->core_size);
76499 - mod->module_core = ptr;
76500 + memset(ptr, 0, mod->core_size_rw);
76501 + mod->module_core_rw = ptr;
76502
76503 - if (mod->init_size) {
76504 - ptr = module_alloc_update_bounds(mod->init_size);
76505 + if (mod->init_size_rw) {
76506 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76507 /*
76508 * The pointer to this block is stored in the module structure
76509 * which is inside the block. This block doesn't need to be
76510 @@ -2827,13 +2871,45 @@ static int move_module(struct module *mod, struct load_info *info)
76511 */
76512 kmemleak_ignore(ptr);
76513 if (!ptr) {
76514 - module_free(mod, mod->module_core);
76515 + module_free(mod, mod->module_core_rw);
76516 return -ENOMEM;
76517 }
76518 - memset(ptr, 0, mod->init_size);
76519 - mod->module_init = ptr;
76520 + memset(ptr, 0, mod->init_size_rw);
76521 + mod->module_init_rw = ptr;
76522 } else
76523 - mod->module_init = NULL;
76524 + mod->module_init_rw = NULL;
76525 +
76526 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76527 + kmemleak_not_leak(ptr);
76528 + if (!ptr) {
76529 + if (mod->module_init_rw)
76530 + module_free(mod, mod->module_init_rw);
76531 + module_free(mod, mod->module_core_rw);
76532 + return -ENOMEM;
76533 + }
76534 +
76535 + pax_open_kernel();
76536 + memset(ptr, 0, mod->core_size_rx);
76537 + pax_close_kernel();
76538 + mod->module_core_rx = ptr;
76539 +
76540 + if (mod->init_size_rx) {
76541 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76542 + kmemleak_ignore(ptr);
76543 + if (!ptr && mod->init_size_rx) {
76544 + module_free_exec(mod, mod->module_core_rx);
76545 + if (mod->module_init_rw)
76546 + module_free(mod, mod->module_init_rw);
76547 + module_free(mod, mod->module_core_rw);
76548 + return -ENOMEM;
76549 + }
76550 +
76551 + pax_open_kernel();
76552 + memset(ptr, 0, mod->init_size_rx);
76553 + pax_close_kernel();
76554 + mod->module_init_rx = ptr;
76555 + } else
76556 + mod->module_init_rx = NULL;
76557
76558 /* Transfer each section which specifies SHF_ALLOC */
76559 pr_debug("final section addresses:\n");
76560 @@ -2844,16 +2920,45 @@ static int move_module(struct module *mod, struct load_info *info)
76561 if (!(shdr->sh_flags & SHF_ALLOC))
76562 continue;
76563
76564 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76565 - dest = mod->module_init
76566 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76567 - else
76568 - dest = mod->module_core + shdr->sh_entsize;
76569 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76570 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76571 + dest = mod->module_init_rw
76572 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76573 + else
76574 + dest = mod->module_init_rx
76575 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76576 + } else {
76577 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76578 + dest = mod->module_core_rw + shdr->sh_entsize;
76579 + else
76580 + dest = mod->module_core_rx + shdr->sh_entsize;
76581 + }
76582 +
76583 + if (shdr->sh_type != SHT_NOBITS) {
76584 +
76585 +#ifdef CONFIG_PAX_KERNEXEC
76586 +#ifdef CONFIG_X86_64
76587 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76588 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76589 +#endif
76590 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76591 + pax_open_kernel();
76592 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76593 + pax_close_kernel();
76594 + } else
76595 +#endif
76596
76597 - if (shdr->sh_type != SHT_NOBITS)
76598 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76599 + }
76600 /* Update sh_addr to point to copy in image. */
76601 - shdr->sh_addr = (unsigned long)dest;
76602 +
76603 +#ifdef CONFIG_PAX_KERNEXEC
76604 + if (shdr->sh_flags & SHF_EXECINSTR)
76605 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76606 + else
76607 +#endif
76608 +
76609 + shdr->sh_addr = (unsigned long)dest;
76610 pr_debug("\t0x%lx %s\n",
76611 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76612 }
76613 @@ -2908,12 +3013,12 @@ static void flush_module_icache(const struct module *mod)
76614 * Do it before processing of module parameters, so the module
76615 * can provide parameter accessor functions of its own.
76616 */
76617 - if (mod->module_init)
76618 - flush_icache_range((unsigned long)mod->module_init,
76619 - (unsigned long)mod->module_init
76620 - + mod->init_size);
76621 - flush_icache_range((unsigned long)mod->module_core,
76622 - (unsigned long)mod->module_core + mod->core_size);
76623 + if (mod->module_init_rx)
76624 + flush_icache_range((unsigned long)mod->module_init_rx,
76625 + (unsigned long)mod->module_init_rx
76626 + + mod->init_size_rx);
76627 + flush_icache_range((unsigned long)mod->module_core_rx,
76628 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
76629
76630 set_fs(old_fs);
76631 }
76632 @@ -2983,8 +3088,10 @@ out:
76633 static void module_deallocate(struct module *mod, struct load_info *info)
76634 {
76635 percpu_modfree(mod);
76636 - module_free(mod, mod->module_init);
76637 - module_free(mod, mod->module_core);
76638 + module_free_exec(mod, mod->module_init_rx);
76639 + module_free_exec(mod, mod->module_core_rx);
76640 + module_free(mod, mod->module_init_rw);
76641 + module_free(mod, mod->module_core_rw);
76642 }
76643
76644 int __weak module_finalize(const Elf_Ehdr *hdr,
76645 @@ -2997,7 +3104,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
76646 static int post_relocation(struct module *mod, const struct load_info *info)
76647 {
76648 /* Sort exception table now relocations are done. */
76649 + pax_open_kernel();
76650 sort_extable(mod->extable, mod->extable + mod->num_exentries);
76651 + pax_close_kernel();
76652
76653 /* Copy relocated percpu area over. */
76654 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
76655 @@ -3051,16 +3160,16 @@ static int do_init_module(struct module *mod)
76656 MODULE_STATE_COMING, mod);
76657
76658 /* Set RO and NX regions for core */
76659 - set_section_ro_nx(mod->module_core,
76660 - mod->core_text_size,
76661 - mod->core_ro_size,
76662 - mod->core_size);
76663 + set_section_ro_nx(mod->module_core_rx,
76664 + mod->core_size_rx,
76665 + mod->core_size_rx,
76666 + mod->core_size_rx);
76667
76668 /* Set RO and NX regions for init */
76669 - set_section_ro_nx(mod->module_init,
76670 - mod->init_text_size,
76671 - mod->init_ro_size,
76672 - mod->init_size);
76673 + set_section_ro_nx(mod->module_init_rx,
76674 + mod->init_size_rx,
76675 + mod->init_size_rx,
76676 + mod->init_size_rx);
76677
76678 do_mod_ctors(mod);
76679 /* Start the module */
76680 @@ -3122,11 +3231,12 @@ static int do_init_module(struct module *mod)
76681 mod->strtab = mod->core_strtab;
76682 #endif
76683 unset_module_init_ro_nx(mod);
76684 - module_free(mod, mod->module_init);
76685 - mod->module_init = NULL;
76686 - mod->init_size = 0;
76687 - mod->init_ro_size = 0;
76688 - mod->init_text_size = 0;
76689 + module_free(mod, mod->module_init_rw);
76690 + module_free_exec(mod, mod->module_init_rx);
76691 + mod->module_init_rw = NULL;
76692 + mod->module_init_rx = NULL;
76693 + mod->init_size_rw = 0;
76694 + mod->init_size_rx = 0;
76695 mutex_unlock(&module_mutex);
76696 wake_up_all(&module_wq);
76697
76698 @@ -3209,9 +3319,38 @@ again:
76699 if (err)
76700 goto free_unload;
76701
76702 + /* Now copy in args */
76703 + mod->args = strndup_user(uargs, ~0UL >> 1);
76704 + if (IS_ERR(mod->args)) {
76705 + err = PTR_ERR(mod->args);
76706 + goto free_unload;
76707 + }
76708 +
76709 /* Set up MODINFO_ATTR fields */
76710 setup_modinfo(mod, info);
76711
76712 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76713 + {
76714 + char *p, *p2;
76715 +
76716 + if (strstr(mod->args, "grsec_modharden_netdev")) {
76717 + 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);
76718 + err = -EPERM;
76719 + goto free_modinfo;
76720 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
76721 + p += sizeof("grsec_modharden_normal") - 1;
76722 + p2 = strstr(p, "_");
76723 + if (p2) {
76724 + *p2 = '\0';
76725 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
76726 + *p2 = '_';
76727 + }
76728 + err = -EPERM;
76729 + goto free_modinfo;
76730 + }
76731 + }
76732 +#endif
76733 +
76734 /* Fix up syms, so that st_value is a pointer to location. */
76735 err = simplify_symbols(mod, info);
76736 if (err < 0)
76737 @@ -3227,13 +3366,6 @@ again:
76738
76739 flush_module_icache(mod);
76740
76741 - /* Now copy in args */
76742 - mod->args = strndup_user(uargs, ~0UL >> 1);
76743 - if (IS_ERR(mod->args)) {
76744 - err = PTR_ERR(mod->args);
76745 - goto free_arch_cleanup;
76746 - }
76747 -
76748 dynamic_debug_setup(info->debug, info->num_debug);
76749
76750 mutex_lock(&module_mutex);
76751 @@ -3278,11 +3410,10 @@ again:
76752 mutex_unlock(&module_mutex);
76753 dynamic_debug_remove(info->debug);
76754 synchronize_sched();
76755 - kfree(mod->args);
76756 - free_arch_cleanup:
76757 module_arch_cleanup(mod);
76758 free_modinfo:
76759 free_modinfo(mod);
76760 + kfree(mod->args);
76761 free_unload:
76762 module_unload_free(mod);
76763 unlink_mod:
76764 @@ -3365,10 +3496,16 @@ static const char *get_ksymbol(struct module *mod,
76765 unsigned long nextval;
76766
76767 /* At worse, next value is at end of module */
76768 - if (within_module_init(addr, mod))
76769 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
76770 + if (within_module_init_rx(addr, mod))
76771 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
76772 + else if (within_module_init_rw(addr, mod))
76773 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
76774 + else if (within_module_core_rx(addr, mod))
76775 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
76776 + else if (within_module_core_rw(addr, mod))
76777 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
76778 else
76779 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
76780 + return NULL;
76781
76782 /* Scan for closest preceding symbol, and next symbol. (ELF
76783 starts real symbols at 1). */
76784 @@ -3621,7 +3758,7 @@ static int m_show(struct seq_file *m, void *p)
76785 return 0;
76786
76787 seq_printf(m, "%s %u",
76788 - mod->name, mod->init_size + mod->core_size);
76789 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
76790 print_unload_info(m, mod);
76791
76792 /* Informative for users. */
76793 @@ -3630,7 +3767,7 @@ static int m_show(struct seq_file *m, void *p)
76794 mod->state == MODULE_STATE_COMING ? "Loading":
76795 "Live");
76796 /* Used by oprofile and other similar tools. */
76797 - seq_printf(m, " 0x%pK", mod->module_core);
76798 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
76799
76800 /* Taints info */
76801 if (mod->taints)
76802 @@ -3666,7 +3803,17 @@ static const struct file_operations proc_modules_operations = {
76803
76804 static int __init proc_modules_init(void)
76805 {
76806 +#ifndef CONFIG_GRKERNSEC_HIDESYM
76807 +#ifdef CONFIG_GRKERNSEC_PROC_USER
76808 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76809 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76810 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
76811 +#else
76812 proc_create("modules", 0, NULL, &proc_modules_operations);
76813 +#endif
76814 +#else
76815 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
76816 +#endif
76817 return 0;
76818 }
76819 module_init(proc_modules_init);
76820 @@ -3727,14 +3874,14 @@ struct module *__module_address(unsigned long addr)
76821 {
76822 struct module *mod;
76823
76824 - if (addr < module_addr_min || addr > module_addr_max)
76825 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
76826 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
76827 return NULL;
76828
76829 list_for_each_entry_rcu(mod, &modules, list) {
76830 if (mod->state == MODULE_STATE_UNFORMED)
76831 continue;
76832 - if (within_module_core(addr, mod)
76833 - || within_module_init(addr, mod))
76834 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
76835 return mod;
76836 }
76837 return NULL;
76838 @@ -3769,11 +3916,20 @@ bool is_module_text_address(unsigned long addr)
76839 */
76840 struct module *__module_text_address(unsigned long addr)
76841 {
76842 - struct module *mod = __module_address(addr);
76843 + struct module *mod;
76844 +
76845 +#ifdef CONFIG_X86_32
76846 + addr = ktla_ktva(addr);
76847 +#endif
76848 +
76849 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
76850 + return NULL;
76851 +
76852 + mod = __module_address(addr);
76853 +
76854 if (mod) {
76855 /* Make sure it's within the text section. */
76856 - if (!within(addr, mod->module_init, mod->init_text_size)
76857 - && !within(addr, mod->module_core, mod->core_text_size))
76858 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
76859 mod = NULL;
76860 }
76861 return mod;
76862 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
76863 index 7e3443f..b2a1e6b 100644
76864 --- a/kernel/mutex-debug.c
76865 +++ b/kernel/mutex-debug.c
76866 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
76867 }
76868
76869 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76870 - struct thread_info *ti)
76871 + struct task_struct *task)
76872 {
76873 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
76874
76875 /* Mark the current thread as blocked on the lock: */
76876 - ti->task->blocked_on = waiter;
76877 + task->blocked_on = waiter;
76878 }
76879
76880 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76881 - struct thread_info *ti)
76882 + struct task_struct *task)
76883 {
76884 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
76885 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
76886 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
76887 - ti->task->blocked_on = NULL;
76888 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
76889 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
76890 + task->blocked_on = NULL;
76891
76892 list_del_init(&waiter->list);
76893 waiter->task = NULL;
76894 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
76895 index 0799fd3..d06ae3b 100644
76896 --- a/kernel/mutex-debug.h
76897 +++ b/kernel/mutex-debug.h
76898 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
76899 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
76900 extern void debug_mutex_add_waiter(struct mutex *lock,
76901 struct mutex_waiter *waiter,
76902 - struct thread_info *ti);
76903 + struct task_struct *task);
76904 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
76905 - struct thread_info *ti);
76906 + struct task_struct *task);
76907 extern void debug_mutex_unlock(struct mutex *lock);
76908 extern void debug_mutex_init(struct mutex *lock, const char *name,
76909 struct lock_class_key *key);
76910 diff --git a/kernel/mutex.c b/kernel/mutex.c
76911 index a307cc9..27fd2e9 100644
76912 --- a/kernel/mutex.c
76913 +++ b/kernel/mutex.c
76914 @@ -198,7 +198,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76915 spin_lock_mutex(&lock->wait_lock, flags);
76916
76917 debug_mutex_lock_common(lock, &waiter);
76918 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
76919 + debug_mutex_add_waiter(lock, &waiter, task);
76920
76921 /* add waiting tasks to the end of the waitqueue (FIFO): */
76922 list_add_tail(&waiter.list, &lock->wait_list);
76923 @@ -227,8 +227,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76924 * TASK_UNINTERRUPTIBLE case.)
76925 */
76926 if (unlikely(signal_pending_state(state, task))) {
76927 - mutex_remove_waiter(lock, &waiter,
76928 - task_thread_info(task));
76929 + mutex_remove_waiter(lock, &waiter, task);
76930 mutex_release(&lock->dep_map, 1, ip);
76931 spin_unlock_mutex(&lock->wait_lock, flags);
76932
76933 @@ -247,7 +246,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
76934 done:
76935 lock_acquired(&lock->dep_map, ip);
76936 /* got the lock - rejoice! */
76937 - mutex_remove_waiter(lock, &waiter, current_thread_info());
76938 + mutex_remove_waiter(lock, &waiter, task);
76939 mutex_set_owner(lock);
76940
76941 /* set it to 0 if there are no waiters left: */
76942 diff --git a/kernel/notifier.c b/kernel/notifier.c
76943 index 2d5cc4c..d9ea600 100644
76944 --- a/kernel/notifier.c
76945 +++ b/kernel/notifier.c
76946 @@ -5,6 +5,7 @@
76947 #include <linux/rcupdate.h>
76948 #include <linux/vmalloc.h>
76949 #include <linux/reboot.h>
76950 +#include <linux/mm.h>
76951
76952 /*
76953 * Notifier list for kernel code which wants to be called
76954 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
76955 while ((*nl) != NULL) {
76956 if (n->priority > (*nl)->priority)
76957 break;
76958 - nl = &((*nl)->next);
76959 + nl = (struct notifier_block **)&((*nl)->next);
76960 }
76961 - n->next = *nl;
76962 + pax_open_kernel();
76963 + *(const void **)&n->next = *nl;
76964 rcu_assign_pointer(*nl, n);
76965 + pax_close_kernel();
76966 return 0;
76967 }
76968
76969 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
76970 return 0;
76971 if (n->priority > (*nl)->priority)
76972 break;
76973 - nl = &((*nl)->next);
76974 + nl = (struct notifier_block **)&((*nl)->next);
76975 }
76976 - n->next = *nl;
76977 + pax_open_kernel();
76978 + *(const void **)&n->next = *nl;
76979 rcu_assign_pointer(*nl, n);
76980 + pax_close_kernel();
76981 return 0;
76982 }
76983
76984 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
76985 {
76986 while ((*nl) != NULL) {
76987 if ((*nl) == n) {
76988 + pax_open_kernel();
76989 rcu_assign_pointer(*nl, n->next);
76990 + pax_close_kernel();
76991 return 0;
76992 }
76993 - nl = &((*nl)->next);
76994 + nl = (struct notifier_block **)&((*nl)->next);
76995 }
76996 return -ENOENT;
76997 }
76998 diff --git a/kernel/panic.c b/kernel/panic.c
76999 index e1b2822..5edc1d9 100644
77000 --- a/kernel/panic.c
77001 +++ b/kernel/panic.c
77002 @@ -410,7 +410,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77003 const char *board;
77004
77005 printk(KERN_WARNING "------------[ cut here ]------------\n");
77006 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77007 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77008 board = dmi_get_system_info(DMI_PRODUCT_NAME);
77009 if (board)
77010 printk(KERN_WARNING "Hardware name: %s\n", board);
77011 @@ -465,7 +465,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77012 */
77013 void __stack_chk_fail(void)
77014 {
77015 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77016 + dump_stack();
77017 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77018 __builtin_return_address(0));
77019 }
77020 EXPORT_SYMBOL(__stack_chk_fail);
77021 diff --git a/kernel/pid.c b/kernel/pid.c
77022 index f2c6a68..4922d97 100644
77023 --- a/kernel/pid.c
77024 +++ b/kernel/pid.c
77025 @@ -33,6 +33,7 @@
77026 #include <linux/rculist.h>
77027 #include <linux/bootmem.h>
77028 #include <linux/hash.h>
77029 +#include <linux/security.h>
77030 #include <linux/pid_namespace.h>
77031 #include <linux/init_task.h>
77032 #include <linux/syscalls.h>
77033 @@ -46,7 +47,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77034
77035 int pid_max = PID_MAX_DEFAULT;
77036
77037 -#define RESERVED_PIDS 300
77038 +#define RESERVED_PIDS 500
77039
77040 int pid_max_min = RESERVED_PIDS + 1;
77041 int pid_max_max = PID_MAX_LIMIT;
77042 @@ -441,10 +442,18 @@ EXPORT_SYMBOL(pid_task);
77043 */
77044 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77045 {
77046 + struct task_struct *task;
77047 +
77048 rcu_lockdep_assert(rcu_read_lock_held(),
77049 "find_task_by_pid_ns() needs rcu_read_lock()"
77050 " protection");
77051 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77052 +
77053 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77054 +
77055 + if (gr_pid_is_chrooted(task))
77056 + return NULL;
77057 +
77058 + return task;
77059 }
77060
77061 struct task_struct *find_task_by_vpid(pid_t vnr)
77062 @@ -452,6 +461,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77063 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77064 }
77065
77066 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77067 +{
77068 + rcu_lockdep_assert(rcu_read_lock_held(),
77069 + "find_task_by_pid_ns() needs rcu_read_lock()"
77070 + " protection");
77071 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77072 +}
77073 +
77074 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77075 {
77076 struct pid *pid;
77077 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77078 index bea15bd..789f3d0 100644
77079 --- a/kernel/pid_namespace.c
77080 +++ b/kernel/pid_namespace.c
77081 @@ -249,7 +249,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77082 void __user *buffer, size_t *lenp, loff_t *ppos)
77083 {
77084 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77085 - struct ctl_table tmp = *table;
77086 + ctl_table_no_const tmp = *table;
77087
77088 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77089 return -EPERM;
77090 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77091 index 942ca27..111e609 100644
77092 --- a/kernel/posix-cpu-timers.c
77093 +++ b/kernel/posix-cpu-timers.c
77094 @@ -1576,14 +1576,14 @@ struct k_clock clock_posix_cpu = {
77095
77096 static __init int init_posix_cpu_timers(void)
77097 {
77098 - struct k_clock process = {
77099 + static struct k_clock process = {
77100 .clock_getres = process_cpu_clock_getres,
77101 .clock_get = process_cpu_clock_get,
77102 .timer_create = process_cpu_timer_create,
77103 .nsleep = process_cpu_nsleep,
77104 .nsleep_restart = process_cpu_nsleep_restart,
77105 };
77106 - struct k_clock thread = {
77107 + static struct k_clock thread = {
77108 .clock_getres = thread_cpu_clock_getres,
77109 .clock_get = thread_cpu_clock_get,
77110 .timer_create = thread_cpu_timer_create,
77111 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77112 index e885be1..380fe76 100644
77113 --- a/kernel/posix-timers.c
77114 +++ b/kernel/posix-timers.c
77115 @@ -43,6 +43,7 @@
77116 #include <linux/idr.h>
77117 #include <linux/posix-clock.h>
77118 #include <linux/posix-timers.h>
77119 +#include <linux/grsecurity.h>
77120 #include <linux/syscalls.h>
77121 #include <linux/wait.h>
77122 #include <linux/workqueue.h>
77123 @@ -129,7 +130,7 @@ static DEFINE_SPINLOCK(idr_lock);
77124 * which we beg off on and pass to do_sys_settimeofday().
77125 */
77126
77127 -static struct k_clock posix_clocks[MAX_CLOCKS];
77128 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77129
77130 /*
77131 * These ones are defined below.
77132 @@ -227,7 +228,7 @@ static int posix_get_boottime(const clockid_t which_clock, struct timespec *tp)
77133 */
77134 static __init int init_posix_timers(void)
77135 {
77136 - struct k_clock clock_realtime = {
77137 + static struct k_clock clock_realtime = {
77138 .clock_getres = hrtimer_get_res,
77139 .clock_get = posix_clock_realtime_get,
77140 .clock_set = posix_clock_realtime_set,
77141 @@ -239,7 +240,7 @@ static __init int init_posix_timers(void)
77142 .timer_get = common_timer_get,
77143 .timer_del = common_timer_del,
77144 };
77145 - struct k_clock clock_monotonic = {
77146 + static struct k_clock clock_monotonic = {
77147 .clock_getres = hrtimer_get_res,
77148 .clock_get = posix_ktime_get_ts,
77149 .nsleep = common_nsleep,
77150 @@ -249,19 +250,19 @@ static __init int init_posix_timers(void)
77151 .timer_get = common_timer_get,
77152 .timer_del = common_timer_del,
77153 };
77154 - struct k_clock clock_monotonic_raw = {
77155 + static struct k_clock clock_monotonic_raw = {
77156 .clock_getres = hrtimer_get_res,
77157 .clock_get = posix_get_monotonic_raw,
77158 };
77159 - struct k_clock clock_realtime_coarse = {
77160 + static struct k_clock clock_realtime_coarse = {
77161 .clock_getres = posix_get_coarse_res,
77162 .clock_get = posix_get_realtime_coarse,
77163 };
77164 - struct k_clock clock_monotonic_coarse = {
77165 + static struct k_clock clock_monotonic_coarse = {
77166 .clock_getres = posix_get_coarse_res,
77167 .clock_get = posix_get_monotonic_coarse,
77168 };
77169 - struct k_clock clock_boottime = {
77170 + static struct k_clock clock_boottime = {
77171 .clock_getres = hrtimer_get_res,
77172 .clock_get = posix_get_boottime,
77173 .nsleep = common_nsleep,
77174 @@ -473,7 +474,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77175 return;
77176 }
77177
77178 - posix_clocks[clock_id] = *new_clock;
77179 + posix_clocks[clock_id] = new_clock;
77180 }
77181 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77182
77183 @@ -519,9 +520,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77184 return (id & CLOCKFD_MASK) == CLOCKFD ?
77185 &clock_posix_dynamic : &clock_posix_cpu;
77186
77187 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77188 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77189 return NULL;
77190 - return &posix_clocks[id];
77191 + return posix_clocks[id];
77192 }
77193
77194 static int common_timer_create(struct k_itimer *new_timer)
77195 @@ -966,6 +967,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77196 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77197 return -EFAULT;
77198
77199 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77200 + have their clock_set fptr set to a nosettime dummy function
77201 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77202 + call common_clock_set, which calls do_sys_settimeofday, which
77203 + we hook
77204 + */
77205 +
77206 return kc->clock_set(which_clock, &new_tp);
77207 }
77208
77209 diff --git a/kernel/power/process.c b/kernel/power/process.c
77210 index d5a258b..4271191 100644
77211 --- a/kernel/power/process.c
77212 +++ b/kernel/power/process.c
77213 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77214 u64 elapsed_csecs64;
77215 unsigned int elapsed_csecs;
77216 bool wakeup = false;
77217 + bool timedout = false;
77218
77219 do_gettimeofday(&start);
77220
77221 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77222
77223 while (true) {
77224 todo = 0;
77225 + if (time_after(jiffies, end_time))
77226 + timedout = true;
77227 read_lock(&tasklist_lock);
77228 do_each_thread(g, p) {
77229 if (p == current || !freeze_task(p))
77230 continue;
77231
77232 - if (!freezer_should_skip(p))
77233 + if (!freezer_should_skip(p)) {
77234 todo++;
77235 + if (timedout) {
77236 + printk(KERN_ERR "Task refusing to freeze:\n");
77237 + sched_show_task(p);
77238 + }
77239 + }
77240 } while_each_thread(g, p);
77241 read_unlock(&tasklist_lock);
77242
77243 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77244 todo += wq_busy;
77245 }
77246
77247 - if (!todo || time_after(jiffies, end_time))
77248 + if (!todo || timedout)
77249 break;
77250
77251 if (pm_wakeup_pending()) {
77252 diff --git a/kernel/printk.c b/kernel/printk.c
77253 index 267ce78..2487112 100644
77254 --- a/kernel/printk.c
77255 +++ b/kernel/printk.c
77256 @@ -609,11 +609,17 @@ static unsigned int devkmsg_poll(struct file *file, poll_table *wait)
77257 return ret;
77258 }
77259
77260 +static int check_syslog_permissions(int type, bool from_file);
77261 +
77262 static int devkmsg_open(struct inode *inode, struct file *file)
77263 {
77264 struct devkmsg_user *user;
77265 int err;
77266
77267 + err = check_syslog_permissions(SYSLOG_ACTION_OPEN, SYSLOG_FROM_FILE);
77268 + if (err)
77269 + return err;
77270 +
77271 /* write-only does not need any file context */
77272 if ((file->f_flags & O_ACCMODE) == O_WRONLY)
77273 return 0;
77274 @@ -822,7 +828,7 @@ static int syslog_action_restricted(int type)
77275 if (dmesg_restrict)
77276 return 1;
77277 /* Unless restricted, we allow "read all" and "get buffer size" for everybody */
77278 - return type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77279 + return type != SYSLOG_ACTION_OPEN && type != SYSLOG_ACTION_READ_ALL && type != SYSLOG_ACTION_SIZE_BUFFER;
77280 }
77281
77282 static int check_syslog_permissions(int type, bool from_file)
77283 @@ -834,6 +840,11 @@ static int check_syslog_permissions(int type, bool from_file)
77284 if (from_file && type != SYSLOG_ACTION_OPEN)
77285 return 0;
77286
77287 +#ifdef CONFIG_GRKERNSEC_DMESG
77288 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77289 + return -EPERM;
77290 +#endif
77291 +
77292 if (syslog_action_restricted(type)) {
77293 if (capable(CAP_SYSLOG))
77294 return 0;
77295 diff --git a/kernel/profile.c b/kernel/profile.c
77296 index 1f39181..86093471 100644
77297 --- a/kernel/profile.c
77298 +++ b/kernel/profile.c
77299 @@ -40,7 +40,7 @@ struct profile_hit {
77300 /* Oprofile timer tick hook */
77301 static int (*timer_hook)(struct pt_regs *) __read_mostly;
77302
77303 -static atomic_t *prof_buffer;
77304 +static atomic_unchecked_t *prof_buffer;
77305 static unsigned long prof_len, prof_shift;
77306
77307 int prof_on __read_mostly;
77308 @@ -282,7 +282,7 @@ static void profile_flip_buffers(void)
77309 hits[i].pc = 0;
77310 continue;
77311 }
77312 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77313 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77314 hits[i].hits = hits[i].pc = 0;
77315 }
77316 }
77317 @@ -343,9 +343,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77318 * Add the current hit(s) and flush the write-queue out
77319 * to the global buffer:
77320 */
77321 - atomic_add(nr_hits, &prof_buffer[pc]);
77322 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77323 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77324 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77325 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77326 hits[i].pc = hits[i].hits = 0;
77327 }
77328 out:
77329 @@ -420,7 +420,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77330 {
77331 unsigned long pc;
77332 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77333 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77334 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77335 }
77336 #endif /* !CONFIG_SMP */
77337
77338 @@ -518,7 +518,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77339 return -EFAULT;
77340 buf++; p++; count--; read++;
77341 }
77342 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77343 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77344 if (copy_to_user(buf, (void *)pnt, count))
77345 return -EFAULT;
77346 read += count;
77347 @@ -549,7 +549,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77348 }
77349 #endif
77350 profile_discard_flip_buffers();
77351 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77352 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77353 return count;
77354 }
77355
77356 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77357 index 6cbeaae..cfe7ff0 100644
77358 --- a/kernel/ptrace.c
77359 +++ b/kernel/ptrace.c
77360 @@ -324,7 +324,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77361 if (seize)
77362 flags |= PT_SEIZED;
77363 rcu_read_lock();
77364 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77365 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77366 flags |= PT_PTRACE_CAP;
77367 rcu_read_unlock();
77368 task->ptrace = flags;
77369 @@ -535,7 +535,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77370 break;
77371 return -EIO;
77372 }
77373 - if (copy_to_user(dst, buf, retval))
77374 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77375 return -EFAULT;
77376 copied += retval;
77377 src += retval;
77378 @@ -720,7 +720,7 @@ int ptrace_request(struct task_struct *child, long request,
77379 bool seized = child->ptrace & PT_SEIZED;
77380 int ret = -EIO;
77381 siginfo_t siginfo, *si;
77382 - void __user *datavp = (void __user *) data;
77383 + void __user *datavp = (__force void __user *) data;
77384 unsigned long __user *datalp = datavp;
77385 unsigned long flags;
77386
77387 @@ -922,14 +922,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77388 goto out;
77389 }
77390
77391 + if (gr_handle_ptrace(child, request)) {
77392 + ret = -EPERM;
77393 + goto out_put_task_struct;
77394 + }
77395 +
77396 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77397 ret = ptrace_attach(child, request, addr, data);
77398 /*
77399 * Some architectures need to do book-keeping after
77400 * a ptrace attach.
77401 */
77402 - if (!ret)
77403 + if (!ret) {
77404 arch_ptrace_attach(child);
77405 + gr_audit_ptrace(child);
77406 + }
77407 goto out_put_task_struct;
77408 }
77409
77410 @@ -957,7 +964,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77411 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77412 if (copied != sizeof(tmp))
77413 return -EIO;
77414 - return put_user(tmp, (unsigned long __user *)data);
77415 + return put_user(tmp, (__force unsigned long __user *)data);
77416 }
77417
77418 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77419 @@ -1051,7 +1058,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77420 }
77421
77422 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77423 - compat_long_t addr, compat_long_t data)
77424 + compat_ulong_t addr, compat_ulong_t data)
77425 {
77426 struct task_struct *child;
77427 long ret;
77428 @@ -1067,14 +1074,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77429 goto out;
77430 }
77431
77432 + if (gr_handle_ptrace(child, request)) {
77433 + ret = -EPERM;
77434 + goto out_put_task_struct;
77435 + }
77436 +
77437 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77438 ret = ptrace_attach(child, request, addr, data);
77439 /*
77440 * Some architectures need to do book-keeping after
77441 * a ptrace attach.
77442 */
77443 - if (!ret)
77444 + if (!ret) {
77445 arch_ptrace_attach(child);
77446 + gr_audit_ptrace(child);
77447 + }
77448 goto out_put_task_struct;
77449 }
77450
77451 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77452 index e7dce58..ad0d7b7 100644
77453 --- a/kernel/rcutiny.c
77454 +++ b/kernel/rcutiny.c
77455 @@ -46,7 +46,7 @@
77456 struct rcu_ctrlblk;
77457 static void invoke_rcu_callbacks(void);
77458 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77459 -static void rcu_process_callbacks(struct softirq_action *unused);
77460 +static void rcu_process_callbacks(void);
77461 static void __call_rcu(struct rcu_head *head,
77462 void (*func)(struct rcu_head *rcu),
77463 struct rcu_ctrlblk *rcp);
77464 @@ -310,7 +310,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77465 rcu_is_callbacks_kthread()));
77466 }
77467
77468 -static void rcu_process_callbacks(struct softirq_action *unused)
77469 +static void rcu_process_callbacks(void)
77470 {
77471 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77472 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77473 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77474 index f85016a..91cb03b 100644
77475 --- a/kernel/rcutiny_plugin.h
77476 +++ b/kernel/rcutiny_plugin.h
77477 @@ -896,7 +896,7 @@ static int rcu_kthread(void *arg)
77478 have_rcu_kthread_work = morework;
77479 local_irq_restore(flags);
77480 if (work)
77481 - rcu_process_callbacks(NULL);
77482 + rcu_process_callbacks();
77483 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77484 }
77485
77486 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77487 index 31dea01..ad91ffb 100644
77488 --- a/kernel/rcutorture.c
77489 +++ b/kernel/rcutorture.c
77490 @@ -163,12 +163,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77491 { 0 };
77492 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77493 { 0 };
77494 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77495 -static atomic_t n_rcu_torture_alloc;
77496 -static atomic_t n_rcu_torture_alloc_fail;
77497 -static atomic_t n_rcu_torture_free;
77498 -static atomic_t n_rcu_torture_mberror;
77499 -static atomic_t n_rcu_torture_error;
77500 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77501 +static atomic_unchecked_t n_rcu_torture_alloc;
77502 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77503 +static atomic_unchecked_t n_rcu_torture_free;
77504 +static atomic_unchecked_t n_rcu_torture_mberror;
77505 +static atomic_unchecked_t n_rcu_torture_error;
77506 static long n_rcu_torture_barrier_error;
77507 static long n_rcu_torture_boost_ktrerror;
77508 static long n_rcu_torture_boost_rterror;
77509 @@ -272,11 +272,11 @@ rcu_torture_alloc(void)
77510
77511 spin_lock_bh(&rcu_torture_lock);
77512 if (list_empty(&rcu_torture_freelist)) {
77513 - atomic_inc(&n_rcu_torture_alloc_fail);
77514 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77515 spin_unlock_bh(&rcu_torture_lock);
77516 return NULL;
77517 }
77518 - atomic_inc(&n_rcu_torture_alloc);
77519 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77520 p = rcu_torture_freelist.next;
77521 list_del_init(p);
77522 spin_unlock_bh(&rcu_torture_lock);
77523 @@ -289,7 +289,7 @@ rcu_torture_alloc(void)
77524 static void
77525 rcu_torture_free(struct rcu_torture *p)
77526 {
77527 - atomic_inc(&n_rcu_torture_free);
77528 + atomic_inc_unchecked(&n_rcu_torture_free);
77529 spin_lock_bh(&rcu_torture_lock);
77530 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77531 spin_unlock_bh(&rcu_torture_lock);
77532 @@ -409,7 +409,7 @@ rcu_torture_cb(struct rcu_head *p)
77533 i = rp->rtort_pipe_count;
77534 if (i > RCU_TORTURE_PIPE_LEN)
77535 i = RCU_TORTURE_PIPE_LEN;
77536 - atomic_inc(&rcu_torture_wcount[i]);
77537 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77538 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77539 rp->rtort_mbtest = 0;
77540 rcu_torture_free(rp);
77541 @@ -457,7 +457,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77542 i = rp->rtort_pipe_count;
77543 if (i > RCU_TORTURE_PIPE_LEN)
77544 i = RCU_TORTURE_PIPE_LEN;
77545 - atomic_inc(&rcu_torture_wcount[i]);
77546 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77547 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77548 rp->rtort_mbtest = 0;
77549 list_del(&rp->rtort_free);
77550 @@ -975,7 +975,7 @@ rcu_torture_writer(void *arg)
77551 i = old_rp->rtort_pipe_count;
77552 if (i > RCU_TORTURE_PIPE_LEN)
77553 i = RCU_TORTURE_PIPE_LEN;
77554 - atomic_inc(&rcu_torture_wcount[i]);
77555 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77556 old_rp->rtort_pipe_count++;
77557 cur_ops->deferred_free(old_rp);
77558 }
77559 @@ -1060,7 +1060,7 @@ static void rcu_torture_timer(unsigned long unused)
77560 }
77561 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77562 if (p->rtort_mbtest == 0)
77563 - atomic_inc(&n_rcu_torture_mberror);
77564 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77565 spin_lock(&rand_lock);
77566 cur_ops->read_delay(&rand);
77567 n_rcu_torture_timers++;
77568 @@ -1124,7 +1124,7 @@ rcu_torture_reader(void *arg)
77569 }
77570 do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
77571 if (p->rtort_mbtest == 0)
77572 - atomic_inc(&n_rcu_torture_mberror);
77573 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77574 cur_ops->read_delay(&rand);
77575 preempt_disable();
77576 pipe_count = p->rtort_pipe_count;
77577 @@ -1183,11 +1183,11 @@ rcu_torture_printk(char *page)
77578 rcu_torture_current,
77579 rcu_torture_current_version,
77580 list_empty(&rcu_torture_freelist),
77581 - atomic_read(&n_rcu_torture_alloc),
77582 - atomic_read(&n_rcu_torture_alloc_fail),
77583 - atomic_read(&n_rcu_torture_free));
77584 + atomic_read_unchecked(&n_rcu_torture_alloc),
77585 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77586 + atomic_read_unchecked(&n_rcu_torture_free));
77587 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77588 - atomic_read(&n_rcu_torture_mberror),
77589 + atomic_read_unchecked(&n_rcu_torture_mberror),
77590 n_rcu_torture_boost_ktrerror,
77591 n_rcu_torture_boost_rterror);
77592 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77593 @@ -1206,14 +1206,14 @@ rcu_torture_printk(char *page)
77594 n_barrier_attempts,
77595 n_rcu_torture_barrier_error);
77596 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77597 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77598 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77599 n_rcu_torture_barrier_error != 0 ||
77600 n_rcu_torture_boost_ktrerror != 0 ||
77601 n_rcu_torture_boost_rterror != 0 ||
77602 n_rcu_torture_boost_failure != 0 ||
77603 i > 1) {
77604 cnt += sprintf(&page[cnt], "!!! ");
77605 - atomic_inc(&n_rcu_torture_error);
77606 + atomic_inc_unchecked(&n_rcu_torture_error);
77607 WARN_ON_ONCE(1);
77608 }
77609 cnt += sprintf(&page[cnt], "Reader Pipe: ");
77610 @@ -1227,7 +1227,7 @@ rcu_torture_printk(char *page)
77611 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
77612 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77613 cnt += sprintf(&page[cnt], " %d",
77614 - atomic_read(&rcu_torture_wcount[i]));
77615 + atomic_read_unchecked(&rcu_torture_wcount[i]));
77616 }
77617 cnt += sprintf(&page[cnt], "\n");
77618 if (cur_ops->stats)
77619 @@ -1920,7 +1920,7 @@ rcu_torture_cleanup(void)
77620
77621 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
77622
77623 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77624 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
77625 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
77626 else if (n_online_successes != n_online_attempts ||
77627 n_offline_successes != n_offline_attempts)
77628 @@ -1989,18 +1989,18 @@ rcu_torture_init(void)
77629
77630 rcu_torture_current = NULL;
77631 rcu_torture_current_version = 0;
77632 - atomic_set(&n_rcu_torture_alloc, 0);
77633 - atomic_set(&n_rcu_torture_alloc_fail, 0);
77634 - atomic_set(&n_rcu_torture_free, 0);
77635 - atomic_set(&n_rcu_torture_mberror, 0);
77636 - atomic_set(&n_rcu_torture_error, 0);
77637 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
77638 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
77639 + atomic_set_unchecked(&n_rcu_torture_free, 0);
77640 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
77641 + atomic_set_unchecked(&n_rcu_torture_error, 0);
77642 n_rcu_torture_barrier_error = 0;
77643 n_rcu_torture_boost_ktrerror = 0;
77644 n_rcu_torture_boost_rterror = 0;
77645 n_rcu_torture_boost_failure = 0;
77646 n_rcu_torture_boosts = 0;
77647 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
77648 - atomic_set(&rcu_torture_wcount[i], 0);
77649 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
77650 for_each_possible_cpu(cpu) {
77651 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
77652 per_cpu(rcu_torture_count, cpu)[i] = 0;
77653 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
77654 index e441b77..dd54f17 100644
77655 --- a/kernel/rcutree.c
77656 +++ b/kernel/rcutree.c
77657 @@ -349,9 +349,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
77658 rcu_prepare_for_idle(smp_processor_id());
77659 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77660 smp_mb__before_atomic_inc(); /* See above. */
77661 - atomic_inc(&rdtp->dynticks);
77662 + atomic_inc_unchecked(&rdtp->dynticks);
77663 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
77664 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77665 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77666
77667 /*
77668 * It is illegal to enter an extended quiescent state while
77669 @@ -487,10 +487,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
77670 int user)
77671 {
77672 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
77673 - atomic_inc(&rdtp->dynticks);
77674 + atomic_inc_unchecked(&rdtp->dynticks);
77675 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77676 smp_mb__after_atomic_inc(); /* See above. */
77677 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77678 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77679 rcu_cleanup_after_idle(smp_processor_id());
77680 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
77681 if (!user && !is_idle_task(current)) {
77682 @@ -629,14 +629,14 @@ void rcu_nmi_enter(void)
77683 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
77684
77685 if (rdtp->dynticks_nmi_nesting == 0 &&
77686 - (atomic_read(&rdtp->dynticks) & 0x1))
77687 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
77688 return;
77689 rdtp->dynticks_nmi_nesting++;
77690 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
77691 - atomic_inc(&rdtp->dynticks);
77692 + atomic_inc_unchecked(&rdtp->dynticks);
77693 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
77694 smp_mb__after_atomic_inc(); /* See above. */
77695 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
77696 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
77697 }
77698
77699 /**
77700 @@ -655,9 +655,9 @@ void rcu_nmi_exit(void)
77701 return;
77702 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
77703 smp_mb__before_atomic_inc(); /* See above. */
77704 - atomic_inc(&rdtp->dynticks);
77705 + atomic_inc_unchecked(&rdtp->dynticks);
77706 smp_mb__after_atomic_inc(); /* Force delay to next write. */
77707 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
77708 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
77709 }
77710
77711 /**
77712 @@ -671,7 +671,7 @@ int rcu_is_cpu_idle(void)
77713 int ret;
77714
77715 preempt_disable();
77716 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77717 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
77718 preempt_enable();
77719 return ret;
77720 }
77721 @@ -739,7 +739,7 @@ int rcu_is_cpu_rrupt_from_idle(void)
77722 */
77723 static int dyntick_save_progress_counter(struct rcu_data *rdp)
77724 {
77725 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
77726 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77727 return (rdp->dynticks_snap & 0x1) == 0;
77728 }
77729
77730 @@ -754,7 +754,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
77731 unsigned int curr;
77732 unsigned int snap;
77733
77734 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
77735 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
77736 snap = (unsigned int)rdp->dynticks_snap;
77737
77738 /*
77739 @@ -802,10 +802,10 @@ static int jiffies_till_stall_check(void)
77740 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77741 */
77742 if (till_stall_check < 3) {
77743 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77744 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77745 till_stall_check = 3;
77746 } else if (till_stall_check > 300) {
77747 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77748 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77749 till_stall_check = 300;
77750 }
77751 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77752 @@ -1592,7 +1592,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
77753 rsp->qlen += rdp->qlen;
77754 rdp->n_cbs_orphaned += rdp->qlen;
77755 rdp->qlen_lazy = 0;
77756 - ACCESS_ONCE(rdp->qlen) = 0;
77757 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77758 }
77759
77760 /*
77761 @@ -1838,7 +1838,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
77762 }
77763 smp_mb(); /* List handling before counting for rcu_barrier(). */
77764 rdp->qlen_lazy -= count_lazy;
77765 - ACCESS_ONCE(rdp->qlen) -= count;
77766 + ACCESS_ONCE_RW(rdp->qlen) -= count;
77767 rdp->n_cbs_invoked += count;
77768
77769 /* Reinstate batch limit if we have worked down the excess. */
77770 @@ -2031,7 +2031,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
77771 /*
77772 * Do RCU core processing for the current CPU.
77773 */
77774 -static void rcu_process_callbacks(struct softirq_action *unused)
77775 +static void rcu_process_callbacks(void)
77776 {
77777 struct rcu_state *rsp;
77778
77779 @@ -2154,7 +2154,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
77780 local_irq_restore(flags);
77781 return;
77782 }
77783 - ACCESS_ONCE(rdp->qlen)++;
77784 + ACCESS_ONCE_RW(rdp->qlen)++;
77785 if (lazy)
77786 rdp->qlen_lazy++;
77787 else
77788 @@ -2363,11 +2363,11 @@ void synchronize_sched_expedited(void)
77789 * counter wrap on a 32-bit system. Quite a few more CPUs would of
77790 * course be required on a 64-bit system.
77791 */
77792 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
77793 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
77794 (ulong)atomic_long_read(&rsp->expedited_done) +
77795 ULONG_MAX / 8)) {
77796 synchronize_sched();
77797 - atomic_long_inc(&rsp->expedited_wrap);
77798 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
77799 return;
77800 }
77801
77802 @@ -2375,7 +2375,7 @@ void synchronize_sched_expedited(void)
77803 * Take a ticket. Note that atomic_inc_return() implies a
77804 * full memory barrier.
77805 */
77806 - snap = atomic_long_inc_return(&rsp->expedited_start);
77807 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
77808 firstsnap = snap;
77809 get_online_cpus();
77810 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
77811 @@ -2388,14 +2388,14 @@ void synchronize_sched_expedited(void)
77812 synchronize_sched_expedited_cpu_stop,
77813 NULL) == -EAGAIN) {
77814 put_online_cpus();
77815 - atomic_long_inc(&rsp->expedited_tryfail);
77816 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
77817
77818 /* Check to see if someone else did our work for us. */
77819 s = atomic_long_read(&rsp->expedited_done);
77820 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77821 /* ensure test happens before caller kfree */
77822 smp_mb__before_atomic_inc(); /* ^^^ */
77823 - atomic_long_inc(&rsp->expedited_workdone1);
77824 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
77825 return;
77826 }
77827
77828 @@ -2404,7 +2404,7 @@ void synchronize_sched_expedited(void)
77829 udelay(trycount * num_online_cpus());
77830 } else {
77831 wait_rcu_gp(call_rcu_sched);
77832 - atomic_long_inc(&rsp->expedited_normal);
77833 + atomic_long_inc_unchecked(&rsp->expedited_normal);
77834 return;
77835 }
77836
77837 @@ -2413,7 +2413,7 @@ void synchronize_sched_expedited(void)
77838 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
77839 /* ensure test happens before caller kfree */
77840 smp_mb__before_atomic_inc(); /* ^^^ */
77841 - atomic_long_inc(&rsp->expedited_workdone2);
77842 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
77843 return;
77844 }
77845
77846 @@ -2425,10 +2425,10 @@ void synchronize_sched_expedited(void)
77847 * period works for us.
77848 */
77849 get_online_cpus();
77850 - snap = atomic_long_read(&rsp->expedited_start);
77851 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
77852 smp_mb(); /* ensure read is before try_stop_cpus(). */
77853 }
77854 - atomic_long_inc(&rsp->expedited_stoppedcpus);
77855 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
77856
77857 /*
77858 * Everyone up to our most recent fetch is covered by our grace
77859 @@ -2437,16 +2437,16 @@ void synchronize_sched_expedited(void)
77860 * than we did already did their update.
77861 */
77862 do {
77863 - atomic_long_inc(&rsp->expedited_done_tries);
77864 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
77865 s = atomic_long_read(&rsp->expedited_done);
77866 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
77867 /* ensure test happens before caller kfree */
77868 smp_mb__before_atomic_inc(); /* ^^^ */
77869 - atomic_long_inc(&rsp->expedited_done_lost);
77870 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
77871 break;
77872 }
77873 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
77874 - atomic_long_inc(&rsp->expedited_done_exit);
77875 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
77876
77877 put_online_cpus();
77878 }
77879 @@ -2620,7 +2620,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77880 * ACCESS_ONCE() to prevent the compiler from speculating
77881 * the increment to precede the early-exit check.
77882 */
77883 - ACCESS_ONCE(rsp->n_barrier_done)++;
77884 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77885 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
77886 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
77887 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
77888 @@ -2670,7 +2670,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
77889
77890 /* Increment ->n_barrier_done to prevent duplicate work. */
77891 smp_mb(); /* Keep increment after above mechanism. */
77892 - ACCESS_ONCE(rsp->n_barrier_done)++;
77893 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
77894 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
77895 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
77896 smp_mb(); /* Keep increment before caller's subsequent code. */
77897 @@ -2715,10 +2715,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
77898 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
77899 init_callback_list(rdp);
77900 rdp->qlen_lazy = 0;
77901 - ACCESS_ONCE(rdp->qlen) = 0;
77902 + ACCESS_ONCE_RW(rdp->qlen) = 0;
77903 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
77904 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
77905 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
77906 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
77907 #ifdef CONFIG_RCU_USER_QS
77908 WARN_ON_ONCE(rdp->dynticks->in_user);
77909 #endif
77910 @@ -2754,8 +2754,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
77911 rdp->blimit = blimit;
77912 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
77913 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
77914 - atomic_set(&rdp->dynticks->dynticks,
77915 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
77916 + atomic_set_unchecked(&rdp->dynticks->dynticks,
77917 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
77918 rcu_prepare_for_idle_init(cpu);
77919 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
77920
77921 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
77922 index 4b69291..704c92e 100644
77923 --- a/kernel/rcutree.h
77924 +++ b/kernel/rcutree.h
77925 @@ -86,7 +86,7 @@ struct rcu_dynticks {
77926 long long dynticks_nesting; /* Track irq/process nesting level. */
77927 /* Process level is worth LLONG_MAX/2. */
77928 int dynticks_nmi_nesting; /* Track NMI nesting level. */
77929 - atomic_t dynticks; /* Even value for idle, else odd. */
77930 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
77931 #ifdef CONFIG_RCU_FAST_NO_HZ
77932 int dyntick_drain; /* Prepare-for-idle state variable. */
77933 unsigned long dyntick_holdoff;
77934 @@ -423,17 +423,17 @@ struct rcu_state {
77935 /* _rcu_barrier(). */
77936 /* End of fields guarded by barrier_mutex. */
77937
77938 - atomic_long_t expedited_start; /* Starting ticket. */
77939 - atomic_long_t expedited_done; /* Done ticket. */
77940 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
77941 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
77942 - atomic_long_t expedited_workdone1; /* # done by others #1. */
77943 - atomic_long_t expedited_workdone2; /* # done by others #2. */
77944 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
77945 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
77946 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
77947 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
77948 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
77949 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
77950 + atomic_long_t expedited_done; /* Done ticket. */
77951 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
77952 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
77953 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
77954 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
77955 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
77956 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
77957 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
77958 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
77959 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
77960
77961 unsigned long jiffies_force_qs; /* Time at which to invoke */
77962 /* force_quiescent_state(). */
77963 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
77964 index c1cc7e1..f62e436 100644
77965 --- a/kernel/rcutree_plugin.h
77966 +++ b/kernel/rcutree_plugin.h
77967 @@ -892,7 +892,7 @@ void synchronize_rcu_expedited(void)
77968
77969 /* Clean up and exit. */
77970 smp_mb(); /* ensure expedited GP seen before counter increment. */
77971 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
77972 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
77973 unlock_mb_ret:
77974 mutex_unlock(&sync_rcu_preempt_exp_mutex);
77975 mb_ret:
77976 @@ -1440,7 +1440,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
77977 free_cpumask_var(cm);
77978 }
77979
77980 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
77981 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
77982 .store = &rcu_cpu_kthread_task,
77983 .thread_should_run = rcu_cpu_kthread_should_run,
77984 .thread_fn = rcu_cpu_kthread,
77985 @@ -2072,7 +2072,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
77986 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
77987 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d %s\n",
77988 cpu, ticks_value, ticks_title,
77989 - atomic_read(&rdtp->dynticks) & 0xfff,
77990 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
77991 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
77992 fast_no_hz);
77993 }
77994 @@ -2192,7 +2192,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
77995
77996 /* Enqueue the callback on the nocb list and update counts. */
77997 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
77998 - ACCESS_ONCE(*old_rhpp) = rhp;
77999 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78000 atomic_long_add(rhcount, &rdp->nocb_q_count);
78001 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78002
78003 @@ -2384,12 +2384,12 @@ static int rcu_nocb_kthread(void *arg)
78004 * Extract queued callbacks, update counts, and wait
78005 * for a grace period to elapse.
78006 */
78007 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78008 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78009 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78010 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78011 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78012 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78013 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78014 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78015 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78016 wait_rcu_gp(rdp->rsp->call_remote);
78017
78018 /* Each pass through the following loop invokes a callback. */
78019 @@ -2411,8 +2411,8 @@ static int rcu_nocb_kthread(void *arg)
78020 list = next;
78021 }
78022 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78023 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78024 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78025 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78026 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78027 rdp->n_nocbs_invoked += c;
78028 }
78029 return 0;
78030 @@ -2438,7 +2438,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78031 rdp = per_cpu_ptr(rsp->rda, cpu);
78032 t = kthread_run(rcu_nocb_kthread, rdp, "rcuo%d", cpu);
78033 BUG_ON(IS_ERR(t));
78034 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78035 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78036 }
78037 }
78038
78039 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78040 index 0d095dc..1985b19 100644
78041 --- a/kernel/rcutree_trace.c
78042 +++ b/kernel/rcutree_trace.c
78043 @@ -123,7 +123,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78044 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78045 rdp->passed_quiesce, rdp->qs_pending);
78046 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78047 - atomic_read(&rdp->dynticks->dynticks),
78048 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78049 rdp->dynticks->dynticks_nesting,
78050 rdp->dynticks->dynticks_nmi_nesting,
78051 rdp->dynticks_fqs);
78052 @@ -184,17 +184,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78053 struct rcu_state *rsp = (struct rcu_state *)m->private;
78054
78055 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",
78056 - atomic_long_read(&rsp->expedited_start),
78057 + atomic_long_read_unchecked(&rsp->expedited_start),
78058 atomic_long_read(&rsp->expedited_done),
78059 - atomic_long_read(&rsp->expedited_wrap),
78060 - atomic_long_read(&rsp->expedited_tryfail),
78061 - atomic_long_read(&rsp->expedited_workdone1),
78062 - atomic_long_read(&rsp->expedited_workdone2),
78063 - atomic_long_read(&rsp->expedited_normal),
78064 - atomic_long_read(&rsp->expedited_stoppedcpus),
78065 - atomic_long_read(&rsp->expedited_done_tries),
78066 - atomic_long_read(&rsp->expedited_done_lost),
78067 - atomic_long_read(&rsp->expedited_done_exit));
78068 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78069 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78070 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78071 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78072 + atomic_long_read_unchecked(&rsp->expedited_normal),
78073 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78074 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78075 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78076 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78077 return 0;
78078 }
78079
78080 diff --git a/kernel/resource.c b/kernel/resource.c
78081 index 73f35d4..4684fc4 100644
78082 --- a/kernel/resource.c
78083 +++ b/kernel/resource.c
78084 @@ -143,8 +143,18 @@ static const struct file_operations proc_iomem_operations = {
78085
78086 static int __init ioresources_init(void)
78087 {
78088 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78089 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78090 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78091 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78092 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78093 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78094 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78095 +#endif
78096 +#else
78097 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78098 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78099 +#endif
78100 return 0;
78101 }
78102 __initcall(ioresources_init);
78103 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78104 index 98ec494..4241d6d 100644
78105 --- a/kernel/rtmutex-tester.c
78106 +++ b/kernel/rtmutex-tester.c
78107 @@ -20,7 +20,7 @@
78108 #define MAX_RT_TEST_MUTEXES 8
78109
78110 static spinlock_t rttest_lock;
78111 -static atomic_t rttest_event;
78112 +static atomic_unchecked_t rttest_event;
78113
78114 struct test_thread_data {
78115 int opcode;
78116 @@ -61,7 +61,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78117
78118 case RTTEST_LOCKCONT:
78119 td->mutexes[td->opdata] = 1;
78120 - td->event = atomic_add_return(1, &rttest_event);
78121 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78122 return 0;
78123
78124 case RTTEST_RESET:
78125 @@ -74,7 +74,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78126 return 0;
78127
78128 case RTTEST_RESETEVENT:
78129 - atomic_set(&rttest_event, 0);
78130 + atomic_set_unchecked(&rttest_event, 0);
78131 return 0;
78132
78133 default:
78134 @@ -91,9 +91,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78135 return ret;
78136
78137 td->mutexes[id] = 1;
78138 - td->event = atomic_add_return(1, &rttest_event);
78139 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78140 rt_mutex_lock(&mutexes[id]);
78141 - td->event = atomic_add_return(1, &rttest_event);
78142 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78143 td->mutexes[id] = 4;
78144 return 0;
78145
78146 @@ -104,9 +104,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78147 return ret;
78148
78149 td->mutexes[id] = 1;
78150 - td->event = atomic_add_return(1, &rttest_event);
78151 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78152 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78153 - td->event = atomic_add_return(1, &rttest_event);
78154 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78155 td->mutexes[id] = ret ? 0 : 4;
78156 return ret ? -EINTR : 0;
78157
78158 @@ -115,9 +115,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78159 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78160 return ret;
78161
78162 - td->event = atomic_add_return(1, &rttest_event);
78163 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78164 rt_mutex_unlock(&mutexes[id]);
78165 - td->event = atomic_add_return(1, &rttest_event);
78166 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78167 td->mutexes[id] = 0;
78168 return 0;
78169
78170 @@ -164,7 +164,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78171 break;
78172
78173 td->mutexes[dat] = 2;
78174 - td->event = atomic_add_return(1, &rttest_event);
78175 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78176 break;
78177
78178 default:
78179 @@ -184,7 +184,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78180 return;
78181
78182 td->mutexes[dat] = 3;
78183 - td->event = atomic_add_return(1, &rttest_event);
78184 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78185 break;
78186
78187 case RTTEST_LOCKNOWAIT:
78188 @@ -196,7 +196,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78189 return;
78190
78191 td->mutexes[dat] = 1;
78192 - td->event = atomic_add_return(1, &rttest_event);
78193 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78194 return;
78195
78196 default:
78197 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78198 index 0984a21..939f183 100644
78199 --- a/kernel/sched/auto_group.c
78200 +++ b/kernel/sched/auto_group.c
78201 @@ -11,7 +11,7 @@
78202
78203 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78204 static struct autogroup autogroup_default;
78205 -static atomic_t autogroup_seq_nr;
78206 +static atomic_unchecked_t autogroup_seq_nr;
78207
78208 void __init autogroup_init(struct task_struct *init_task)
78209 {
78210 @@ -78,7 +78,7 @@ static inline struct autogroup *autogroup_create(void)
78211
78212 kref_init(&ag->kref);
78213 init_rwsem(&ag->lock);
78214 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78215 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78216 ag->tg = tg;
78217 #ifdef CONFIG_RT_GROUP_SCHED
78218 /*
78219 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78220 index 26058d0..e315889 100644
78221 --- a/kernel/sched/core.c
78222 +++ b/kernel/sched/core.c
78223 @@ -3367,7 +3367,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78224 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78225 * positive (at least 1, or number of jiffies left till timeout) if completed.
78226 */
78227 -long __sched
78228 +long __sched __intentional_overflow(-1)
78229 wait_for_completion_interruptible_timeout(struct completion *x,
78230 unsigned long timeout)
78231 {
78232 @@ -3384,7 +3384,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78233 *
78234 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78235 */
78236 -int __sched wait_for_completion_killable(struct completion *x)
78237 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78238 {
78239 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78240 if (t == -ERESTARTSYS)
78241 @@ -3405,7 +3405,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78242 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78243 * positive (at least 1, or number of jiffies left till timeout) if completed.
78244 */
78245 -long __sched
78246 +long __sched __intentional_overflow(-1)
78247 wait_for_completion_killable_timeout(struct completion *x,
78248 unsigned long timeout)
78249 {
78250 @@ -3631,6 +3631,8 @@ int can_nice(const struct task_struct *p, const int nice)
78251 /* convert nice value [19,-20] to rlimit style value [1,40] */
78252 int nice_rlim = 20 - nice;
78253
78254 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78255 +
78256 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78257 capable(CAP_SYS_NICE));
78258 }
78259 @@ -3664,7 +3666,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78260 if (nice > 19)
78261 nice = 19;
78262
78263 - if (increment < 0 && !can_nice(current, nice))
78264 + if (increment < 0 && (!can_nice(current, nice) ||
78265 + gr_handle_chroot_nice()))
78266 return -EPERM;
78267
78268 retval = security_task_setnice(current, nice);
78269 @@ -3818,6 +3821,7 @@ recheck:
78270 unsigned long rlim_rtprio =
78271 task_rlimit(p, RLIMIT_RTPRIO);
78272
78273 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78274 /* can't set/change the rt policy */
78275 if (policy != p->policy && !rlim_rtprio)
78276 return -EPERM;
78277 @@ -4901,7 +4905,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78278
78279 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78280
78281 -static struct ctl_table sd_ctl_dir[] = {
78282 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78283 {
78284 .procname = "sched_domain",
78285 .mode = 0555,
78286 @@ -4918,17 +4922,17 @@ static struct ctl_table sd_ctl_root[] = {
78287 {}
78288 };
78289
78290 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78291 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78292 {
78293 - struct ctl_table *entry =
78294 + ctl_table_no_const *entry =
78295 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78296
78297 return entry;
78298 }
78299
78300 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78301 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78302 {
78303 - struct ctl_table *entry;
78304 + ctl_table_no_const *entry;
78305
78306 /*
78307 * In the intermediate directories, both the child directory and
78308 @@ -4936,22 +4940,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78309 * will always be set. In the lowest directory the names are
78310 * static strings and all have proc handlers.
78311 */
78312 - for (entry = *tablep; entry->mode; entry++) {
78313 - if (entry->child)
78314 - sd_free_ctl_entry(&entry->child);
78315 + for (entry = tablep; entry->mode; entry++) {
78316 + if (entry->child) {
78317 + sd_free_ctl_entry(entry->child);
78318 + pax_open_kernel();
78319 + entry->child = NULL;
78320 + pax_close_kernel();
78321 + }
78322 if (entry->proc_handler == NULL)
78323 kfree(entry->procname);
78324 }
78325
78326 - kfree(*tablep);
78327 - *tablep = NULL;
78328 + kfree(tablep);
78329 }
78330
78331 static int min_load_idx = 0;
78332 static int max_load_idx = CPU_LOAD_IDX_MAX;
78333
78334 static void
78335 -set_table_entry(struct ctl_table *entry,
78336 +set_table_entry(ctl_table_no_const *entry,
78337 const char *procname, void *data, int maxlen,
78338 umode_t mode, proc_handler *proc_handler,
78339 bool load_idx)
78340 @@ -4971,7 +4978,7 @@ set_table_entry(struct ctl_table *entry,
78341 static struct ctl_table *
78342 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78343 {
78344 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78345 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78346
78347 if (table == NULL)
78348 return NULL;
78349 @@ -5006,9 +5013,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78350 return table;
78351 }
78352
78353 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78354 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78355 {
78356 - struct ctl_table *entry, *table;
78357 + ctl_table_no_const *entry, *table;
78358 struct sched_domain *sd;
78359 int domain_num = 0, i;
78360 char buf[32];
78361 @@ -5035,11 +5042,13 @@ static struct ctl_table_header *sd_sysctl_header;
78362 static void register_sched_domain_sysctl(void)
78363 {
78364 int i, cpu_num = num_possible_cpus();
78365 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78366 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78367 char buf[32];
78368
78369 WARN_ON(sd_ctl_dir[0].child);
78370 + pax_open_kernel();
78371 sd_ctl_dir[0].child = entry;
78372 + pax_close_kernel();
78373
78374 if (entry == NULL)
78375 return;
78376 @@ -5062,8 +5071,12 @@ static void unregister_sched_domain_sysctl(void)
78377 if (sd_sysctl_header)
78378 unregister_sysctl_table(sd_sysctl_header);
78379 sd_sysctl_header = NULL;
78380 - if (sd_ctl_dir[0].child)
78381 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78382 + if (sd_ctl_dir[0].child) {
78383 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78384 + pax_open_kernel();
78385 + sd_ctl_dir[0].child = NULL;
78386 + pax_close_kernel();
78387 + }
78388 }
78389 #else
78390 static void register_sched_domain_sysctl(void)
78391 @@ -5162,7 +5175,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78392 * happens before everything else. This has to be lower priority than
78393 * the notifier in the perf_event subsystem, though.
78394 */
78395 -static struct notifier_block __cpuinitdata migration_notifier = {
78396 +static struct notifier_block migration_notifier = {
78397 .notifier_call = migration_call,
78398 .priority = CPU_PRI_MIGRATION,
78399 };
78400 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78401 index 81fa536..6ccf96a 100644
78402 --- a/kernel/sched/fair.c
78403 +++ b/kernel/sched/fair.c
78404 @@ -830,7 +830,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78405
78406 static void reset_ptenuma_scan(struct task_struct *p)
78407 {
78408 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78409 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78410 p->mm->numa_scan_offset = 0;
78411 }
78412
78413 @@ -3254,25 +3254,18 @@ find_idlest_cpu(struct sched_group *group, struct task_struct *p, int this_cpu)
78414 */
78415 static int select_idle_sibling(struct task_struct *p, int target)
78416 {
78417 - int cpu = smp_processor_id();
78418 - int prev_cpu = task_cpu(p);
78419 struct sched_domain *sd;
78420 struct sched_group *sg;
78421 - int i;
78422 + int i = task_cpu(p);
78423
78424 - /*
78425 - * If the task is going to be woken-up on this cpu and if it is
78426 - * already idle, then it is the right target.
78427 - */
78428 - if (target == cpu && idle_cpu(cpu))
78429 - return cpu;
78430 + if (idle_cpu(target))
78431 + return target;
78432
78433 /*
78434 - * If the task is going to be woken-up on the cpu where it previously
78435 - * ran and if it is currently idle, then it the right target.
78436 + * If the prevous cpu is cache affine and idle, don't be stupid.
78437 */
78438 - if (target == prev_cpu && idle_cpu(prev_cpu))
78439 - return prev_cpu;
78440 + if (i != target && cpus_share_cache(i, target) && idle_cpu(i))
78441 + return i;
78442
78443 /*
78444 * Otherwise, iterate the domains and find an elegible idle cpu.
78445 @@ -3286,7 +3279,7 @@ static int select_idle_sibling(struct task_struct *p, int target)
78446 goto next;
78447
78448 for_each_cpu(i, sched_group_cpus(sg)) {
78449 - if (!idle_cpu(i))
78450 + if (i == target || !idle_cpu(i))
78451 goto next;
78452 }
78453
78454 @@ -5663,7 +5656,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78455 * run_rebalance_domains is triggered when needed from the scheduler tick.
78456 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78457 */
78458 -static void run_rebalance_domains(struct softirq_action *h)
78459 +static void run_rebalance_domains(void)
78460 {
78461 int this_cpu = smp_processor_id();
78462 struct rq *this_rq = cpu_rq(this_cpu);
78463 diff --git a/kernel/signal.c b/kernel/signal.c
78464 index dec9c30..d1da15b 100644
78465 --- a/kernel/signal.c
78466 +++ b/kernel/signal.c
78467 @@ -50,12 +50,12 @@ static struct kmem_cache *sigqueue_cachep;
78468
78469 int print_fatal_signals __read_mostly;
78470
78471 -static void __user *sig_handler(struct task_struct *t, int sig)
78472 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78473 {
78474 return t->sighand->action[sig - 1].sa.sa_handler;
78475 }
78476
78477 -static int sig_handler_ignored(void __user *handler, int sig)
78478 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78479 {
78480 /* Is it explicitly or implicitly ignored? */
78481 return handler == SIG_IGN ||
78482 @@ -64,7 +64,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78483
78484 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78485 {
78486 - void __user *handler;
78487 + __sighandler_t handler;
78488
78489 handler = sig_handler(t, sig);
78490
78491 @@ -368,6 +368,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78492 atomic_inc(&user->sigpending);
78493 rcu_read_unlock();
78494
78495 + if (!override_rlimit)
78496 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78497 +
78498 if (override_rlimit ||
78499 atomic_read(&user->sigpending) <=
78500 task_rlimit(t, RLIMIT_SIGPENDING)) {
78501 @@ -495,7 +498,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78502
78503 int unhandled_signal(struct task_struct *tsk, int sig)
78504 {
78505 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78506 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78507 if (is_global_init(tsk))
78508 return 1;
78509 if (handler != SIG_IGN && handler != SIG_DFL)
78510 @@ -815,6 +818,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78511 }
78512 }
78513
78514 + /* allow glibc communication via tgkill to other threads in our
78515 + thread group */
78516 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78517 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78518 + && gr_handle_signal(t, sig))
78519 + return -EPERM;
78520 +
78521 return security_task_kill(t, info, sig, 0);
78522 }
78523
78524 @@ -1197,7 +1207,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78525 return send_signal(sig, info, p, 1);
78526 }
78527
78528 -static int
78529 +int
78530 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78531 {
78532 return send_signal(sig, info, t, 0);
78533 @@ -1234,6 +1244,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78534 unsigned long int flags;
78535 int ret, blocked, ignored;
78536 struct k_sigaction *action;
78537 + int is_unhandled = 0;
78538
78539 spin_lock_irqsave(&t->sighand->siglock, flags);
78540 action = &t->sighand->action[sig-1];
78541 @@ -1248,9 +1259,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78542 }
78543 if (action->sa.sa_handler == SIG_DFL)
78544 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78545 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78546 + is_unhandled = 1;
78547 ret = specific_send_sig_info(sig, info, t);
78548 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78549
78550 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78551 + normal operation */
78552 + if (is_unhandled) {
78553 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78554 + gr_handle_crash(t, sig);
78555 + }
78556 +
78557 return ret;
78558 }
78559
78560 @@ -1317,8 +1337,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78561 ret = check_kill_permission(sig, info, p);
78562 rcu_read_unlock();
78563
78564 - if (!ret && sig)
78565 + if (!ret && sig) {
78566 ret = do_send_sig_info(sig, info, p, true);
78567 + if (!ret)
78568 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78569 + }
78570
78571 return ret;
78572 }
78573 @@ -2855,7 +2878,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78574 int error = -ESRCH;
78575
78576 rcu_read_lock();
78577 - p = find_task_by_vpid(pid);
78578 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78579 + /* allow glibc communication via tgkill to other threads in our
78580 + thread group */
78581 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78582 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78583 + p = find_task_by_vpid_unrestricted(pid);
78584 + else
78585 +#endif
78586 + p = find_task_by_vpid(pid);
78587 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78588 error = check_kill_permission(sig, info, p);
78589 /*
78590 @@ -3138,8 +3169,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78591 }
78592 seg = get_fs();
78593 set_fs(KERNEL_DS);
78594 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78595 - (stack_t __force __user *) &uoss,
78596 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78597 + (stack_t __force_user *) &uoss,
78598 compat_user_stack_pointer());
78599 set_fs(seg);
78600 if (ret >= 0 && uoss_ptr) {
78601 diff --git a/kernel/smp.c b/kernel/smp.c
78602 index 69f38bd..77bbf12 100644
78603 --- a/kernel/smp.c
78604 +++ b/kernel/smp.c
78605 @@ -77,7 +77,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78606 return NOTIFY_OK;
78607 }
78608
78609 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78610 +static struct notifier_block hotplug_cfd_notifier = {
78611 .notifier_call = hotplug_cfd,
78612 };
78613
78614 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78615 index d6c5fc0..530560c 100644
78616 --- a/kernel/smpboot.c
78617 +++ b/kernel/smpboot.c
78618 @@ -275,7 +275,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78619 }
78620 smpboot_unpark_thread(plug_thread, cpu);
78621 }
78622 - list_add(&plug_thread->list, &hotplug_threads);
78623 + pax_list_add(&plug_thread->list, &hotplug_threads);
78624 out:
78625 mutex_unlock(&smpboot_threads_lock);
78626 return ret;
78627 @@ -292,7 +292,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
78628 {
78629 get_online_cpus();
78630 mutex_lock(&smpboot_threads_lock);
78631 - list_del(&plug_thread->list);
78632 + pax_list_del(&plug_thread->list);
78633 smpboot_destroy_threads(plug_thread);
78634 mutex_unlock(&smpboot_threads_lock);
78635 put_online_cpus();
78636 diff --git a/kernel/softirq.c b/kernel/softirq.c
78637 index ed567ba..e71dabf 100644
78638 --- a/kernel/softirq.c
78639 +++ b/kernel/softirq.c
78640 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
78641 EXPORT_SYMBOL(irq_stat);
78642 #endif
78643
78644 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
78645 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
78646
78647 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
78648
78649 -char *softirq_to_name[NR_SOFTIRQS] = {
78650 +const char * const softirq_to_name[NR_SOFTIRQS] = {
78651 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
78652 "TASKLET", "SCHED", "HRTIMER", "RCU"
78653 };
78654 @@ -244,7 +244,7 @@ restart:
78655 kstat_incr_softirqs_this_cpu(vec_nr);
78656
78657 trace_softirq_entry(vec_nr);
78658 - h->action(h);
78659 + h->action();
78660 trace_softirq_exit(vec_nr);
78661 if (unlikely(prev_count != preempt_count())) {
78662 printk(KERN_ERR "huh, entered softirq %u %s %p"
78663 @@ -391,7 +391,7 @@ void __raise_softirq_irqoff(unsigned int nr)
78664 or_softirq_pending(1UL << nr);
78665 }
78666
78667 -void open_softirq(int nr, void (*action)(struct softirq_action *))
78668 +void __init open_softirq(int nr, void (*action)(void))
78669 {
78670 softirq_vec[nr].action = action;
78671 }
78672 @@ -447,7 +447,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
78673
78674 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
78675
78676 -static void tasklet_action(struct softirq_action *a)
78677 +static void tasklet_action(void)
78678 {
78679 struct tasklet_struct *list;
78680
78681 @@ -482,7 +482,7 @@ static void tasklet_action(struct softirq_action *a)
78682 }
78683 }
78684
78685 -static void tasklet_hi_action(struct softirq_action *a)
78686 +static void tasklet_hi_action(void)
78687 {
78688 struct tasklet_struct *list;
78689
78690 @@ -718,7 +718,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
78691 return NOTIFY_OK;
78692 }
78693
78694 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
78695 +static struct notifier_block remote_softirq_cpu_notifier = {
78696 .notifier_call = remote_softirq_cpu_notify,
78697 };
78698
78699 @@ -835,11 +835,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
78700 return NOTIFY_OK;
78701 }
78702
78703 -static struct notifier_block __cpuinitdata cpu_nfb = {
78704 +static struct notifier_block cpu_nfb = {
78705 .notifier_call = cpu_callback
78706 };
78707
78708 -static struct smp_hotplug_thread softirq_threads = {
78709 +static struct smp_hotplug_thread softirq_threads __read_only = {
78710 .store = &ksoftirqd,
78711 .thread_should_run = ksoftirqd_should_run,
78712 .thread_fn = run_ksoftirqd,
78713 diff --git a/kernel/srcu.c b/kernel/srcu.c
78714 index 2b85982..d52ab26 100644
78715 --- a/kernel/srcu.c
78716 +++ b/kernel/srcu.c
78717 @@ -305,9 +305,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
78718 preempt_disable();
78719 idx = rcu_dereference_index_check(sp->completed,
78720 rcu_read_lock_sched_held()) & 0x1;
78721 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78722 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
78723 smp_mb(); /* B */ /* Avoid leaking the critical section. */
78724 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78725 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
78726 preempt_enable();
78727 return idx;
78728 }
78729 @@ -323,7 +323,7 @@ void __srcu_read_unlock(struct srcu_struct *sp, int idx)
78730 {
78731 preempt_disable();
78732 smp_mb(); /* C */ /* Avoid leaking the critical section. */
78733 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78734 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) -= 1;
78735 preempt_enable();
78736 }
78737 EXPORT_SYMBOL_GPL(__srcu_read_unlock);
78738 diff --git a/kernel/stop_machine.c b/kernel/stop_machine.c
78739 index 2f194e9..2c05ea9 100644
78740 --- a/kernel/stop_machine.c
78741 +++ b/kernel/stop_machine.c
78742 @@ -362,7 +362,7 @@ static int __cpuinit cpu_stop_cpu_callback(struct notifier_block *nfb,
78743 * cpu notifiers. It currently shares the same priority as sched
78744 * migration_notifier.
78745 */
78746 -static struct notifier_block __cpuinitdata cpu_stop_cpu_notifier = {
78747 +static struct notifier_block cpu_stop_cpu_notifier = {
78748 .notifier_call = cpu_stop_cpu_callback,
78749 .priority = 10,
78750 };
78751 diff --git a/kernel/sys.c b/kernel/sys.c
78752 index 265b376..48b8613 100644
78753 --- a/kernel/sys.c
78754 +++ b/kernel/sys.c
78755 @@ -157,6 +157,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
78756 error = -EACCES;
78757 goto out;
78758 }
78759 +
78760 + if (gr_handle_chroot_setpriority(p, niceval)) {
78761 + error = -EACCES;
78762 + goto out;
78763 + }
78764 +
78765 no_nice = security_task_setnice(p, niceval);
78766 if (no_nice) {
78767 error = no_nice;
78768 @@ -595,6 +601,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
78769 goto error;
78770 }
78771
78772 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
78773 + goto error;
78774 +
78775 if (rgid != (gid_t) -1 ||
78776 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
78777 new->sgid = new->egid;
78778 @@ -630,6 +639,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
78779 old = current_cred();
78780
78781 retval = -EPERM;
78782 +
78783 + if (gr_check_group_change(kgid, kgid, kgid))
78784 + goto error;
78785 +
78786 if (nsown_capable(CAP_SETGID))
78787 new->gid = new->egid = new->sgid = new->fsgid = kgid;
78788 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
78789 @@ -647,7 +660,7 @@ error:
78790 /*
78791 * change the user struct in a credentials set to match the new UID
78792 */
78793 -static int set_user(struct cred *new)
78794 +int set_user(struct cred *new)
78795 {
78796 struct user_struct *new_user;
78797
78798 @@ -727,6 +740,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
78799 goto error;
78800 }
78801
78802 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
78803 + goto error;
78804 +
78805 if (!uid_eq(new->uid, old->uid)) {
78806 retval = set_user(new);
78807 if (retval < 0)
78808 @@ -777,6 +793,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
78809 old = current_cred();
78810
78811 retval = -EPERM;
78812 +
78813 + if (gr_check_crash_uid(kuid))
78814 + goto error;
78815 + if (gr_check_user_change(kuid, kuid, kuid))
78816 + goto error;
78817 +
78818 if (nsown_capable(CAP_SETUID)) {
78819 new->suid = new->uid = kuid;
78820 if (!uid_eq(kuid, old->uid)) {
78821 @@ -846,6 +868,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
78822 goto error;
78823 }
78824
78825 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
78826 + goto error;
78827 +
78828 if (ruid != (uid_t) -1) {
78829 new->uid = kruid;
78830 if (!uid_eq(kruid, old->uid)) {
78831 @@ -928,6 +953,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
78832 goto error;
78833 }
78834
78835 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
78836 + goto error;
78837 +
78838 if (rgid != (gid_t) -1)
78839 new->gid = krgid;
78840 if (egid != (gid_t) -1)
78841 @@ -989,12 +1017,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
78842 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
78843 nsown_capable(CAP_SETUID)) {
78844 if (!uid_eq(kuid, old->fsuid)) {
78845 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
78846 + goto error;
78847 +
78848 new->fsuid = kuid;
78849 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
78850 goto change_okay;
78851 }
78852 }
78853
78854 +error:
78855 abort_creds(new);
78856 return old_fsuid;
78857
78858 @@ -1027,12 +1059,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
78859 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
78860 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
78861 nsown_capable(CAP_SETGID)) {
78862 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
78863 + goto error;
78864 +
78865 if (!gid_eq(kgid, old->fsgid)) {
78866 new->fsgid = kgid;
78867 goto change_okay;
78868 }
78869 }
78870
78871 +error:
78872 abort_creds(new);
78873 return old_fsgid;
78874
78875 @@ -1340,19 +1376,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
78876 return -EFAULT;
78877
78878 down_read(&uts_sem);
78879 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
78880 + error = __copy_to_user(name->sysname, &utsname()->sysname,
78881 __OLD_UTS_LEN);
78882 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
78883 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
78884 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
78885 __OLD_UTS_LEN);
78886 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
78887 - error |= __copy_to_user(&name->release, &utsname()->release,
78888 + error |= __copy_to_user(name->release, &utsname()->release,
78889 __OLD_UTS_LEN);
78890 error |= __put_user(0, name->release + __OLD_UTS_LEN);
78891 - error |= __copy_to_user(&name->version, &utsname()->version,
78892 + error |= __copy_to_user(name->version, &utsname()->version,
78893 __OLD_UTS_LEN);
78894 error |= __put_user(0, name->version + __OLD_UTS_LEN);
78895 - error |= __copy_to_user(&name->machine, &utsname()->machine,
78896 + error |= __copy_to_user(name->machine, &utsname()->machine,
78897 __OLD_UTS_LEN);
78898 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
78899 up_read(&uts_sem);
78900 @@ -2026,7 +2062,7 @@ SYSCALL_DEFINE5(prctl, int, option, unsigned long, arg2, unsigned long, arg3,
78901 error = get_dumpable(me->mm);
78902 break;
78903 case PR_SET_DUMPABLE:
78904 - if (arg2 < 0 || arg2 > 1) {
78905 + if (arg2 > 1) {
78906 error = -EINVAL;
78907 break;
78908 }
78909 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
78910 index c88878d..e4fa5d1 100644
78911 --- a/kernel/sysctl.c
78912 +++ b/kernel/sysctl.c
78913 @@ -92,7 +92,6 @@
78914
78915
78916 #if defined(CONFIG_SYSCTL)
78917 -
78918 /* External variables not in a header file. */
78919 extern int sysctl_overcommit_memory;
78920 extern int sysctl_overcommit_ratio;
78921 @@ -172,10 +171,8 @@ static int proc_taint(struct ctl_table *table, int write,
78922 void __user *buffer, size_t *lenp, loff_t *ppos);
78923 #endif
78924
78925 -#ifdef CONFIG_PRINTK
78926 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
78927 void __user *buffer, size_t *lenp, loff_t *ppos);
78928 -#endif
78929
78930 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
78931 void __user *buffer, size_t *lenp, loff_t *ppos);
78932 @@ -206,6 +203,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
78933
78934 #endif
78935
78936 +extern struct ctl_table grsecurity_table[];
78937 +
78938 static struct ctl_table kern_table[];
78939 static struct ctl_table vm_table[];
78940 static struct ctl_table fs_table[];
78941 @@ -220,6 +219,20 @@ extern struct ctl_table epoll_table[];
78942 int sysctl_legacy_va_layout;
78943 #endif
78944
78945 +#ifdef CONFIG_PAX_SOFTMODE
78946 +static ctl_table pax_table[] = {
78947 + {
78948 + .procname = "softmode",
78949 + .data = &pax_softmode,
78950 + .maxlen = sizeof(unsigned int),
78951 + .mode = 0600,
78952 + .proc_handler = &proc_dointvec,
78953 + },
78954 +
78955 + { }
78956 +};
78957 +#endif
78958 +
78959 /* The default sysctl tables: */
78960
78961 static struct ctl_table sysctl_base_table[] = {
78962 @@ -268,6 +281,22 @@ static int max_extfrag_threshold = 1000;
78963 #endif
78964
78965 static struct ctl_table kern_table[] = {
78966 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
78967 + {
78968 + .procname = "grsecurity",
78969 + .mode = 0500,
78970 + .child = grsecurity_table,
78971 + },
78972 +#endif
78973 +
78974 +#ifdef CONFIG_PAX_SOFTMODE
78975 + {
78976 + .procname = "pax",
78977 + .mode = 0500,
78978 + .child = pax_table,
78979 + },
78980 +#endif
78981 +
78982 {
78983 .procname = "sched_child_runs_first",
78984 .data = &sysctl_sched_child_runs_first,
78985 @@ -593,7 +622,7 @@ static struct ctl_table kern_table[] = {
78986 .data = &modprobe_path,
78987 .maxlen = KMOD_PATH_LEN,
78988 .mode = 0644,
78989 - .proc_handler = proc_dostring,
78990 + .proc_handler = proc_dostring_modpriv,
78991 },
78992 {
78993 .procname = "modules_disabled",
78994 @@ -760,16 +789,20 @@ static struct ctl_table kern_table[] = {
78995 .extra1 = &zero,
78996 .extra2 = &one,
78997 },
78998 +#endif
78999 {
79000 .procname = "kptr_restrict",
79001 .data = &kptr_restrict,
79002 .maxlen = sizeof(int),
79003 .mode = 0644,
79004 .proc_handler = proc_dointvec_minmax_sysadmin,
79005 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79006 + .extra1 = &two,
79007 +#else
79008 .extra1 = &zero,
79009 +#endif
79010 .extra2 = &two,
79011 },
79012 -#endif
79013 {
79014 .procname = "ngroups_max",
79015 .data = &ngroups_max,
79016 @@ -1266,6 +1299,13 @@ static struct ctl_table vm_table[] = {
79017 .proc_handler = proc_dointvec_minmax,
79018 .extra1 = &zero,
79019 },
79020 + {
79021 + .procname = "heap_stack_gap",
79022 + .data = &sysctl_heap_stack_gap,
79023 + .maxlen = sizeof(sysctl_heap_stack_gap),
79024 + .mode = 0644,
79025 + .proc_handler = proc_doulongvec_minmax,
79026 + },
79027 #else
79028 {
79029 .procname = "nr_trim_pages",
79030 @@ -1716,6 +1756,16 @@ int proc_dostring(struct ctl_table *table, int write,
79031 buffer, lenp, ppos);
79032 }
79033
79034 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79035 + void __user *buffer, size_t *lenp, loff_t *ppos)
79036 +{
79037 + if (write && !capable(CAP_SYS_MODULE))
79038 + return -EPERM;
79039 +
79040 + return _proc_do_string(table->data, table->maxlen, write,
79041 + buffer, lenp, ppos);
79042 +}
79043 +
79044 static size_t proc_skip_spaces(char **buf)
79045 {
79046 size_t ret;
79047 @@ -1821,6 +1871,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79048 len = strlen(tmp);
79049 if (len > *size)
79050 len = *size;
79051 + if (len > sizeof(tmp))
79052 + len = sizeof(tmp);
79053 if (copy_to_user(*buf, tmp, len))
79054 return -EFAULT;
79055 *size -= len;
79056 @@ -1985,7 +2037,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79057 static int proc_taint(struct ctl_table *table, int write,
79058 void __user *buffer, size_t *lenp, loff_t *ppos)
79059 {
79060 - struct ctl_table t;
79061 + ctl_table_no_const t;
79062 unsigned long tmptaint = get_taint();
79063 int err;
79064
79065 @@ -2013,7 +2065,6 @@ static int proc_taint(struct ctl_table *table, int write,
79066 return err;
79067 }
79068
79069 -#ifdef CONFIG_PRINTK
79070 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79071 void __user *buffer, size_t *lenp, loff_t *ppos)
79072 {
79073 @@ -2022,7 +2073,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79074
79075 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79076 }
79077 -#endif
79078
79079 struct do_proc_dointvec_minmax_conv_param {
79080 int *min;
79081 @@ -2169,8 +2219,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79082 *i = val;
79083 } else {
79084 val = convdiv * (*i) / convmul;
79085 - if (!first)
79086 + if (!first) {
79087 err = proc_put_char(&buffer, &left, '\t');
79088 + if (err)
79089 + break;
79090 + }
79091 err = proc_put_long(&buffer, &left, val, false);
79092 if (err)
79093 break;
79094 @@ -2562,6 +2615,12 @@ int proc_dostring(struct ctl_table *table, int write,
79095 return -ENOSYS;
79096 }
79097
79098 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79099 + void __user *buffer, size_t *lenp, loff_t *ppos)
79100 +{
79101 + return -ENOSYS;
79102 +}
79103 +
79104 int proc_dointvec(struct ctl_table *table, int write,
79105 void __user *buffer, size_t *lenp, loff_t *ppos)
79106 {
79107 @@ -2618,5 +2677,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79108 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79109 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79110 EXPORT_SYMBOL(proc_dostring);
79111 +EXPORT_SYMBOL(proc_dostring_modpriv);
79112 EXPORT_SYMBOL(proc_doulongvec_minmax);
79113 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79114 diff --git a/kernel/sysctl_binary.c b/kernel/sysctl_binary.c
79115 index 0ddf3a0..a199f50 100644
79116 --- a/kernel/sysctl_binary.c
79117 +++ b/kernel/sysctl_binary.c
79118 @@ -989,7 +989,7 @@ static ssize_t bin_intvec(struct file *file,
79119 int i;
79120
79121 set_fs(KERNEL_DS);
79122 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79123 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79124 set_fs(old_fs);
79125 if (result < 0)
79126 goto out_kfree;
79127 @@ -1034,7 +1034,7 @@ static ssize_t bin_intvec(struct file *file,
79128 }
79129
79130 set_fs(KERNEL_DS);
79131 - result = vfs_write(file, buffer, str - buffer, &pos);
79132 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79133 set_fs(old_fs);
79134 if (result < 0)
79135 goto out_kfree;
79136 @@ -1067,7 +1067,7 @@ static ssize_t bin_ulongvec(struct file *file,
79137 int i;
79138
79139 set_fs(KERNEL_DS);
79140 - result = vfs_read(file, buffer, BUFSZ - 1, &pos);
79141 + result = vfs_read(file, (char __force_user *)buffer, BUFSZ - 1, &pos);
79142 set_fs(old_fs);
79143 if (result < 0)
79144 goto out_kfree;
79145 @@ -1112,7 +1112,7 @@ static ssize_t bin_ulongvec(struct file *file,
79146 }
79147
79148 set_fs(KERNEL_DS);
79149 - result = vfs_write(file, buffer, str - buffer, &pos);
79150 + result = vfs_write(file, (const char __force_user *)buffer, str - buffer, &pos);
79151 set_fs(old_fs);
79152 if (result < 0)
79153 goto out_kfree;
79154 @@ -1138,7 +1138,7 @@ static ssize_t bin_uuid(struct file *file,
79155 int i;
79156
79157 set_fs(KERNEL_DS);
79158 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79159 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79160 set_fs(old_fs);
79161 if (result < 0)
79162 goto out;
79163 @@ -1185,7 +1185,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79164 __le16 dnaddr;
79165
79166 set_fs(KERNEL_DS);
79167 - result = vfs_read(file, buf, sizeof(buf) - 1, &pos);
79168 + result = vfs_read(file, (char __force_user *)buf, sizeof(buf) - 1, &pos);
79169 set_fs(old_fs);
79170 if (result < 0)
79171 goto out;
79172 @@ -1234,7 +1234,7 @@ static ssize_t bin_dn_node_address(struct file *file,
79173 le16_to_cpu(dnaddr) & 0x3ff);
79174
79175 set_fs(KERNEL_DS);
79176 - result = vfs_write(file, buf, len, &pos);
79177 + result = vfs_write(file, (const char __force_user *)buf, len, &pos);
79178 set_fs(old_fs);
79179 if (result < 0)
79180 goto out;
79181 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79182 index 145bb4d..b2aa969 100644
79183 --- a/kernel/taskstats.c
79184 +++ b/kernel/taskstats.c
79185 @@ -28,9 +28,12 @@
79186 #include <linux/fs.h>
79187 #include <linux/file.h>
79188 #include <linux/pid_namespace.h>
79189 +#include <linux/grsecurity.h>
79190 #include <net/genetlink.h>
79191 #include <linux/atomic.h>
79192
79193 +extern int gr_is_taskstats_denied(int pid);
79194 +
79195 /*
79196 * Maximum length of a cpumask that can be specified in
79197 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79198 @@ -570,6 +573,9 @@ err:
79199
79200 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79201 {
79202 + if (gr_is_taskstats_denied(current->pid))
79203 + return -EACCES;
79204 +
79205 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79206 return cmd_attr_register_cpumask(info);
79207 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79208 diff --git a/kernel/time.c b/kernel/time.c
79209 index d226c6a..2f0d217 100644
79210 --- a/kernel/time.c
79211 +++ b/kernel/time.c
79212 @@ -163,6 +163,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79213 return error;
79214
79215 if (tz) {
79216 + /* we log in do_settimeofday called below, so don't log twice
79217 + */
79218 + if (!tv)
79219 + gr_log_timechange();
79220 +
79221 sys_tz = *tz;
79222 update_vsyscall_tz();
79223 if (firsttime) {
79224 @@ -493,7 +498,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79225 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79226 * value to a scaled second value.
79227 */
79228 -unsigned long
79229 +unsigned long __intentional_overflow(-1)
79230 timespec_to_jiffies(const struct timespec *value)
79231 {
79232 unsigned long sec = value->tv_sec;
79233 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79234 index f11d83b..d016d91 100644
79235 --- a/kernel/time/alarmtimer.c
79236 +++ b/kernel/time/alarmtimer.c
79237 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79238 struct platform_device *pdev;
79239 int error = 0;
79240 int i;
79241 - struct k_clock alarm_clock = {
79242 + static struct k_clock alarm_clock = {
79243 .clock_getres = alarm_clock_getres,
79244 .clock_get = alarm_clock_get,
79245 .timer_create = alarm_timer_create,
79246 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79247 index a13987a..36cd791 100644
79248 --- a/kernel/time/tick-broadcast.c
79249 +++ b/kernel/time/tick-broadcast.c
79250 @@ -116,7 +116,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79251 * then clear the broadcast bit.
79252 */
79253 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79254 - int cpu = smp_processor_id();
79255 + cpu = smp_processor_id();
79256
79257 cpumask_clear_cpu(cpu, tick_get_broadcast_mask());
79258 tick_broadcast_clear_oneshot(cpu);
79259 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79260 index cbc6acb..3a77191 100644
79261 --- a/kernel/time/timekeeping.c
79262 +++ b/kernel/time/timekeeping.c
79263 @@ -15,6 +15,7 @@
79264 #include <linux/init.h>
79265 #include <linux/mm.h>
79266 #include <linux/sched.h>
79267 +#include <linux/grsecurity.h>
79268 #include <linux/syscore_ops.h>
79269 #include <linux/clocksource.h>
79270 #include <linux/jiffies.h>
79271 @@ -412,6 +413,8 @@ int do_settimeofday(const struct timespec *tv)
79272 if (!timespec_valid_strict(tv))
79273 return -EINVAL;
79274
79275 + gr_log_timechange();
79276 +
79277 write_seqlock_irqsave(&tk->lock, flags);
79278
79279 timekeeping_forward_now(tk);
79280 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79281 index af5a7e9..715611a 100644
79282 --- a/kernel/time/timer_list.c
79283 +++ b/kernel/time/timer_list.c
79284 @@ -38,12 +38,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79285
79286 static void print_name_offset(struct seq_file *m, void *sym)
79287 {
79288 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79289 + SEQ_printf(m, "<%p>", NULL);
79290 +#else
79291 char symname[KSYM_NAME_LEN];
79292
79293 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79294 SEQ_printf(m, "<%pK>", sym);
79295 else
79296 SEQ_printf(m, "%s", symname);
79297 +#endif
79298 }
79299
79300 static void
79301 @@ -112,7 +116,11 @@ next_one:
79302 static void
79303 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79304 {
79305 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79306 + SEQ_printf(m, " .base: %p\n", NULL);
79307 +#else
79308 SEQ_printf(m, " .base: %pK\n", base);
79309 +#endif
79310 SEQ_printf(m, " .index: %d\n",
79311 base->index);
79312 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79313 @@ -293,7 +301,11 @@ static int __init init_timer_list_procfs(void)
79314 {
79315 struct proc_dir_entry *pe;
79316
79317 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79318 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79319 +#else
79320 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79321 +#endif
79322 if (!pe)
79323 return -ENOMEM;
79324 return 0;
79325 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79326 index 0b537f2..40d6c20 100644
79327 --- a/kernel/time/timer_stats.c
79328 +++ b/kernel/time/timer_stats.c
79329 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79330 static unsigned long nr_entries;
79331 static struct entry entries[MAX_ENTRIES];
79332
79333 -static atomic_t overflow_count;
79334 +static atomic_unchecked_t overflow_count;
79335
79336 /*
79337 * The entries are in a hash-table, for fast lookup:
79338 @@ -140,7 +140,7 @@ static void reset_entries(void)
79339 nr_entries = 0;
79340 memset(entries, 0, sizeof(entries));
79341 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79342 - atomic_set(&overflow_count, 0);
79343 + atomic_set_unchecked(&overflow_count, 0);
79344 }
79345
79346 static struct entry *alloc_entry(void)
79347 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79348 if (likely(entry))
79349 entry->count++;
79350 else
79351 - atomic_inc(&overflow_count);
79352 + atomic_inc_unchecked(&overflow_count);
79353
79354 out_unlock:
79355 raw_spin_unlock_irqrestore(lock, flags);
79356 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79357
79358 static void print_name_offset(struct seq_file *m, unsigned long addr)
79359 {
79360 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79361 + seq_printf(m, "<%p>", NULL);
79362 +#else
79363 char symname[KSYM_NAME_LEN];
79364
79365 if (lookup_symbol_name(addr, symname) < 0)
79366 - seq_printf(m, "<%p>", (void *)addr);
79367 + seq_printf(m, "<%pK>", (void *)addr);
79368 else
79369 seq_printf(m, "%s", symname);
79370 +#endif
79371 }
79372
79373 static int tstats_show(struct seq_file *m, void *v)
79374 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79375
79376 seq_puts(m, "Timer Stats Version: v0.2\n");
79377 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79378 - if (atomic_read(&overflow_count))
79379 + if (atomic_read_unchecked(&overflow_count))
79380 seq_printf(m, "Overflow: %d entries\n",
79381 - atomic_read(&overflow_count));
79382 + atomic_read_unchecked(&overflow_count));
79383
79384 for (i = 0; i < nr_entries; i++) {
79385 entry = entries + i;
79386 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79387 {
79388 struct proc_dir_entry *pe;
79389
79390 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79391 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79392 +#else
79393 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79394 +#endif
79395 if (!pe)
79396 return -ENOMEM;
79397 return 0;
79398 diff --git a/kernel/timer.c b/kernel/timer.c
79399 index 367d008..5dee98f 100644
79400 --- a/kernel/timer.c
79401 +++ b/kernel/timer.c
79402 @@ -1363,7 +1363,7 @@ void update_process_times(int user_tick)
79403 /*
79404 * This function runs timers and the timer-tq in bottom half context.
79405 */
79406 -static void run_timer_softirq(struct softirq_action *h)
79407 +static void run_timer_softirq(void)
79408 {
79409 struct tvec_base *base = __this_cpu_read(tvec_bases);
79410
79411 @@ -1481,7 +1481,7 @@ static void process_timeout(unsigned long __data)
79412 *
79413 * In all cases the return value is guaranteed to be non-negative.
79414 */
79415 -signed long __sched schedule_timeout(signed long timeout)
79416 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79417 {
79418 struct timer_list timer;
79419 unsigned long expire;
79420 @@ -1772,7 +1772,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79421 return NOTIFY_OK;
79422 }
79423
79424 -static struct notifier_block __cpuinitdata timers_nb = {
79425 +static struct notifier_block timers_nb = {
79426 .notifier_call = timer_cpu_notify,
79427 };
79428
79429 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79430 index c0bd030..62a1927 100644
79431 --- a/kernel/trace/blktrace.c
79432 +++ b/kernel/trace/blktrace.c
79433 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79434 struct blk_trace *bt = filp->private_data;
79435 char buf[16];
79436
79437 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79438 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79439
79440 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79441 }
79442 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79443 return 1;
79444
79445 bt = buf->chan->private_data;
79446 - atomic_inc(&bt->dropped);
79447 + atomic_inc_unchecked(&bt->dropped);
79448 return 0;
79449 }
79450
79451 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79452
79453 bt->dir = dir;
79454 bt->dev = dev;
79455 - atomic_set(&bt->dropped, 0);
79456 + atomic_set_unchecked(&bt->dropped, 0);
79457
79458 ret = -EIO;
79459 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79460 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79461 index 64bc5d8..1ed69e2 100644
79462 --- a/kernel/trace/ftrace.c
79463 +++ b/kernel/trace/ftrace.c
79464 @@ -668,7 +668,6 @@ int ftrace_profile_pages_init(struct ftrace_profile_stat *stat)
79465 free_page(tmp);
79466 }
79467
79468 - free_page((unsigned long)stat->pages);
79469 stat->pages = NULL;
79470 stat->start = NULL;
79471
79472 @@ -1874,12 +1873,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79473 if (unlikely(ftrace_disabled))
79474 return 0;
79475
79476 + ret = ftrace_arch_code_modify_prepare();
79477 + FTRACE_WARN_ON(ret);
79478 + if (ret)
79479 + return 0;
79480 +
79481 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79482 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79483 if (ret) {
79484 ftrace_bug(ret, ip);
79485 - return 0;
79486 }
79487 - return 1;
79488 + return ret ? 0 : 1;
79489 }
79490
79491 /*
79492 @@ -2965,7 +2969,7 @@ static void ftrace_free_entry_rcu(struct rcu_head *rhp)
79493
79494 int
79495 register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
79496 - void *data)
79497 + void *data)
79498 {
79499 struct ftrace_func_probe *entry;
79500 struct ftrace_page *pg;
79501 @@ -3832,8 +3836,10 @@ static int ftrace_process_locs(struct module *mod,
79502 if (!count)
79503 return 0;
79504
79505 + pax_open_kernel();
79506 sort(start, count, sizeof(*start),
79507 ftrace_cmp_ips, ftrace_swap_ips);
79508 + pax_close_kernel();
79509
79510 start_pg = ftrace_allocate_pages(count);
79511 if (!start_pg)
79512 @@ -4555,8 +4561,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79513 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79514
79515 static int ftrace_graph_active;
79516 -static struct notifier_block ftrace_suspend_notifier;
79517 -
79518 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79519 {
79520 return 0;
79521 @@ -4700,6 +4704,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79522 return NOTIFY_DONE;
79523 }
79524
79525 +static struct notifier_block ftrace_suspend_notifier = {
79526 + .notifier_call = ftrace_suspend_notifier_call
79527 +};
79528 +
79529 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79530 trace_func_graph_ent_t entryfunc)
79531 {
79532 @@ -4713,7 +4721,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79533 goto out;
79534 }
79535
79536 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79537 register_pm_notifier(&ftrace_suspend_notifier);
79538
79539 ftrace_graph_active++;
79540 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79541 index ce8514f..8233573 100644
79542 --- a/kernel/trace/ring_buffer.c
79543 +++ b/kernel/trace/ring_buffer.c
79544 @@ -346,9 +346,9 @@ struct buffer_data_page {
79545 */
79546 struct buffer_page {
79547 struct list_head list; /* list of buffer pages */
79548 - local_t write; /* index for next write */
79549 + local_unchecked_t write; /* index for next write */
79550 unsigned read; /* index for next read */
79551 - local_t entries; /* entries on this page */
79552 + local_unchecked_t entries; /* entries on this page */
79553 unsigned long real_end; /* real end of data */
79554 struct buffer_data_page *page; /* Actual data page */
79555 };
79556 @@ -461,8 +461,8 @@ struct ring_buffer_per_cpu {
79557 unsigned long last_overrun;
79558 local_t entries_bytes;
79559 local_t entries;
79560 - local_t overrun;
79561 - local_t commit_overrun;
79562 + local_unchecked_t overrun;
79563 + local_unchecked_t commit_overrun;
79564 local_t dropped_events;
79565 local_t committing;
79566 local_t commits;
79567 @@ -861,8 +861,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79568 *
79569 * We add a counter to the write field to denote this.
79570 */
79571 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79572 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79573 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79574 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79575
79576 /*
79577 * Just make sure we have seen our old_write and synchronize
79578 @@ -890,8 +890,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79579 * cmpxchg to only update if an interrupt did not already
79580 * do it for us. If the cmpxchg fails, we don't care.
79581 */
79582 - (void)local_cmpxchg(&next_page->write, old_write, val);
79583 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79584 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79585 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79586
79587 /*
79588 * No need to worry about races with clearing out the commit.
79589 @@ -1250,12 +1250,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79590
79591 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79592 {
79593 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79594 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79595 }
79596
79597 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79598 {
79599 - return local_read(&bpage->write) & RB_WRITE_MASK;
79600 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79601 }
79602
79603 static int
79604 @@ -1350,7 +1350,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79605 * bytes consumed in ring buffer from here.
79606 * Increment overrun to account for the lost events.
79607 */
79608 - local_add(page_entries, &cpu_buffer->overrun);
79609 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79610 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79611 }
79612
79613 @@ -1906,7 +1906,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79614 * it is our responsibility to update
79615 * the counters.
79616 */
79617 - local_add(entries, &cpu_buffer->overrun);
79618 + local_add_unchecked(entries, &cpu_buffer->overrun);
79619 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79620
79621 /*
79622 @@ -2056,7 +2056,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79623 if (tail == BUF_PAGE_SIZE)
79624 tail_page->real_end = 0;
79625
79626 - local_sub(length, &tail_page->write);
79627 + local_sub_unchecked(length, &tail_page->write);
79628 return;
79629 }
79630
79631 @@ -2091,7 +2091,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79632 rb_event_set_padding(event);
79633
79634 /* Set the write back to the previous setting */
79635 - local_sub(length, &tail_page->write);
79636 + local_sub_unchecked(length, &tail_page->write);
79637 return;
79638 }
79639
79640 @@ -2103,7 +2103,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79641
79642 /* Set write to end of buffer */
79643 length = (tail + length) - BUF_PAGE_SIZE;
79644 - local_sub(length, &tail_page->write);
79645 + local_sub_unchecked(length, &tail_page->write);
79646 }
79647
79648 /*
79649 @@ -2129,7 +2129,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79650 * about it.
79651 */
79652 if (unlikely(next_page == commit_page)) {
79653 - local_inc(&cpu_buffer->commit_overrun);
79654 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79655 goto out_reset;
79656 }
79657
79658 @@ -2185,7 +2185,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79659 cpu_buffer->tail_page) &&
79660 (cpu_buffer->commit_page ==
79661 cpu_buffer->reader_page))) {
79662 - local_inc(&cpu_buffer->commit_overrun);
79663 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79664 goto out_reset;
79665 }
79666 }
79667 @@ -2233,7 +2233,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79668 length += RB_LEN_TIME_EXTEND;
79669
79670 tail_page = cpu_buffer->tail_page;
79671 - write = local_add_return(length, &tail_page->write);
79672 + write = local_add_return_unchecked(length, &tail_page->write);
79673
79674 /* set write to only the index of the write */
79675 write &= RB_WRITE_MASK;
79676 @@ -2250,7 +2250,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79677 kmemcheck_annotate_bitfield(event, bitfield);
79678 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
79679
79680 - local_inc(&tail_page->entries);
79681 + local_inc_unchecked(&tail_page->entries);
79682
79683 /*
79684 * If this is the first commit on the page, then update
79685 @@ -2283,7 +2283,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79686
79687 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
79688 unsigned long write_mask =
79689 - local_read(&bpage->write) & ~RB_WRITE_MASK;
79690 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
79691 unsigned long event_length = rb_event_length(event);
79692 /*
79693 * This is on the tail page. It is possible that
79694 @@ -2293,7 +2293,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
79695 */
79696 old_index += write_mask;
79697 new_index += write_mask;
79698 - index = local_cmpxchg(&bpage->write, old_index, new_index);
79699 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
79700 if (index == old_index) {
79701 /* update counters */
79702 local_sub(event_length, &cpu_buffer->entries_bytes);
79703 @@ -2632,7 +2632,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79704
79705 /* Do the likely case first */
79706 if (likely(bpage->page == (void *)addr)) {
79707 - local_dec(&bpage->entries);
79708 + local_dec_unchecked(&bpage->entries);
79709 return;
79710 }
79711
79712 @@ -2644,7 +2644,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
79713 start = bpage;
79714 do {
79715 if (bpage->page == (void *)addr) {
79716 - local_dec(&bpage->entries);
79717 + local_dec_unchecked(&bpage->entries);
79718 return;
79719 }
79720 rb_inc_page(cpu_buffer, &bpage);
79721 @@ -2926,7 +2926,7 @@ static inline unsigned long
79722 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
79723 {
79724 return local_read(&cpu_buffer->entries) -
79725 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
79726 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
79727 }
79728
79729 /**
79730 @@ -3015,7 +3015,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
79731 return 0;
79732
79733 cpu_buffer = buffer->buffers[cpu];
79734 - ret = local_read(&cpu_buffer->overrun);
79735 + ret = local_read_unchecked(&cpu_buffer->overrun);
79736
79737 return ret;
79738 }
79739 @@ -3038,7 +3038,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
79740 return 0;
79741
79742 cpu_buffer = buffer->buffers[cpu];
79743 - ret = local_read(&cpu_buffer->commit_overrun);
79744 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
79745
79746 return ret;
79747 }
79748 @@ -3105,7 +3105,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
79749 /* if you care about this being correct, lock the buffer */
79750 for_each_buffer_cpu(buffer, cpu) {
79751 cpu_buffer = buffer->buffers[cpu];
79752 - overruns += local_read(&cpu_buffer->overrun);
79753 + overruns += local_read_unchecked(&cpu_buffer->overrun);
79754 }
79755
79756 return overruns;
79757 @@ -3281,8 +3281,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79758 /*
79759 * Reset the reader page to size zero.
79760 */
79761 - local_set(&cpu_buffer->reader_page->write, 0);
79762 - local_set(&cpu_buffer->reader_page->entries, 0);
79763 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79764 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79765 local_set(&cpu_buffer->reader_page->page->commit, 0);
79766 cpu_buffer->reader_page->real_end = 0;
79767
79768 @@ -3316,7 +3316,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
79769 * want to compare with the last_overrun.
79770 */
79771 smp_mb();
79772 - overwrite = local_read(&(cpu_buffer->overrun));
79773 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
79774
79775 /*
79776 * Here's the tricky part.
79777 @@ -3886,8 +3886,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79778
79779 cpu_buffer->head_page
79780 = list_entry(cpu_buffer->pages, struct buffer_page, list);
79781 - local_set(&cpu_buffer->head_page->write, 0);
79782 - local_set(&cpu_buffer->head_page->entries, 0);
79783 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
79784 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
79785 local_set(&cpu_buffer->head_page->page->commit, 0);
79786
79787 cpu_buffer->head_page->read = 0;
79788 @@ -3897,14 +3897,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
79789
79790 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
79791 INIT_LIST_HEAD(&cpu_buffer->new_pages);
79792 - local_set(&cpu_buffer->reader_page->write, 0);
79793 - local_set(&cpu_buffer->reader_page->entries, 0);
79794 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
79795 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
79796 local_set(&cpu_buffer->reader_page->page->commit, 0);
79797 cpu_buffer->reader_page->read = 0;
79798
79799 local_set(&cpu_buffer->entries_bytes, 0);
79800 - local_set(&cpu_buffer->overrun, 0);
79801 - local_set(&cpu_buffer->commit_overrun, 0);
79802 + local_set_unchecked(&cpu_buffer->overrun, 0);
79803 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
79804 local_set(&cpu_buffer->dropped_events, 0);
79805 local_set(&cpu_buffer->entries, 0);
79806 local_set(&cpu_buffer->committing, 0);
79807 @@ -4308,8 +4308,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
79808 rb_init_page(bpage);
79809 bpage = reader->page;
79810 reader->page = *data_page;
79811 - local_set(&reader->write, 0);
79812 - local_set(&reader->entries, 0);
79813 + local_set_unchecked(&reader->write, 0);
79814 + local_set_unchecked(&reader->entries, 0);
79815 reader->read = 0;
79816 *data_page = bpage;
79817
79818 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
79819 index fe1d581..43a0f38 100644
79820 --- a/kernel/trace/trace.c
79821 +++ b/kernel/trace/trace.c
79822 @@ -4494,10 +4494,9 @@ static const struct file_operations tracing_dyn_info_fops = {
79823 };
79824 #endif
79825
79826 -static struct dentry *d_tracer;
79827 -
79828 struct dentry *tracing_init_dentry(void)
79829 {
79830 + static struct dentry *d_tracer;
79831 static int once;
79832
79833 if (d_tracer)
79834 @@ -4517,10 +4516,9 @@ struct dentry *tracing_init_dentry(void)
79835 return d_tracer;
79836 }
79837
79838 -static struct dentry *d_percpu;
79839 -
79840 struct dentry *tracing_dentry_percpu(void)
79841 {
79842 + static struct dentry *d_percpu;
79843 static int once;
79844 struct dentry *d_tracer;
79845
79846 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
79847 index 880073d..42db7c3 100644
79848 --- a/kernel/trace/trace_events.c
79849 +++ b/kernel/trace/trace_events.c
79850 @@ -1330,10 +1330,6 @@ static LIST_HEAD(ftrace_module_file_list);
79851 struct ftrace_module_file_ops {
79852 struct list_head list;
79853 struct module *mod;
79854 - struct file_operations id;
79855 - struct file_operations enable;
79856 - struct file_operations format;
79857 - struct file_operations filter;
79858 };
79859
79860 static struct ftrace_module_file_ops *
79861 @@ -1354,17 +1350,12 @@ trace_create_file_ops(struct module *mod)
79862
79863 file_ops->mod = mod;
79864
79865 - file_ops->id = ftrace_event_id_fops;
79866 - file_ops->id.owner = mod;
79867 -
79868 - file_ops->enable = ftrace_enable_fops;
79869 - file_ops->enable.owner = mod;
79870 -
79871 - file_ops->filter = ftrace_event_filter_fops;
79872 - file_ops->filter.owner = mod;
79873 -
79874 - file_ops->format = ftrace_event_format_fops;
79875 - file_ops->format.owner = mod;
79876 + pax_open_kernel();
79877 + mod->trace_id.owner = mod;
79878 + mod->trace_enable.owner = mod;
79879 + mod->trace_filter.owner = mod;
79880 + mod->trace_format.owner = mod;
79881 + pax_close_kernel();
79882
79883 list_add(&file_ops->list, &ftrace_module_file_list);
79884
79885 @@ -1388,8 +1379,8 @@ static void trace_module_add_events(struct module *mod)
79886
79887 for_each_event(call, start, end) {
79888 __trace_add_event_call(*call, mod,
79889 - &file_ops->id, &file_ops->enable,
79890 - &file_ops->filter, &file_ops->format);
79891 + &mod->trace_id, &mod->trace_enable,
79892 + &mod->trace_filter, &mod->trace_format);
79893 }
79894 }
79895
79896 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
79897 index fd3c8aa..5f324a6 100644
79898 --- a/kernel/trace/trace_mmiotrace.c
79899 +++ b/kernel/trace/trace_mmiotrace.c
79900 @@ -24,7 +24,7 @@ struct header_iter {
79901 static struct trace_array *mmio_trace_array;
79902 static bool overrun_detected;
79903 static unsigned long prev_overruns;
79904 -static atomic_t dropped_count;
79905 +static atomic_unchecked_t dropped_count;
79906
79907 static void mmio_reset_data(struct trace_array *tr)
79908 {
79909 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
79910
79911 static unsigned long count_overruns(struct trace_iterator *iter)
79912 {
79913 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
79914 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
79915 unsigned long over = ring_buffer_overruns(iter->tr->buffer);
79916
79917 if (over > prev_overruns)
79918 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
79919 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
79920 sizeof(*entry), 0, pc);
79921 if (!event) {
79922 - atomic_inc(&dropped_count);
79923 + atomic_inc_unchecked(&dropped_count);
79924 return;
79925 }
79926 entry = ring_buffer_event_data(event);
79927 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
79928 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
79929 sizeof(*entry), 0, pc);
79930 if (!event) {
79931 - atomic_inc(&dropped_count);
79932 + atomic_inc_unchecked(&dropped_count);
79933 return;
79934 }
79935 entry = ring_buffer_event_data(event);
79936 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
79937 index 194d796..76edb8f 100644
79938 --- a/kernel/trace/trace_output.c
79939 +++ b/kernel/trace/trace_output.c
79940 @@ -278,7 +278,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
79941
79942 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
79943 if (!IS_ERR(p)) {
79944 - p = mangle_path(s->buffer + s->len, p, "\n");
79945 + p = mangle_path(s->buffer + s->len, p, "\n\\");
79946 if (p) {
79947 s->len = p - s->buffer;
79948 return 1;
79949 @@ -852,14 +852,16 @@ int register_ftrace_event(struct trace_event *event)
79950 goto out;
79951 }
79952
79953 + pax_open_kernel();
79954 if (event->funcs->trace == NULL)
79955 - event->funcs->trace = trace_nop_print;
79956 + *(void **)&event->funcs->trace = trace_nop_print;
79957 if (event->funcs->raw == NULL)
79958 - event->funcs->raw = trace_nop_print;
79959 + *(void **)&event->funcs->raw = trace_nop_print;
79960 if (event->funcs->hex == NULL)
79961 - event->funcs->hex = trace_nop_print;
79962 + *(void **)&event->funcs->hex = trace_nop_print;
79963 if (event->funcs->binary == NULL)
79964 - event->funcs->binary = trace_nop_print;
79965 + *(void **)&event->funcs->binary = trace_nop_print;
79966 + pax_close_kernel();
79967
79968 key = event->type & (EVENT_HASHSIZE - 1);
79969
79970 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
79971 index 42ca822..cdcacc6 100644
79972 --- a/kernel/trace/trace_stack.c
79973 +++ b/kernel/trace/trace_stack.c
79974 @@ -52,7 +52,7 @@ static inline void check_stack(void)
79975 return;
79976
79977 /* we do not handle interrupt stacks yet */
79978 - if (!object_is_on_stack(&this_size))
79979 + if (!object_starts_on_stack(&this_size))
79980 return;
79981
79982 local_irq_save(flags);
79983 diff --git a/kernel/user.c b/kernel/user.c
79984 index 7f6ff2b..1ac8f18 100644
79985 --- a/kernel/user.c
79986 +++ b/kernel/user.c
79987 @@ -47,9 +47,7 @@ struct user_namespace init_user_ns = {
79988 .count = 4294967295U,
79989 },
79990 },
79991 - .kref = {
79992 - .refcount = ATOMIC_INIT(3),
79993 - },
79994 + .count = ATOMIC_INIT(3),
79995 .owner = GLOBAL_ROOT_UID,
79996 .group = GLOBAL_ROOT_GID,
79997 .proc_inum = PROC_USER_INIT_INO,
79998 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
79999 index f45e128..a5a5fb6 100644
80000 --- a/kernel/user_namespace.c
80001 +++ b/kernel/user_namespace.c
80002 @@ -88,7 +88,7 @@ int create_user_ns(struct cred *new)
80003 return ret;
80004 }
80005
80006 - kref_init(&ns->kref);
80007 + atomic_set(&ns->count, 1);
80008 /* Leave the new->user_ns reference with the new user namespace. */
80009 ns->parent = parent_ns;
80010 ns->owner = owner;
80011 @@ -116,15 +116,16 @@ int unshare_userns(unsigned long unshare_flags, struct cred **new_cred)
80012 return create_user_ns(cred);
80013 }
80014
80015 -void free_user_ns(struct kref *kref)
80016 +void free_user_ns(struct user_namespace *ns)
80017 {
80018 - struct user_namespace *parent, *ns =
80019 - container_of(kref, struct user_namespace, kref);
80020 + struct user_namespace *parent;
80021
80022 - parent = ns->parent;
80023 - proc_free_inum(ns->proc_inum);
80024 - kmem_cache_free(user_ns_cachep, ns);
80025 - put_user_ns(parent);
80026 + do {
80027 + parent = ns->parent;
80028 + proc_free_inum(ns->proc_inum);
80029 + kmem_cache_free(user_ns_cachep, ns);
80030 + ns = parent;
80031 + } while (atomic_dec_and_test(&parent->count));
80032 }
80033 EXPORT_SYMBOL(free_user_ns);
80034
80035 @@ -815,7 +816,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80036 if (atomic_read(&current->mm->mm_users) > 1)
80037 return -EINVAL;
80038
80039 - if (current->fs->users != 1)
80040 + if (atomic_read(&current->fs->users) != 1)
80041 return -EINVAL;
80042
80043 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80044 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80045 index 63da38c..639904e 100644
80046 --- a/kernel/utsname_sysctl.c
80047 +++ b/kernel/utsname_sysctl.c
80048 @@ -46,7 +46,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80049 static int proc_do_uts_string(ctl_table *table, int write,
80050 void __user *buffer, size_t *lenp, loff_t *ppos)
80051 {
80052 - struct ctl_table uts_table;
80053 + ctl_table_no_const uts_table;
80054 int r;
80055 memcpy(&uts_table, table, sizeof(uts_table));
80056 uts_table.data = get_uts(table, write);
80057 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80058 index 75a2ab3..5961da7 100644
80059 --- a/kernel/watchdog.c
80060 +++ b/kernel/watchdog.c
80061 @@ -527,7 +527,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80062 }
80063 #endif /* CONFIG_SYSCTL */
80064
80065 -static struct smp_hotplug_thread watchdog_threads = {
80066 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80067 .store = &softlockup_watchdog,
80068 .thread_should_run = watchdog_should_run,
80069 .thread_fn = watchdog,
80070 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80071 index 67604e5..fe94fb1 100644
80072 --- a/lib/Kconfig.debug
80073 +++ b/lib/Kconfig.debug
80074 @@ -550,7 +550,7 @@ config DEBUG_MUTEXES
80075
80076 config DEBUG_LOCK_ALLOC
80077 bool "Lock debugging: detect incorrect freeing of live locks"
80078 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80079 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80080 select DEBUG_SPINLOCK
80081 select DEBUG_MUTEXES
80082 select LOCKDEP
80083 @@ -564,7 +564,7 @@ config DEBUG_LOCK_ALLOC
80084
80085 config PROVE_LOCKING
80086 bool "Lock debugging: prove locking correctness"
80087 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80088 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80089 select LOCKDEP
80090 select DEBUG_SPINLOCK
80091 select DEBUG_MUTEXES
80092 @@ -670,7 +670,7 @@ config LOCKDEP
80093
80094 config LOCK_STAT
80095 bool "Lock usage statistics"
80096 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80097 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80098 select LOCKDEP
80099 select DEBUG_SPINLOCK
80100 select DEBUG_MUTEXES
80101 @@ -1278,6 +1278,7 @@ config LATENCYTOP
80102 depends on DEBUG_KERNEL
80103 depends on STACKTRACE_SUPPORT
80104 depends on PROC_FS
80105 + depends on !GRKERNSEC_HIDESYM
80106 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80107 select KALLSYMS
80108 select KALLSYMS_ALL
80109 @@ -1306,7 +1307,7 @@ config INTERVAL_TREE_TEST
80110
80111 config PROVIDE_OHCI1394_DMA_INIT
80112 bool "Remote debugging over FireWire early on boot"
80113 - depends on PCI && X86
80114 + depends on PCI && X86 && !GRKERNSEC
80115 help
80116 If you want to debug problems which hang or crash the kernel early
80117 on boot and the crashing machine has a FireWire port, you can use
80118 @@ -1335,7 +1336,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80119
80120 config FIREWIRE_OHCI_REMOTE_DMA
80121 bool "Remote debugging over FireWire with firewire-ohci"
80122 - depends on FIREWIRE_OHCI
80123 + depends on FIREWIRE_OHCI && !GRKERNSEC
80124 help
80125 This option lets you use the FireWire bus for remote debugging
80126 with help of the firewire-ohci driver. It enables unfiltered
80127 diff --git a/lib/Makefile b/lib/Makefile
80128 index 02ed6c0..bd243da 100644
80129 --- a/lib/Makefile
80130 +++ b/lib/Makefile
80131 @@ -47,7 +47,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80132
80133 obj-$(CONFIG_BTREE) += btree.o
80134 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80135 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80136 +obj-y += list_debug.o
80137 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80138
80139 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80140 diff --git a/lib/bitmap.c b/lib/bitmap.c
80141 index 06f7e4f..f3cf2b0 100644
80142 --- a/lib/bitmap.c
80143 +++ b/lib/bitmap.c
80144 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80145 {
80146 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80147 u32 chunk;
80148 - const char __user __force *ubuf = (const char __user __force *)buf;
80149 + const char __user *ubuf = (const char __force_user *)buf;
80150
80151 bitmap_zero(maskp, nmaskbits);
80152
80153 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80154 {
80155 if (!access_ok(VERIFY_READ, ubuf, ulen))
80156 return -EFAULT;
80157 - return __bitmap_parse((const char __force *)ubuf,
80158 + return __bitmap_parse((const char __force_kernel *)ubuf,
80159 ulen, 1, maskp, nmaskbits);
80160
80161 }
80162 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80163 {
80164 unsigned a, b;
80165 int c, old_c, totaldigits;
80166 - const char __user __force *ubuf = (const char __user __force *)buf;
80167 + const char __user *ubuf = (const char __force_user *)buf;
80168 int exp_digit, in_range;
80169
80170 totaldigits = c = 0;
80171 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80172 {
80173 if (!access_ok(VERIFY_READ, ubuf, ulen))
80174 return -EFAULT;
80175 - return __bitmap_parselist((const char __force *)ubuf,
80176 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80177 ulen, 1, maskp, nmaskbits);
80178 }
80179 EXPORT_SYMBOL(bitmap_parselist_user);
80180 diff --git a/lib/bug.c b/lib/bug.c
80181 index d0cdf14..4d07bd2 100644
80182 --- a/lib/bug.c
80183 +++ b/lib/bug.c
80184 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80185 return BUG_TRAP_TYPE_NONE;
80186
80187 bug = find_bug(bugaddr);
80188 + if (!bug)
80189 + return BUG_TRAP_TYPE_NONE;
80190
80191 file = NULL;
80192 line = 0;
80193 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80194 index d11808c..dc2d6f8 100644
80195 --- a/lib/debugobjects.c
80196 +++ b/lib/debugobjects.c
80197 @@ -287,7 +287,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80198 if (limit > 4)
80199 return;
80200
80201 - is_on_stack = object_is_on_stack(addr);
80202 + is_on_stack = object_starts_on_stack(addr);
80203 if (is_on_stack == onstack)
80204 return;
80205
80206 diff --git a/lib/devres.c b/lib/devres.c
80207 index 80b9c76..9e32279 100644
80208 --- a/lib/devres.c
80209 +++ b/lib/devres.c
80210 @@ -80,7 +80,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80211 void devm_iounmap(struct device *dev, void __iomem *addr)
80212 {
80213 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80214 - (void *)addr));
80215 + (void __force *)addr));
80216 iounmap(addr);
80217 }
80218 EXPORT_SYMBOL(devm_iounmap);
80219 @@ -192,7 +192,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80220 {
80221 ioport_unmap(addr);
80222 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80223 - devm_ioport_map_match, (void *)addr));
80224 + devm_ioport_map_match, (void __force *)addr));
80225 }
80226 EXPORT_SYMBOL(devm_ioport_unmap);
80227
80228 diff --git a/lib/div64.c b/lib/div64.c
80229 index a163b6c..9618fa5 100644
80230 --- a/lib/div64.c
80231 +++ b/lib/div64.c
80232 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80233 EXPORT_SYMBOL(__div64_32);
80234
80235 #ifndef div_s64_rem
80236 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80237 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80238 {
80239 u64 quotient;
80240
80241 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80242 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80243 */
80244 #ifndef div64_u64
80245 -u64 div64_u64(u64 dividend, u64 divisor)
80246 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80247 {
80248 u32 high = divisor >> 32;
80249 u64 quot;
80250 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80251 index 5e396ac..58d5de1 100644
80252 --- a/lib/dma-debug.c
80253 +++ b/lib/dma-debug.c
80254 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80255
80256 void dma_debug_add_bus(struct bus_type *bus)
80257 {
80258 - struct notifier_block *nb;
80259 + notifier_block_no_const *nb;
80260
80261 if (global_disable)
80262 return;
80263 @@ -942,7 +942,7 @@ out:
80264
80265 static void check_for_stack(struct device *dev, void *addr)
80266 {
80267 - if (object_is_on_stack(addr))
80268 + if (object_starts_on_stack(addr))
80269 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80270 "stack [addr=%p]\n", addr);
80271 }
80272 diff --git a/lib/inflate.c b/lib/inflate.c
80273 index 013a761..c28f3fc 100644
80274 --- a/lib/inflate.c
80275 +++ b/lib/inflate.c
80276 @@ -269,7 +269,7 @@ static void free(void *where)
80277 malloc_ptr = free_mem_ptr;
80278 }
80279 #else
80280 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80281 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80282 #define free(a) kfree(a)
80283 #endif
80284
80285 diff --git a/lib/ioremap.c b/lib/ioremap.c
80286 index 0c9216c..863bd89 100644
80287 --- a/lib/ioremap.c
80288 +++ b/lib/ioremap.c
80289 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80290 unsigned long next;
80291
80292 phys_addr -= addr;
80293 - pmd = pmd_alloc(&init_mm, pud, addr);
80294 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80295 if (!pmd)
80296 return -ENOMEM;
80297 do {
80298 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80299 unsigned long next;
80300
80301 phys_addr -= addr;
80302 - pud = pud_alloc(&init_mm, pgd, addr);
80303 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80304 if (!pud)
80305 return -ENOMEM;
80306 do {
80307 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80308 index bd2bea9..6b3c95e 100644
80309 --- a/lib/is_single_threaded.c
80310 +++ b/lib/is_single_threaded.c
80311 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80312 struct task_struct *p, *t;
80313 bool ret;
80314
80315 + if (!mm)
80316 + return true;
80317 +
80318 if (atomic_read(&task->signal->live) != 1)
80319 return false;
80320
80321 diff --git a/lib/kobject.c b/lib/kobject.c
80322 index e07ee1f..a4fd13d 100644
80323 --- a/lib/kobject.c
80324 +++ b/lib/kobject.c
80325 @@ -529,6 +529,13 @@ struct kobject *kobject_get(struct kobject *kobj)
80326 return kobj;
80327 }
80328
80329 +static struct kobject *kobject_get_unless_zero(struct kobject *kobj)
80330 +{
80331 + if (!kref_get_unless_zero(&kobj->kref))
80332 + kobj = NULL;
80333 + return kobj;
80334 +}
80335 +
80336 /*
80337 * kobject_cleanup - free kobject resources.
80338 * @kobj: object to cleanup
80339 @@ -751,7 +758,7 @@ struct kobject *kset_find_obj(struct kset *kset, const char *name)
80340
80341 list_for_each_entry(k, &kset->list, entry) {
80342 if (kobject_name(k) && !strcmp(kobject_name(k), name)) {
80343 - ret = kobject_get(k);
80344 + ret = kobject_get_unless_zero(k);
80345 break;
80346 }
80347 }
80348 @@ -852,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80349
80350
80351 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80352 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80353 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80354
80355 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80356 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80357 {
80358 enum kobj_ns_type type = ops->type;
80359 int error;
80360 diff --git a/lib/list_debug.c b/lib/list_debug.c
80361 index c24c2f7..06e070b 100644
80362 --- a/lib/list_debug.c
80363 +++ b/lib/list_debug.c
80364 @@ -11,7 +11,9 @@
80365 #include <linux/bug.h>
80366 #include <linux/kernel.h>
80367 #include <linux/rculist.h>
80368 +#include <linux/mm.h>
80369
80370 +#ifdef CONFIG_DEBUG_LIST
80371 /*
80372 * Insert a new entry between two known consecutive entries.
80373 *
80374 @@ -19,21 +21,32 @@
80375 * the prev/next entries already!
80376 */
80377
80378 -void __list_add(struct list_head *new,
80379 - struct list_head *prev,
80380 - struct list_head *next)
80381 +static bool __list_add_debug(struct list_head *new,
80382 + struct list_head *prev,
80383 + struct list_head *next)
80384 {
80385 - WARN(next->prev != prev,
80386 + if (WARN(next->prev != prev,
80387 "list_add corruption. next->prev should be "
80388 "prev (%p), but was %p. (next=%p).\n",
80389 - prev, next->prev, next);
80390 - WARN(prev->next != next,
80391 + prev, next->prev, next) ||
80392 + WARN(prev->next != next,
80393 "list_add corruption. prev->next should be "
80394 "next (%p), but was %p. (prev=%p).\n",
80395 - next, prev->next, prev);
80396 - WARN(new == prev || new == next,
80397 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80398 - new, prev, next);
80399 + next, prev->next, prev) ||
80400 + WARN(new == prev || new == next,
80401 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80402 + new, prev, next))
80403 + return false;
80404 + return true;
80405 +}
80406 +
80407 +void __list_add(struct list_head *new,
80408 + struct list_head *prev,
80409 + struct list_head *next)
80410 +{
80411 + if (!__list_add_debug(new, prev, next))
80412 + return;
80413 +
80414 next->prev = new;
80415 new->next = next;
80416 new->prev = prev;
80417 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80418 }
80419 EXPORT_SYMBOL(__list_add);
80420
80421 -void __list_del_entry(struct list_head *entry)
80422 +static bool __list_del_entry_debug(struct list_head *entry)
80423 {
80424 struct list_head *prev, *next;
80425
80426 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80427 WARN(next->prev != entry,
80428 "list_del corruption. next->prev should be %p, "
80429 "but was %p\n", entry, next->prev))
80430 + return false;
80431 + return true;
80432 +}
80433 +
80434 +void __list_del_entry(struct list_head *entry)
80435 +{
80436 + if (!__list_del_entry_debug(entry))
80437 return;
80438
80439 - __list_del(prev, next);
80440 + __list_del(entry->prev, entry->next);
80441 }
80442 EXPORT_SYMBOL(__list_del_entry);
80443
80444 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80445 void __list_add_rcu(struct list_head *new,
80446 struct list_head *prev, struct list_head *next)
80447 {
80448 - WARN(next->prev != prev,
80449 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80450 - prev, next->prev, next);
80451 - WARN(prev->next != next,
80452 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80453 - next, prev->next, prev);
80454 + if (!__list_add_debug(new, prev, next))
80455 + return;
80456 +
80457 new->next = next;
80458 new->prev = prev;
80459 rcu_assign_pointer(list_next_rcu(prev), new);
80460 next->prev = new;
80461 }
80462 EXPORT_SYMBOL(__list_add_rcu);
80463 +#endif
80464 +
80465 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80466 +{
80467 +#ifdef CONFIG_DEBUG_LIST
80468 + if (!__list_add_debug(new, prev, next))
80469 + return;
80470 +#endif
80471 +
80472 + pax_open_kernel();
80473 + next->prev = new;
80474 + new->next = next;
80475 + new->prev = prev;
80476 + prev->next = new;
80477 + pax_close_kernel();
80478 +}
80479 +EXPORT_SYMBOL(__pax_list_add);
80480 +
80481 +void pax_list_del(struct list_head *entry)
80482 +{
80483 +#ifdef CONFIG_DEBUG_LIST
80484 + if (!__list_del_entry_debug(entry))
80485 + return;
80486 +#endif
80487 +
80488 + pax_open_kernel();
80489 + __list_del(entry->prev, entry->next);
80490 + entry->next = LIST_POISON1;
80491 + entry->prev = LIST_POISON2;
80492 + pax_close_kernel();
80493 +}
80494 +EXPORT_SYMBOL(pax_list_del);
80495 +
80496 +void pax_list_del_init(struct list_head *entry)
80497 +{
80498 + pax_open_kernel();
80499 + __list_del(entry->prev, entry->next);
80500 + INIT_LIST_HEAD(entry);
80501 + pax_close_kernel();
80502 +}
80503 +EXPORT_SYMBOL(pax_list_del_init);
80504 +
80505 +void __pax_list_add_rcu(struct list_head *new,
80506 + struct list_head *prev, struct list_head *next)
80507 +{
80508 +#ifdef CONFIG_DEBUG_LIST
80509 + if (!__list_add_debug(new, prev, next))
80510 + return;
80511 +#endif
80512 +
80513 + pax_open_kernel();
80514 + new->next = next;
80515 + new->prev = prev;
80516 + rcu_assign_pointer(list_next_rcu(prev), new);
80517 + next->prev = new;
80518 + pax_close_kernel();
80519 +}
80520 +EXPORT_SYMBOL(__pax_list_add_rcu);
80521 +
80522 +void pax_list_del_rcu(struct list_head *entry)
80523 +{
80524 +#ifdef CONFIG_DEBUG_LIST
80525 + if (!__list_del_entry_debug(entry))
80526 + return;
80527 +#endif
80528 +
80529 + pax_open_kernel();
80530 + __list_del(entry->prev, entry->next);
80531 + entry->next = LIST_POISON1;
80532 + entry->prev = LIST_POISON2;
80533 + pax_close_kernel();
80534 +}
80535 +EXPORT_SYMBOL(pax_list_del_rcu);
80536 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80537 index e796429..6e38f9f 100644
80538 --- a/lib/radix-tree.c
80539 +++ b/lib/radix-tree.c
80540 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80541 int nr;
80542 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80543 };
80544 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80545 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80546
80547 static inline void *ptr_to_indirect(void *ptr)
80548 {
80549 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80550 index bb2b201..46abaf9 100644
80551 --- a/lib/strncpy_from_user.c
80552 +++ b/lib/strncpy_from_user.c
80553 @@ -21,7 +21,7 @@
80554 */
80555 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80556 {
80557 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80558 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80559 long res = 0;
80560
80561 /*
80562 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80563 index a28df52..3d55877 100644
80564 --- a/lib/strnlen_user.c
80565 +++ b/lib/strnlen_user.c
80566 @@ -26,7 +26,7 @@
80567 */
80568 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80569 {
80570 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80571 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80572 long align, res = 0;
80573 unsigned long c;
80574
80575 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80576 index 196b069..358f342 100644
80577 --- a/lib/swiotlb.c
80578 +++ b/lib/swiotlb.c
80579 @@ -642,7 +642,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80580
80581 void
80582 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80583 - dma_addr_t dev_addr)
80584 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80585 {
80586 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80587
80588 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80589 index fab33a9..3b5fe68 100644
80590 --- a/lib/vsprintf.c
80591 +++ b/lib/vsprintf.c
80592 @@ -16,6 +16,9 @@
80593 * - scnprintf and vscnprintf
80594 */
80595
80596 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80597 +#define __INCLUDED_BY_HIDESYM 1
80598 +#endif
80599 #include <stdarg.h>
80600 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80601 #include <linux/types.h>
80602 @@ -541,7 +544,7 @@ char *symbol_string(char *buf, char *end, void *ptr,
80603 char sym[KSYM_SYMBOL_LEN];
80604 if (ext == 'B')
80605 sprint_backtrace(sym, value);
80606 - else if (ext != 'f' && ext != 's')
80607 + else if (ext != 'f' && ext != 's' && ext != 'a')
80608 sprint_symbol(sym, value);
80609 else
80610 sprint_symbol_no_offset(sym, value);
80611 @@ -974,7 +977,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80612 return number(buf, end, *(const netdev_features_t *)addr, spec);
80613 }
80614
80615 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80616 +int kptr_restrict __read_mostly = 2;
80617 +#else
80618 int kptr_restrict __read_mostly;
80619 +#endif
80620
80621 /*
80622 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80623 @@ -988,6 +995,8 @@ int kptr_restrict __read_mostly;
80624 * - 'S' For symbolic direct pointers with offset
80625 * - 's' For symbolic direct pointers without offset
80626 * - 'B' For backtraced symbolic direct pointers with offset
80627 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80628 + * - 'a' For symbolic direct pointers without offset approved for use with GRKERNSEC_HIDESYM
80629 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80630 * - 'r' For raw struct resource, e.g., [mem 0x0-0x1f flags 0x201]
80631 * - 'M' For a 6-byte MAC address, it prints the address in the
80632 @@ -1043,12 +1052,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80633
80634 if (!ptr && *fmt != 'K') {
80635 /*
80636 - * Print (null) with the same width as a pointer so it makes
80637 + * Print (nil) with the same width as a pointer so it makes
80638 * tabular output look nice.
80639 */
80640 if (spec.field_width == -1)
80641 spec.field_width = default_width;
80642 - return string(buf, end, "(null)", spec);
80643 + return string(buf, end, "(nil)", spec);
80644 }
80645
80646 switch (*fmt) {
80647 @@ -1058,6 +1067,13 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80648 /* Fallthrough */
80649 case 'S':
80650 case 's':
80651 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80652 + break;
80653 +#else
80654 + return symbol_string(buf, end, ptr, spec, *fmt);
80655 +#endif
80656 + case 'A':
80657 + case 'a':
80658 case 'B':
80659 return symbol_string(buf, end, ptr, spec, *fmt);
80660 case 'R':
80661 @@ -1098,6 +1114,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80662 va_end(va);
80663 return buf;
80664 }
80665 + case 'P':
80666 + break;
80667 case 'K':
80668 /*
80669 * %pK cannot be used in IRQ context because its test
80670 @@ -1121,6 +1139,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80671 }
80672 break;
80673 }
80674 +
80675 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80676 + /* 'P' = approved pointers to copy to userland,
80677 + as in the /proc/kallsyms case, as we make it display nothing
80678 + for non-root users, and the real contents for root users
80679 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80680 + above
80681 + */
80682 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80683 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80684 + dump_stack();
80685 + ptr = NULL;
80686 + }
80687 +#endif
80688 +
80689 spec.flags |= SMALL;
80690 if (spec.field_width == -1) {
80691 spec.field_width = default_width;
80692 @@ -1842,11 +1875,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80693 typeof(type) value; \
80694 if (sizeof(type) == 8) { \
80695 args = PTR_ALIGN(args, sizeof(u32)); \
80696 - *(u32 *)&value = *(u32 *)args; \
80697 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80698 + *(u32 *)&value = *(const u32 *)args; \
80699 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80700 } else { \
80701 args = PTR_ALIGN(args, sizeof(type)); \
80702 - value = *(typeof(type) *)args; \
80703 + value = *(const typeof(type) *)args; \
80704 } \
80705 args += sizeof(type); \
80706 value; \
80707 @@ -1909,7 +1942,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80708 case FORMAT_TYPE_STR: {
80709 const char *str_arg = args;
80710 args += strlen(str_arg) + 1;
80711 - str = string(str, end, (char *)str_arg, spec);
80712 + str = string(str, end, str_arg, spec);
80713 break;
80714 }
80715
80716 diff --git a/localversion-grsec b/localversion-grsec
80717 new file mode 100644
80718 index 0000000..7cd6065
80719 --- /dev/null
80720 +++ b/localversion-grsec
80721 @@ -0,0 +1 @@
80722 +-grsec
80723 diff --git a/mm/Kconfig b/mm/Kconfig
80724 index 278e3ab..87c384d 100644
80725 --- a/mm/Kconfig
80726 +++ b/mm/Kconfig
80727 @@ -286,10 +286,10 @@ config KSM
80728 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
80729
80730 config DEFAULT_MMAP_MIN_ADDR
80731 - int "Low address space to protect from user allocation"
80732 + int "Low address space to protect from user allocation"
80733 depends on MMU
80734 - default 4096
80735 - help
80736 + default 65536
80737 + help
80738 This is the portion of low virtual memory which should be protected
80739 from userspace allocation. Keeping a user from writing to low pages
80740 can help reduce the impact of kernel NULL pointer bugs.
80741 @@ -320,7 +320,7 @@ config MEMORY_FAILURE
80742
80743 config HWPOISON_INJECT
80744 tristate "HWPoison pages injector"
80745 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
80746 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
80747 select PROC_PAGE_MONITOR
80748
80749 config NOMMU_INITIAL_TRIM_EXCESS
80750 diff --git a/mm/filemap.c b/mm/filemap.c
80751 index 83efee7..3f99381 100644
80752 --- a/mm/filemap.c
80753 +++ b/mm/filemap.c
80754 @@ -1747,7 +1747,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
80755 struct address_space *mapping = file->f_mapping;
80756
80757 if (!mapping->a_ops->readpage)
80758 - return -ENOEXEC;
80759 + return -ENODEV;
80760 file_accessed(file);
80761 vma->vm_ops = &generic_file_vm_ops;
80762 return 0;
80763 @@ -2087,6 +2087,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
80764 *pos = i_size_read(inode);
80765
80766 if (limit != RLIM_INFINITY) {
80767 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
80768 if (*pos >= limit) {
80769 send_sig(SIGXFSZ, current, 0);
80770 return -EFBIG;
80771 diff --git a/mm/fremap.c b/mm/fremap.c
80772 index a0aaf0e..20325c3 100644
80773 --- a/mm/fremap.c
80774 +++ b/mm/fremap.c
80775 @@ -157,6 +157,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
80776 retry:
80777 vma = find_vma(mm, start);
80778
80779 +#ifdef CONFIG_PAX_SEGMEXEC
80780 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
80781 + goto out;
80782 +#endif
80783 +
80784 /*
80785 * Make sure the vma is shared, that it supports prefaulting,
80786 * and that the remapped range is valid and fully within
80787 diff --git a/mm/highmem.c b/mm/highmem.c
80788 index b32b70c..e512eb0 100644
80789 --- a/mm/highmem.c
80790 +++ b/mm/highmem.c
80791 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
80792 * So no dangers, even with speculative execution.
80793 */
80794 page = pte_page(pkmap_page_table[i]);
80795 + pax_open_kernel();
80796 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
80797 -
80798 + pax_close_kernel();
80799 set_page_address(page, NULL);
80800 need_flush = 1;
80801 }
80802 @@ -198,9 +199,11 @@ start:
80803 }
80804 }
80805 vaddr = PKMAP_ADDR(last_pkmap_nr);
80806 +
80807 + pax_open_kernel();
80808 set_pte_at(&init_mm, vaddr,
80809 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
80810 -
80811 + pax_close_kernel();
80812 pkmap_count[last_pkmap_nr] = 1;
80813 set_page_address(page, (void *)vaddr);
80814
80815 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
80816 index d7cec92..b05cc33 100644
80817 --- a/mm/hugetlb.c
80818 +++ b/mm/hugetlb.c
80819 @@ -2008,15 +2008,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
80820 struct hstate *h = &default_hstate;
80821 unsigned long tmp;
80822 int ret;
80823 + ctl_table_no_const hugetlb_table;
80824
80825 tmp = h->max_huge_pages;
80826
80827 if (write && h->order >= MAX_ORDER)
80828 return -EINVAL;
80829
80830 - table->data = &tmp;
80831 - table->maxlen = sizeof(unsigned long);
80832 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80833 + hugetlb_table = *table;
80834 + hugetlb_table.data = &tmp;
80835 + hugetlb_table.maxlen = sizeof(unsigned long);
80836 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80837 if (ret)
80838 goto out;
80839
80840 @@ -2073,15 +2075,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
80841 struct hstate *h = &default_hstate;
80842 unsigned long tmp;
80843 int ret;
80844 + ctl_table_no_const hugetlb_table;
80845
80846 tmp = h->nr_overcommit_huge_pages;
80847
80848 if (write && h->order >= MAX_ORDER)
80849 return -EINVAL;
80850
80851 - table->data = &tmp;
80852 - table->maxlen = sizeof(unsigned long);
80853 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
80854 + hugetlb_table = *table;
80855 + hugetlb_table.data = &tmp;
80856 + hugetlb_table.maxlen = sizeof(unsigned long);
80857 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
80858 if (ret)
80859 goto out;
80860
80861 @@ -2515,6 +2519,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
80862 return 1;
80863 }
80864
80865 +#ifdef CONFIG_PAX_SEGMEXEC
80866 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
80867 +{
80868 + struct mm_struct *mm = vma->vm_mm;
80869 + struct vm_area_struct *vma_m;
80870 + unsigned long address_m;
80871 + pte_t *ptep_m;
80872 +
80873 + vma_m = pax_find_mirror_vma(vma);
80874 + if (!vma_m)
80875 + return;
80876 +
80877 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
80878 + address_m = address + SEGMEXEC_TASK_SIZE;
80879 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
80880 + get_page(page_m);
80881 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
80882 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
80883 +}
80884 +#endif
80885 +
80886 /*
80887 * Hugetlb_cow() should be called with page lock of the original hugepage held.
80888 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
80889 @@ -2633,6 +2658,11 @@ retry_avoidcopy:
80890 make_huge_pte(vma, new_page, 1));
80891 page_remove_rmap(old_page);
80892 hugepage_add_new_anon_rmap(new_page, vma, address);
80893 +
80894 +#ifdef CONFIG_PAX_SEGMEXEC
80895 + pax_mirror_huge_pte(vma, address, new_page);
80896 +#endif
80897 +
80898 /* Make the old page be freed below */
80899 new_page = old_page;
80900 }
80901 @@ -2792,6 +2822,10 @@ retry:
80902 && (vma->vm_flags & VM_SHARED)));
80903 set_huge_pte_at(mm, address, ptep, new_pte);
80904
80905 +#ifdef CONFIG_PAX_SEGMEXEC
80906 + pax_mirror_huge_pte(vma, address, page);
80907 +#endif
80908 +
80909 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
80910 /* Optimization, do the COW without a second fault */
80911 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
80912 @@ -2821,6 +2855,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80913 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
80914 struct hstate *h = hstate_vma(vma);
80915
80916 +#ifdef CONFIG_PAX_SEGMEXEC
80917 + struct vm_area_struct *vma_m;
80918 +#endif
80919 +
80920 address &= huge_page_mask(h);
80921
80922 ptep = huge_pte_offset(mm, address);
80923 @@ -2834,6 +2872,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
80924 VM_FAULT_SET_HINDEX(hstate_index(h));
80925 }
80926
80927 +#ifdef CONFIG_PAX_SEGMEXEC
80928 + vma_m = pax_find_mirror_vma(vma);
80929 + if (vma_m) {
80930 + unsigned long address_m;
80931 +
80932 + if (vma->vm_start > vma_m->vm_start) {
80933 + address_m = address;
80934 + address -= SEGMEXEC_TASK_SIZE;
80935 + vma = vma_m;
80936 + h = hstate_vma(vma);
80937 + } else
80938 + address_m = address + SEGMEXEC_TASK_SIZE;
80939 +
80940 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
80941 + return VM_FAULT_OOM;
80942 + address_m &= HPAGE_MASK;
80943 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
80944 + }
80945 +#endif
80946 +
80947 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
80948 if (!ptep)
80949 return VM_FAULT_OOM;
80950 diff --git a/mm/internal.h b/mm/internal.h
80951 index 9ba2110..eaf0674 100644
80952 --- a/mm/internal.h
80953 +++ b/mm/internal.h
80954 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
80955 * in mm/page_alloc.c
80956 */
80957 extern void __free_pages_bootmem(struct page *page, unsigned int order);
80958 +extern void free_compound_page(struct page *page);
80959 extern void prep_compound_page(struct page *page, unsigned long order);
80960 #ifdef CONFIG_MEMORY_FAILURE
80961 extern bool is_free_buddy_page(struct page *page);
80962 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
80963 index 752a705..6c3102e 100644
80964 --- a/mm/kmemleak.c
80965 +++ b/mm/kmemleak.c
80966 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
80967
80968 for (i = 0; i < object->trace_len; i++) {
80969 void *ptr = (void *)object->trace[i];
80970 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
80971 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
80972 }
80973 }
80974
80975 @@ -1853,7 +1853,7 @@ static int __init kmemleak_late_init(void)
80976 return -ENOMEM;
80977 }
80978
80979 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
80980 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
80981 &kmemleak_fops);
80982 if (!dentry)
80983 pr_warning("Failed to create the debugfs kmemleak file\n");
80984 diff --git a/mm/maccess.c b/mm/maccess.c
80985 index d53adf9..03a24bf 100644
80986 --- a/mm/maccess.c
80987 +++ b/mm/maccess.c
80988 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
80989 set_fs(KERNEL_DS);
80990 pagefault_disable();
80991 ret = __copy_from_user_inatomic(dst,
80992 - (__force const void __user *)src, size);
80993 + (const void __force_user *)src, size);
80994 pagefault_enable();
80995 set_fs(old_fs);
80996
80997 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
80998
80999 set_fs(KERNEL_DS);
81000 pagefault_disable();
81001 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81002 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81003 pagefault_enable();
81004 set_fs(old_fs);
81005
81006 diff --git a/mm/madvise.c b/mm/madvise.c
81007 index 03dfa5c..b032917 100644
81008 --- a/mm/madvise.c
81009 +++ b/mm/madvise.c
81010 @@ -48,6 +48,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81011 pgoff_t pgoff;
81012 unsigned long new_flags = vma->vm_flags;
81013
81014 +#ifdef CONFIG_PAX_SEGMEXEC
81015 + struct vm_area_struct *vma_m;
81016 +#endif
81017 +
81018 switch (behavior) {
81019 case MADV_NORMAL:
81020 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81021 @@ -123,6 +127,13 @@ success:
81022 /*
81023 * vm_flags is protected by the mmap_sem held in write mode.
81024 */
81025 +
81026 +#ifdef CONFIG_PAX_SEGMEXEC
81027 + vma_m = pax_find_mirror_vma(vma);
81028 + if (vma_m)
81029 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81030 +#endif
81031 +
81032 vma->vm_flags = new_flags;
81033
81034 out:
81035 @@ -181,6 +192,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81036 struct vm_area_struct ** prev,
81037 unsigned long start, unsigned long end)
81038 {
81039 +
81040 +#ifdef CONFIG_PAX_SEGMEXEC
81041 + struct vm_area_struct *vma_m;
81042 +#endif
81043 +
81044 *prev = vma;
81045 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81046 return -EINVAL;
81047 @@ -193,6 +209,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81048 zap_page_range(vma, start, end - start, &details);
81049 } else
81050 zap_page_range(vma, start, end - start, NULL);
81051 +
81052 +#ifdef CONFIG_PAX_SEGMEXEC
81053 + vma_m = pax_find_mirror_vma(vma);
81054 + if (vma_m) {
81055 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81056 + struct zap_details details = {
81057 + .nonlinear_vma = vma_m,
81058 + .last_index = ULONG_MAX,
81059 + };
81060 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81061 + } else
81062 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81063 + }
81064 +#endif
81065 +
81066 return 0;
81067 }
81068
81069 @@ -397,6 +428,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81070 if (end < start)
81071 goto out;
81072
81073 +#ifdef CONFIG_PAX_SEGMEXEC
81074 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81075 + if (end > SEGMEXEC_TASK_SIZE)
81076 + goto out;
81077 + } else
81078 +#endif
81079 +
81080 + if (end > TASK_SIZE)
81081 + goto out;
81082 +
81083 error = 0;
81084 if (end == start)
81085 goto out;
81086 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81087 index c6e4dd3..1f41988 100644
81088 --- a/mm/memory-failure.c
81089 +++ b/mm/memory-failure.c
81090 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81091
81092 int sysctl_memory_failure_recovery __read_mostly = 1;
81093
81094 -atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81095 +atomic_long_unchecked_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
81096
81097 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81098
81099 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81100 pfn, t->comm, t->pid);
81101 si.si_signo = SIGBUS;
81102 si.si_errno = 0;
81103 - si.si_addr = (void *)addr;
81104 + si.si_addr = (void __user *)addr;
81105 #ifdef __ARCH_SI_TRAPNO
81106 si.si_trapno = trapno;
81107 #endif
81108 @@ -760,7 +760,7 @@ static struct page_state {
81109 unsigned long res;
81110 char *msg;
81111 int (*action)(struct page *p, unsigned long pfn);
81112 -} error_states[] = {
81113 +} __do_const error_states[] = {
81114 { reserved, reserved, "reserved kernel", me_kernel },
81115 /*
81116 * free pages are specially detected outside this table:
81117 @@ -1040,7 +1040,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81118 }
81119
81120 nr_pages = 1 << compound_trans_order(hpage);
81121 - atomic_long_add(nr_pages, &mce_bad_pages);
81122 + atomic_long_add_unchecked(nr_pages, &mce_bad_pages);
81123
81124 /*
81125 * We need/can do nothing about count=0 pages.
81126 @@ -1070,7 +1070,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81127 if (!PageHWPoison(hpage)
81128 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81129 || (p != hpage && TestSetPageHWPoison(hpage))) {
81130 - atomic_long_sub(nr_pages, &mce_bad_pages);
81131 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81132 return 0;
81133 }
81134 set_page_hwpoison_huge_page(hpage);
81135 @@ -1128,7 +1128,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81136 }
81137 if (hwpoison_filter(p)) {
81138 if (TestClearPageHWPoison(p))
81139 - atomic_long_sub(nr_pages, &mce_bad_pages);
81140 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81141 unlock_page(hpage);
81142 put_page(hpage);
81143 return 0;
81144 @@ -1323,7 +1323,7 @@ int unpoison_memory(unsigned long pfn)
81145 return 0;
81146 }
81147 if (TestClearPageHWPoison(p))
81148 - atomic_long_sub(nr_pages, &mce_bad_pages);
81149 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81150 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81151 return 0;
81152 }
81153 @@ -1337,7 +1337,7 @@ int unpoison_memory(unsigned long pfn)
81154 */
81155 if (TestClearPageHWPoison(page)) {
81156 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81157 - atomic_long_sub(nr_pages, &mce_bad_pages);
81158 + atomic_long_sub_unchecked(nr_pages, &mce_bad_pages);
81159 freeit = 1;
81160 if (PageHuge(page))
81161 clear_page_hwpoison_huge_page(page);
81162 @@ -1442,7 +1442,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81163 }
81164 done:
81165 if (!PageHWPoison(hpage))
81166 - atomic_long_add(1 << compound_trans_order(hpage),
81167 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81168 &mce_bad_pages);
81169 set_page_hwpoison_huge_page(hpage);
81170 dequeue_hwpoisoned_huge_page(hpage);
81171 @@ -1583,7 +1583,7 @@ int soft_offline_page(struct page *page, int flags)
81172 return ret;
81173
81174 done:
81175 - atomic_long_add(1, &mce_bad_pages);
81176 + atomic_long_add_unchecked(1, &mce_bad_pages);
81177 SetPageHWPoison(page);
81178 /* keep elevated page count for bad page */
81179 return ret;
81180 diff --git a/mm/memory.c b/mm/memory.c
81181 index bb1369f..38014f5 100644
81182 --- a/mm/memory.c
81183 +++ b/mm/memory.c
81184 @@ -212,6 +212,7 @@ void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm, bool fullmm)
81185 tlb->mm = mm;
81186
81187 tlb->fullmm = fullmm;
81188 + tlb->need_flush_all = 0;
81189 tlb->start = -1UL;
81190 tlb->end = 0;
81191 tlb->need_flush = 0;
81192 @@ -433,6 +434,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81193 free_pte_range(tlb, pmd, addr);
81194 } while (pmd++, addr = next, addr != end);
81195
81196 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81197 start &= PUD_MASK;
81198 if (start < floor)
81199 return;
81200 @@ -447,6 +449,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81201 pmd = pmd_offset(pud, start);
81202 pud_clear(pud);
81203 pmd_free_tlb(tlb, pmd, start);
81204 +#endif
81205 +
81206 }
81207
81208 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81209 @@ -466,6 +470,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81210 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81211 } while (pud++, addr = next, addr != end);
81212
81213 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81214 start &= PGDIR_MASK;
81215 if (start < floor)
81216 return;
81217 @@ -480,6 +485,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81218 pud = pud_offset(pgd, start);
81219 pgd_clear(pgd);
81220 pud_free_tlb(tlb, pud, start);
81221 +#endif
81222 +
81223 }
81224
81225 /*
81226 @@ -1618,12 +1625,6 @@ no_page_table:
81227 return page;
81228 }
81229
81230 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81231 -{
81232 - return stack_guard_page_start(vma, addr) ||
81233 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81234 -}
81235 -
81236 /**
81237 * __get_user_pages() - pin user pages in memory
81238 * @tsk: task_struct of target task
81239 @@ -1709,10 +1710,10 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81240
81241 i = 0;
81242
81243 - do {
81244 + while (nr_pages) {
81245 struct vm_area_struct *vma;
81246
81247 - vma = find_extend_vma(mm, start);
81248 + vma = find_vma(mm, start);
81249 if (!vma && in_gate_area(mm, start)) {
81250 unsigned long pg = start & PAGE_MASK;
81251 pgd_t *pgd;
81252 @@ -1760,7 +1761,7 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81253 goto next_page;
81254 }
81255
81256 - if (!vma ||
81257 + if (!vma || start < vma->vm_start ||
81258 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81259 !(vm_flags & vma->vm_flags))
81260 return i ? : -EFAULT;
81261 @@ -1787,11 +1788,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81262 int ret;
81263 unsigned int fault_flags = 0;
81264
81265 - /* For mlock, just skip the stack guard page. */
81266 - if (foll_flags & FOLL_MLOCK) {
81267 - if (stack_guard_page(vma, start))
81268 - goto next_page;
81269 - }
81270 if (foll_flags & FOLL_WRITE)
81271 fault_flags |= FAULT_FLAG_WRITE;
81272 if (nonblocking)
81273 @@ -1865,7 +1861,7 @@ next_page:
81274 start += PAGE_SIZE;
81275 nr_pages--;
81276 } while (nr_pages && start < vma->vm_end);
81277 - } while (nr_pages);
81278 + }
81279 return i;
81280 }
81281 EXPORT_SYMBOL(__get_user_pages);
81282 @@ -2072,6 +2068,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81283 page_add_file_rmap(page);
81284 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81285
81286 +#ifdef CONFIG_PAX_SEGMEXEC
81287 + pax_mirror_file_pte(vma, addr, page, ptl);
81288 +#endif
81289 +
81290 retval = 0;
81291 pte_unmap_unlock(pte, ptl);
81292 return retval;
81293 @@ -2116,9 +2116,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81294 if (!page_count(page))
81295 return -EINVAL;
81296 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81297 +
81298 +#ifdef CONFIG_PAX_SEGMEXEC
81299 + struct vm_area_struct *vma_m;
81300 +#endif
81301 +
81302 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81303 BUG_ON(vma->vm_flags & VM_PFNMAP);
81304 vma->vm_flags |= VM_MIXEDMAP;
81305 +
81306 +#ifdef CONFIG_PAX_SEGMEXEC
81307 + vma_m = pax_find_mirror_vma(vma);
81308 + if (vma_m)
81309 + vma_m->vm_flags |= VM_MIXEDMAP;
81310 +#endif
81311 +
81312 }
81313 return insert_page(vma, addr, page, vma->vm_page_prot);
81314 }
81315 @@ -2201,6 +2213,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81316 unsigned long pfn)
81317 {
81318 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81319 + BUG_ON(vma->vm_mirror);
81320
81321 if (addr < vma->vm_start || addr >= vma->vm_end)
81322 return -EFAULT;
81323 @@ -2401,7 +2414,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81324
81325 BUG_ON(pud_huge(*pud));
81326
81327 - pmd = pmd_alloc(mm, pud, addr);
81328 + pmd = (mm == &init_mm) ?
81329 + pmd_alloc_kernel(mm, pud, addr) :
81330 + pmd_alloc(mm, pud, addr);
81331 if (!pmd)
81332 return -ENOMEM;
81333 do {
81334 @@ -2421,7 +2436,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81335 unsigned long next;
81336 int err;
81337
81338 - pud = pud_alloc(mm, pgd, addr);
81339 + pud = (mm == &init_mm) ?
81340 + pud_alloc_kernel(mm, pgd, addr) :
81341 + pud_alloc(mm, pgd, addr);
81342 if (!pud)
81343 return -ENOMEM;
81344 do {
81345 @@ -2509,6 +2526,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81346 copy_user_highpage(dst, src, va, vma);
81347 }
81348
81349 +#ifdef CONFIG_PAX_SEGMEXEC
81350 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81351 +{
81352 + struct mm_struct *mm = vma->vm_mm;
81353 + spinlock_t *ptl;
81354 + pte_t *pte, entry;
81355 +
81356 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81357 + entry = *pte;
81358 + if (!pte_present(entry)) {
81359 + if (!pte_none(entry)) {
81360 + BUG_ON(pte_file(entry));
81361 + free_swap_and_cache(pte_to_swp_entry(entry));
81362 + pte_clear_not_present_full(mm, address, pte, 0);
81363 + }
81364 + } else {
81365 + struct page *page;
81366 +
81367 + flush_cache_page(vma, address, pte_pfn(entry));
81368 + entry = ptep_clear_flush(vma, address, pte);
81369 + BUG_ON(pte_dirty(entry));
81370 + page = vm_normal_page(vma, address, entry);
81371 + if (page) {
81372 + update_hiwater_rss(mm);
81373 + if (PageAnon(page))
81374 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81375 + else
81376 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81377 + page_remove_rmap(page);
81378 + page_cache_release(page);
81379 + }
81380 + }
81381 + pte_unmap_unlock(pte, ptl);
81382 +}
81383 +
81384 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81385 + *
81386 + * the ptl of the lower mapped page is held on entry and is not released on exit
81387 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81388 + */
81389 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81390 +{
81391 + struct mm_struct *mm = vma->vm_mm;
81392 + unsigned long address_m;
81393 + spinlock_t *ptl_m;
81394 + struct vm_area_struct *vma_m;
81395 + pmd_t *pmd_m;
81396 + pte_t *pte_m, entry_m;
81397 +
81398 + BUG_ON(!page_m || !PageAnon(page_m));
81399 +
81400 + vma_m = pax_find_mirror_vma(vma);
81401 + if (!vma_m)
81402 + return;
81403 +
81404 + BUG_ON(!PageLocked(page_m));
81405 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81406 + address_m = address + SEGMEXEC_TASK_SIZE;
81407 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81408 + pte_m = pte_offset_map(pmd_m, address_m);
81409 + ptl_m = pte_lockptr(mm, pmd_m);
81410 + if (ptl != ptl_m) {
81411 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81412 + if (!pte_none(*pte_m))
81413 + goto out;
81414 + }
81415 +
81416 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81417 + page_cache_get(page_m);
81418 + page_add_anon_rmap(page_m, vma_m, address_m);
81419 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81420 + set_pte_at(mm, address_m, pte_m, entry_m);
81421 + update_mmu_cache(vma_m, address_m, entry_m);
81422 +out:
81423 + if (ptl != ptl_m)
81424 + spin_unlock(ptl_m);
81425 + pte_unmap(pte_m);
81426 + unlock_page(page_m);
81427 +}
81428 +
81429 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81430 +{
81431 + struct mm_struct *mm = vma->vm_mm;
81432 + unsigned long address_m;
81433 + spinlock_t *ptl_m;
81434 + struct vm_area_struct *vma_m;
81435 + pmd_t *pmd_m;
81436 + pte_t *pte_m, entry_m;
81437 +
81438 + BUG_ON(!page_m || PageAnon(page_m));
81439 +
81440 + vma_m = pax_find_mirror_vma(vma);
81441 + if (!vma_m)
81442 + return;
81443 +
81444 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81445 + address_m = address + SEGMEXEC_TASK_SIZE;
81446 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81447 + pte_m = pte_offset_map(pmd_m, address_m);
81448 + ptl_m = pte_lockptr(mm, pmd_m);
81449 + if (ptl != ptl_m) {
81450 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81451 + if (!pte_none(*pte_m))
81452 + goto out;
81453 + }
81454 +
81455 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81456 + page_cache_get(page_m);
81457 + page_add_file_rmap(page_m);
81458 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81459 + set_pte_at(mm, address_m, pte_m, entry_m);
81460 + update_mmu_cache(vma_m, address_m, entry_m);
81461 +out:
81462 + if (ptl != ptl_m)
81463 + spin_unlock(ptl_m);
81464 + pte_unmap(pte_m);
81465 +}
81466 +
81467 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81468 +{
81469 + struct mm_struct *mm = vma->vm_mm;
81470 + unsigned long address_m;
81471 + spinlock_t *ptl_m;
81472 + struct vm_area_struct *vma_m;
81473 + pmd_t *pmd_m;
81474 + pte_t *pte_m, entry_m;
81475 +
81476 + vma_m = pax_find_mirror_vma(vma);
81477 + if (!vma_m)
81478 + return;
81479 +
81480 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81481 + address_m = address + SEGMEXEC_TASK_SIZE;
81482 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81483 + pte_m = pte_offset_map(pmd_m, address_m);
81484 + ptl_m = pte_lockptr(mm, pmd_m);
81485 + if (ptl != ptl_m) {
81486 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81487 + if (!pte_none(*pte_m))
81488 + goto out;
81489 + }
81490 +
81491 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81492 + set_pte_at(mm, address_m, pte_m, entry_m);
81493 +out:
81494 + if (ptl != ptl_m)
81495 + spin_unlock(ptl_m);
81496 + pte_unmap(pte_m);
81497 +}
81498 +
81499 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81500 +{
81501 + struct page *page_m;
81502 + pte_t entry;
81503 +
81504 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81505 + goto out;
81506 +
81507 + entry = *pte;
81508 + page_m = vm_normal_page(vma, address, entry);
81509 + if (!page_m)
81510 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81511 + else if (PageAnon(page_m)) {
81512 + if (pax_find_mirror_vma(vma)) {
81513 + pte_unmap_unlock(pte, ptl);
81514 + lock_page(page_m);
81515 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81516 + if (pte_same(entry, *pte))
81517 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81518 + else
81519 + unlock_page(page_m);
81520 + }
81521 + } else
81522 + pax_mirror_file_pte(vma, address, page_m, ptl);
81523 +
81524 +out:
81525 + pte_unmap_unlock(pte, ptl);
81526 +}
81527 +#endif
81528 +
81529 /*
81530 * This routine handles present pages, when users try to write
81531 * to a shared page. It is done by copying the page to a new address
81532 @@ -2725,6 +2922,12 @@ gotten:
81533 */
81534 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81535 if (likely(pte_same(*page_table, orig_pte))) {
81536 +
81537 +#ifdef CONFIG_PAX_SEGMEXEC
81538 + if (pax_find_mirror_vma(vma))
81539 + BUG_ON(!trylock_page(new_page));
81540 +#endif
81541 +
81542 if (old_page) {
81543 if (!PageAnon(old_page)) {
81544 dec_mm_counter_fast(mm, MM_FILEPAGES);
81545 @@ -2776,6 +2979,10 @@ gotten:
81546 page_remove_rmap(old_page);
81547 }
81548
81549 +#ifdef CONFIG_PAX_SEGMEXEC
81550 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81551 +#endif
81552 +
81553 /* Free the old page.. */
81554 new_page = old_page;
81555 ret |= VM_FAULT_WRITE;
81556 @@ -3051,6 +3258,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81557 swap_free(entry);
81558 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81559 try_to_free_swap(page);
81560 +
81561 +#ifdef CONFIG_PAX_SEGMEXEC
81562 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81563 +#endif
81564 +
81565 unlock_page(page);
81566 if (swapcache) {
81567 /*
81568 @@ -3074,6 +3286,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81569
81570 /* No need to invalidate - it was non-present before */
81571 update_mmu_cache(vma, address, page_table);
81572 +
81573 +#ifdef CONFIG_PAX_SEGMEXEC
81574 + pax_mirror_anon_pte(vma, address, page, ptl);
81575 +#endif
81576 +
81577 unlock:
81578 pte_unmap_unlock(page_table, ptl);
81579 out:
81580 @@ -3093,40 +3310,6 @@ out_release:
81581 }
81582
81583 /*
81584 - * This is like a special single-page "expand_{down|up}wards()",
81585 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81586 - * doesn't hit another vma.
81587 - */
81588 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81589 -{
81590 - address &= PAGE_MASK;
81591 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81592 - struct vm_area_struct *prev = vma->vm_prev;
81593 -
81594 - /*
81595 - * Is there a mapping abutting this one below?
81596 - *
81597 - * That's only ok if it's the same stack mapping
81598 - * that has gotten split..
81599 - */
81600 - if (prev && prev->vm_end == address)
81601 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81602 -
81603 - expand_downwards(vma, address - PAGE_SIZE);
81604 - }
81605 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81606 - struct vm_area_struct *next = vma->vm_next;
81607 -
81608 - /* As VM_GROWSDOWN but s/below/above/ */
81609 - if (next && next->vm_start == address + PAGE_SIZE)
81610 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81611 -
81612 - expand_upwards(vma, address + PAGE_SIZE);
81613 - }
81614 - return 0;
81615 -}
81616 -
81617 -/*
81618 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81619 * but allow concurrent faults), and pte mapped but not yet locked.
81620 * We return with mmap_sem still held, but pte unmapped and unlocked.
81621 @@ -3135,27 +3318,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81622 unsigned long address, pte_t *page_table, pmd_t *pmd,
81623 unsigned int flags)
81624 {
81625 - struct page *page;
81626 + struct page *page = NULL;
81627 spinlock_t *ptl;
81628 pte_t entry;
81629
81630 - pte_unmap(page_table);
81631 -
81632 - /* Check if we need to add a guard page to the stack */
81633 - if (check_stack_guard_page(vma, address) < 0)
81634 - return VM_FAULT_SIGBUS;
81635 -
81636 - /* Use the zero-page for reads */
81637 if (!(flags & FAULT_FLAG_WRITE)) {
81638 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81639 vma->vm_page_prot));
81640 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81641 + ptl = pte_lockptr(mm, pmd);
81642 + spin_lock(ptl);
81643 if (!pte_none(*page_table))
81644 goto unlock;
81645 goto setpte;
81646 }
81647
81648 /* Allocate our own private page. */
81649 + pte_unmap(page_table);
81650 +
81651 if (unlikely(anon_vma_prepare(vma)))
81652 goto oom;
81653 page = alloc_zeroed_user_highpage_movable(vma, address);
81654 @@ -3174,6 +3353,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81655 if (!pte_none(*page_table))
81656 goto release;
81657
81658 +#ifdef CONFIG_PAX_SEGMEXEC
81659 + if (pax_find_mirror_vma(vma))
81660 + BUG_ON(!trylock_page(page));
81661 +#endif
81662 +
81663 inc_mm_counter_fast(mm, MM_ANONPAGES);
81664 page_add_new_anon_rmap(page, vma, address);
81665 setpte:
81666 @@ -3181,6 +3365,12 @@ setpte:
81667
81668 /* No need to invalidate - it was non-present before */
81669 update_mmu_cache(vma, address, page_table);
81670 +
81671 +#ifdef CONFIG_PAX_SEGMEXEC
81672 + if (page)
81673 + pax_mirror_anon_pte(vma, address, page, ptl);
81674 +#endif
81675 +
81676 unlock:
81677 pte_unmap_unlock(page_table, ptl);
81678 return 0;
81679 @@ -3324,6 +3514,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81680 */
81681 /* Only go through if we didn't race with anybody else... */
81682 if (likely(pte_same(*page_table, orig_pte))) {
81683 +
81684 +#ifdef CONFIG_PAX_SEGMEXEC
81685 + if (anon && pax_find_mirror_vma(vma))
81686 + BUG_ON(!trylock_page(page));
81687 +#endif
81688 +
81689 flush_icache_page(vma, page);
81690 entry = mk_pte(page, vma->vm_page_prot);
81691 if (flags & FAULT_FLAG_WRITE)
81692 @@ -3343,6 +3539,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81693
81694 /* no need to invalidate: a not-present page won't be cached */
81695 update_mmu_cache(vma, address, page_table);
81696 +
81697 +#ifdef CONFIG_PAX_SEGMEXEC
81698 + if (anon)
81699 + pax_mirror_anon_pte(vma, address, page, ptl);
81700 + else
81701 + pax_mirror_file_pte(vma, address, page, ptl);
81702 +#endif
81703 +
81704 } else {
81705 if (cow_page)
81706 mem_cgroup_uncharge_page(cow_page);
81707 @@ -3664,6 +3868,12 @@ int handle_pte_fault(struct mm_struct *mm,
81708 if (flags & FAULT_FLAG_WRITE)
81709 flush_tlb_fix_spurious_fault(vma, address);
81710 }
81711 +
81712 +#ifdef CONFIG_PAX_SEGMEXEC
81713 + pax_mirror_pte(vma, address, pte, pmd, ptl);
81714 + return 0;
81715 +#endif
81716 +
81717 unlock:
81718 pte_unmap_unlock(pte, ptl);
81719 return 0;
81720 @@ -3680,6 +3890,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81721 pmd_t *pmd;
81722 pte_t *pte;
81723
81724 +#ifdef CONFIG_PAX_SEGMEXEC
81725 + struct vm_area_struct *vma_m;
81726 +#endif
81727 +
81728 __set_current_state(TASK_RUNNING);
81729
81730 count_vm_event(PGFAULT);
81731 @@ -3691,6 +3905,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81732 if (unlikely(is_vm_hugetlb_page(vma)))
81733 return hugetlb_fault(mm, vma, address, flags);
81734
81735 +#ifdef CONFIG_PAX_SEGMEXEC
81736 + vma_m = pax_find_mirror_vma(vma);
81737 + if (vma_m) {
81738 + unsigned long address_m;
81739 + pgd_t *pgd_m;
81740 + pud_t *pud_m;
81741 + pmd_t *pmd_m;
81742 +
81743 + if (vma->vm_start > vma_m->vm_start) {
81744 + address_m = address;
81745 + address -= SEGMEXEC_TASK_SIZE;
81746 + vma = vma_m;
81747 + } else
81748 + address_m = address + SEGMEXEC_TASK_SIZE;
81749 +
81750 + pgd_m = pgd_offset(mm, address_m);
81751 + pud_m = pud_alloc(mm, pgd_m, address_m);
81752 + if (!pud_m)
81753 + return VM_FAULT_OOM;
81754 + pmd_m = pmd_alloc(mm, pud_m, address_m);
81755 + if (!pmd_m)
81756 + return VM_FAULT_OOM;
81757 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
81758 + return VM_FAULT_OOM;
81759 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
81760 + }
81761 +#endif
81762 +
81763 retry:
81764 pgd = pgd_offset(mm, address);
81765 pud = pud_alloc(mm, pgd, address);
81766 @@ -3789,6 +4031,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81767 spin_unlock(&mm->page_table_lock);
81768 return 0;
81769 }
81770 +
81771 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
81772 +{
81773 + pud_t *new = pud_alloc_one(mm, address);
81774 + if (!new)
81775 + return -ENOMEM;
81776 +
81777 + smp_wmb(); /* See comment in __pte_alloc */
81778 +
81779 + spin_lock(&mm->page_table_lock);
81780 + if (pgd_present(*pgd)) /* Another has populated it */
81781 + pud_free(mm, new);
81782 + else
81783 + pgd_populate_kernel(mm, pgd, new);
81784 + spin_unlock(&mm->page_table_lock);
81785 + return 0;
81786 +}
81787 #endif /* __PAGETABLE_PUD_FOLDED */
81788
81789 #ifndef __PAGETABLE_PMD_FOLDED
81790 @@ -3819,11 +4078,35 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
81791 spin_unlock(&mm->page_table_lock);
81792 return 0;
81793 }
81794 +
81795 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
81796 +{
81797 + pmd_t *new = pmd_alloc_one(mm, address);
81798 + if (!new)
81799 + return -ENOMEM;
81800 +
81801 + smp_wmb(); /* See comment in __pte_alloc */
81802 +
81803 + spin_lock(&mm->page_table_lock);
81804 +#ifndef __ARCH_HAS_4LEVEL_HACK
81805 + if (pud_present(*pud)) /* Another has populated it */
81806 + pmd_free(mm, new);
81807 + else
81808 + pud_populate_kernel(mm, pud, new);
81809 +#else
81810 + if (pgd_present(*pud)) /* Another has populated it */
81811 + pmd_free(mm, new);
81812 + else
81813 + pgd_populate_kernel(mm, pud, new);
81814 +#endif /* __ARCH_HAS_4LEVEL_HACK */
81815 + spin_unlock(&mm->page_table_lock);
81816 + return 0;
81817 +}
81818 #endif /* __PAGETABLE_PMD_FOLDED */
81819
81820 -int make_pages_present(unsigned long addr, unsigned long end)
81821 +ssize_t make_pages_present(unsigned long addr, unsigned long end)
81822 {
81823 - int ret, len, write;
81824 + ssize_t ret, len, write;
81825 struct vm_area_struct * vma;
81826
81827 vma = find_vma(current->mm, addr);
81828 @@ -3856,7 +4139,7 @@ static int __init gate_vma_init(void)
81829 gate_vma.vm_start = FIXADDR_USER_START;
81830 gate_vma.vm_end = FIXADDR_USER_END;
81831 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
81832 - gate_vma.vm_page_prot = __P101;
81833 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
81834
81835 return 0;
81836 }
81837 @@ -3990,8 +4273,8 @@ out:
81838 return ret;
81839 }
81840
81841 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81842 - void *buf, int len, int write)
81843 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81844 + void *buf, size_t len, int write)
81845 {
81846 resource_size_t phys_addr;
81847 unsigned long prot = 0;
81848 @@ -4016,8 +4299,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
81849 * Access another process' address space as given in mm. If non-NULL, use the
81850 * given task for page fault accounting.
81851 */
81852 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81853 - unsigned long addr, void *buf, int len, int write)
81854 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81855 + unsigned long addr, void *buf, size_t len, int write)
81856 {
81857 struct vm_area_struct *vma;
81858 void *old_buf = buf;
81859 @@ -4025,7 +4308,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81860 down_read(&mm->mmap_sem);
81861 /* ignore errors, just check how much was successfully transferred */
81862 while (len) {
81863 - int bytes, ret, offset;
81864 + ssize_t bytes, ret, offset;
81865 void *maddr;
81866 struct page *page = NULL;
81867
81868 @@ -4084,8 +4367,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
81869 *
81870 * The caller must hold a reference on @mm.
81871 */
81872 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81873 - void *buf, int len, int write)
81874 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
81875 + void *buf, size_t len, int write)
81876 {
81877 return __access_remote_vm(NULL, mm, addr, buf, len, write);
81878 }
81879 @@ -4095,11 +4378,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
81880 * Source/target buffer must be kernel space,
81881 * Do not walk the page table directly, use get_user_pages
81882 */
81883 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
81884 - void *buf, int len, int write)
81885 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
81886 + void *buf, size_t len, int write)
81887 {
81888 struct mm_struct *mm;
81889 - int ret;
81890 + ssize_t ret;
81891
81892 mm = get_task_mm(tsk);
81893 if (!mm)
81894 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
81895 index 3df6d12..a11056a 100644
81896 --- a/mm/mempolicy.c
81897 +++ b/mm/mempolicy.c
81898 @@ -721,6 +721,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81899 unsigned long vmstart;
81900 unsigned long vmend;
81901
81902 +#ifdef CONFIG_PAX_SEGMEXEC
81903 + struct vm_area_struct *vma_m;
81904 +#endif
81905 +
81906 vma = find_vma(mm, start);
81907 if (!vma || vma->vm_start > start)
81908 return -EFAULT;
81909 @@ -757,9 +761,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
81910 if (err)
81911 goto out;
81912 }
81913 +
81914 err = vma_replace_policy(vma, new_pol);
81915 if (err)
81916 goto out;
81917 +
81918 +#ifdef CONFIG_PAX_SEGMEXEC
81919 + vma_m = pax_find_mirror_vma(vma);
81920 + if (vma_m) {
81921 + err = vma_replace_policy(vma_m, new_pol);
81922 + if (err)
81923 + goto out;
81924 + }
81925 +#endif
81926 +
81927 }
81928
81929 out:
81930 @@ -1216,6 +1231,17 @@ static long do_mbind(unsigned long start, unsigned long len,
81931
81932 if (end < start)
81933 return -EINVAL;
81934 +
81935 +#ifdef CONFIG_PAX_SEGMEXEC
81936 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
81937 + if (end > SEGMEXEC_TASK_SIZE)
81938 + return -EINVAL;
81939 + } else
81940 +#endif
81941 +
81942 + if (end > TASK_SIZE)
81943 + return -EINVAL;
81944 +
81945 if (end == start)
81946 return 0;
81947
81948 @@ -1445,8 +1471,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81949 */
81950 tcred = __task_cred(task);
81951 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81952 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81953 - !capable(CAP_SYS_NICE)) {
81954 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81955 rcu_read_unlock();
81956 err = -EPERM;
81957 goto out_put;
81958 @@ -1477,6 +1502,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
81959 goto out;
81960 }
81961
81962 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
81963 + if (mm != current->mm &&
81964 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
81965 + mmput(mm);
81966 + err = -EPERM;
81967 + goto out;
81968 + }
81969 +#endif
81970 +
81971 err = do_migrate_pages(mm, old, new,
81972 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
81973
81974 diff --git a/mm/migrate.c b/mm/migrate.c
81975 index 2fd8b4a..d70358f 100644
81976 --- a/mm/migrate.c
81977 +++ b/mm/migrate.c
81978 @@ -1401,8 +1401,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
81979 */
81980 tcred = __task_cred(task);
81981 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
81982 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
81983 - !capable(CAP_SYS_NICE)) {
81984 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
81985 rcu_read_unlock();
81986 err = -EPERM;
81987 goto out;
81988 diff --git a/mm/mlock.c b/mm/mlock.c
81989 index c9bd528..da8d069 100644
81990 --- a/mm/mlock.c
81991 +++ b/mm/mlock.c
81992 @@ -13,6 +13,7 @@
81993 #include <linux/pagemap.h>
81994 #include <linux/mempolicy.h>
81995 #include <linux/syscalls.h>
81996 +#include <linux/security.h>
81997 #include <linux/sched.h>
81998 #include <linux/export.h>
81999 #include <linux/rmap.h>
82000 @@ -369,7 +370,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82001 {
82002 unsigned long nstart, end, tmp;
82003 struct vm_area_struct * vma, * prev;
82004 - int error;
82005 + int error = 0;
82006
82007 VM_BUG_ON(start & ~PAGE_MASK);
82008 VM_BUG_ON(len != PAGE_ALIGN(len));
82009 @@ -378,6 +379,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82010 return -EINVAL;
82011 if (end == start)
82012 return 0;
82013 + if (end > TASK_SIZE)
82014 + return -EINVAL;
82015 +
82016 vma = find_vma(current->mm, start);
82017 if (!vma || vma->vm_start > start)
82018 return -ENOMEM;
82019 @@ -389,6 +393,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82020 for (nstart = start ; ; ) {
82021 vm_flags_t newflags;
82022
82023 +#ifdef CONFIG_PAX_SEGMEXEC
82024 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82025 + break;
82026 +#endif
82027 +
82028 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82029
82030 newflags = vma->vm_flags | VM_LOCKED;
82031 @@ -494,6 +503,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82032 lock_limit >>= PAGE_SHIFT;
82033
82034 /* check against resource limits */
82035 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82036 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82037 error = do_mlock(start, len, 1);
82038 up_write(&current->mm->mmap_sem);
82039 @@ -528,6 +538,12 @@ static int do_mlockall(int flags)
82040 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82041 vm_flags_t newflags;
82042
82043 +#ifdef CONFIG_PAX_SEGMEXEC
82044 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82045 + break;
82046 +#endif
82047 +
82048 + BUG_ON(vma->vm_end > TASK_SIZE);
82049 newflags = vma->vm_flags | VM_LOCKED;
82050 if (!(flags & MCL_CURRENT))
82051 newflags &= ~VM_LOCKED;
82052 @@ -560,6 +576,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82053 lock_limit >>= PAGE_SHIFT;
82054
82055 ret = -ENOMEM;
82056 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82057 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82058 capable(CAP_IPC_LOCK))
82059 ret = do_mlockall(flags);
82060 diff --git a/mm/mmap.c b/mm/mmap.c
82061 index 90db251..04240d1 100644
82062 --- a/mm/mmap.c
82063 +++ b/mm/mmap.c
82064 @@ -32,6 +32,7 @@
82065 #include <linux/khugepaged.h>
82066 #include <linux/uprobes.h>
82067 #include <linux/rbtree_augmented.h>
82068 +#include <linux/random.h>
82069
82070 #include <asm/uaccess.h>
82071 #include <asm/cacheflush.h>
82072 @@ -48,6 +49,16 @@
82073 #define arch_rebalance_pgtables(addr, len) (addr)
82074 #endif
82075
82076 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82077 +{
82078 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82079 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82080 + up_read(&mm->mmap_sem);
82081 + BUG();
82082 + }
82083 +#endif
82084 +}
82085 +
82086 static void unmap_region(struct mm_struct *mm,
82087 struct vm_area_struct *vma, struct vm_area_struct *prev,
82088 unsigned long start, unsigned long end);
82089 @@ -67,22 +78,32 @@ static void unmap_region(struct mm_struct *mm,
82090 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82091 *
82092 */
82093 -pgprot_t protection_map[16] = {
82094 +pgprot_t protection_map[16] __read_only = {
82095 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82096 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82097 };
82098
82099 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82100 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82101 {
82102 - return __pgprot(pgprot_val(protection_map[vm_flags &
82103 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82104 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82105 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82106 +
82107 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82108 + if (!(__supported_pte_mask & _PAGE_NX) &&
82109 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82110 + (vm_flags & (VM_READ | VM_WRITE)))
82111 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82112 +#endif
82113 +
82114 + return prot;
82115 }
82116 EXPORT_SYMBOL(vm_get_page_prot);
82117
82118 int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
82119 int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82120 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82121 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82122 /*
82123 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82124 * other variables. It can be updated by several CPUs frequently.
82125 @@ -238,6 +259,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82126 struct vm_area_struct *next = vma->vm_next;
82127
82128 might_sleep();
82129 + BUG_ON(vma->vm_mirror);
82130 if (vma->vm_ops && vma->vm_ops->close)
82131 vma->vm_ops->close(vma);
82132 if (vma->vm_file)
82133 @@ -281,6 +303,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82134 * not page aligned -Ram Gupta
82135 */
82136 rlim = rlimit(RLIMIT_DATA);
82137 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82138 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82139 (mm->end_data - mm->start_data) > rlim)
82140 goto out;
82141 @@ -888,6 +911,12 @@ static int
82142 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82143 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82144 {
82145 +
82146 +#ifdef CONFIG_PAX_SEGMEXEC
82147 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82148 + return 0;
82149 +#endif
82150 +
82151 if (is_mergeable_vma(vma, file, vm_flags) &&
82152 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82153 if (vma->vm_pgoff == vm_pgoff)
82154 @@ -907,6 +936,12 @@ static int
82155 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82156 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82157 {
82158 +
82159 +#ifdef CONFIG_PAX_SEGMEXEC
82160 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82161 + return 0;
82162 +#endif
82163 +
82164 if (is_mergeable_vma(vma, file, vm_flags) &&
82165 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82166 pgoff_t vm_pglen;
82167 @@ -949,13 +984,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82168 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82169 struct vm_area_struct *prev, unsigned long addr,
82170 unsigned long end, unsigned long vm_flags,
82171 - struct anon_vma *anon_vma, struct file *file,
82172 + struct anon_vma *anon_vma, struct file *file,
82173 pgoff_t pgoff, struct mempolicy *policy)
82174 {
82175 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82176 struct vm_area_struct *area, *next;
82177 int err;
82178
82179 +#ifdef CONFIG_PAX_SEGMEXEC
82180 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82181 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82182 +
82183 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82184 +#endif
82185 +
82186 /*
82187 * We later require that vma->vm_flags == vm_flags,
82188 * so this tests vma->vm_flags & VM_SPECIAL, too.
82189 @@ -971,6 +1013,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82190 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82191 next = next->vm_next;
82192
82193 +#ifdef CONFIG_PAX_SEGMEXEC
82194 + if (prev)
82195 + prev_m = pax_find_mirror_vma(prev);
82196 + if (area)
82197 + area_m = pax_find_mirror_vma(area);
82198 + if (next)
82199 + next_m = pax_find_mirror_vma(next);
82200 +#endif
82201 +
82202 /*
82203 * Can it merge with the predecessor?
82204 */
82205 @@ -990,9 +1041,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82206 /* cases 1, 6 */
82207 err = vma_adjust(prev, prev->vm_start,
82208 next->vm_end, prev->vm_pgoff, NULL);
82209 - } else /* cases 2, 5, 7 */
82210 +
82211 +#ifdef CONFIG_PAX_SEGMEXEC
82212 + if (!err && prev_m)
82213 + err = vma_adjust(prev_m, prev_m->vm_start,
82214 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82215 +#endif
82216 +
82217 + } else { /* cases 2, 5, 7 */
82218 err = vma_adjust(prev, prev->vm_start,
82219 end, prev->vm_pgoff, NULL);
82220 +
82221 +#ifdef CONFIG_PAX_SEGMEXEC
82222 + if (!err && prev_m)
82223 + err = vma_adjust(prev_m, prev_m->vm_start,
82224 + end_m, prev_m->vm_pgoff, NULL);
82225 +#endif
82226 +
82227 + }
82228 if (err)
82229 return NULL;
82230 khugepaged_enter_vma_merge(prev);
82231 @@ -1006,12 +1072,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82232 mpol_equal(policy, vma_policy(next)) &&
82233 can_vma_merge_before(next, vm_flags,
82234 anon_vma, file, pgoff+pglen)) {
82235 - if (prev && addr < prev->vm_end) /* case 4 */
82236 + if (prev && addr < prev->vm_end) { /* case 4 */
82237 err = vma_adjust(prev, prev->vm_start,
82238 addr, prev->vm_pgoff, NULL);
82239 - else /* cases 3, 8 */
82240 +
82241 +#ifdef CONFIG_PAX_SEGMEXEC
82242 + if (!err && prev_m)
82243 + err = vma_adjust(prev_m, prev_m->vm_start,
82244 + addr_m, prev_m->vm_pgoff, NULL);
82245 +#endif
82246 +
82247 + } else { /* cases 3, 8 */
82248 err = vma_adjust(area, addr, next->vm_end,
82249 next->vm_pgoff - pglen, NULL);
82250 +
82251 +#ifdef CONFIG_PAX_SEGMEXEC
82252 + if (!err && area_m)
82253 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82254 + next_m->vm_pgoff - pglen, NULL);
82255 +#endif
82256 +
82257 + }
82258 if (err)
82259 return NULL;
82260 khugepaged_enter_vma_merge(area);
82261 @@ -1120,8 +1201,10 @@ none:
82262 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82263 struct file *file, long pages)
82264 {
82265 - const unsigned long stack_flags
82266 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82267 +
82268 +#ifdef CONFIG_PAX_RANDMMAP
82269 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82270 +#endif
82271
82272 mm->total_vm += pages;
82273
82274 @@ -1129,7 +1212,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82275 mm->shared_vm += pages;
82276 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82277 mm->exec_vm += pages;
82278 - } else if (flags & stack_flags)
82279 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82280 mm->stack_vm += pages;
82281 }
82282 #endif /* CONFIG_PROC_FS */
82283 @@ -1165,7 +1248,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82284 * (the exception is when the underlying filesystem is noexec
82285 * mounted, in which case we dont add PROT_EXEC.)
82286 */
82287 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82288 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82289 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82290 prot |= PROT_EXEC;
82291
82292 @@ -1191,7 +1274,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82293 /* Obtain the address to map to. we verify (or select) it and ensure
82294 * that it represents a valid section of the address space.
82295 */
82296 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82297 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82298 if (addr & ~PAGE_MASK)
82299 return addr;
82300
82301 @@ -1202,6 +1285,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82302 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82303 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82304
82305 +#ifdef CONFIG_PAX_MPROTECT
82306 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82307 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82308 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82309 + gr_log_rwxmmap(file);
82310 +
82311 +#ifdef CONFIG_PAX_EMUPLT
82312 + vm_flags &= ~VM_EXEC;
82313 +#else
82314 + return -EPERM;
82315 +#endif
82316 +
82317 + }
82318 +
82319 + if (!(vm_flags & VM_EXEC))
82320 + vm_flags &= ~VM_MAYEXEC;
82321 +#else
82322 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82323 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82324 +#endif
82325 + else
82326 + vm_flags &= ~VM_MAYWRITE;
82327 + }
82328 +#endif
82329 +
82330 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82331 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82332 + vm_flags &= ~VM_PAGEEXEC;
82333 +#endif
82334 +
82335 if (flags & MAP_LOCKED)
82336 if (!can_do_mlock())
82337 return -EPERM;
82338 @@ -1213,6 +1326,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82339 locked += mm->locked_vm;
82340 lock_limit = rlimit(RLIMIT_MEMLOCK);
82341 lock_limit >>= PAGE_SHIFT;
82342 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82343 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82344 return -EAGAIN;
82345 }
82346 @@ -1279,6 +1393,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82347 }
82348 }
82349
82350 + if (!gr_acl_handle_mmap(file, prot))
82351 + return -EACCES;
82352 +
82353 return mmap_region(file, addr, len, flags, vm_flags, pgoff);
82354 }
82355
82356 @@ -1356,7 +1473,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82357 vm_flags_t vm_flags = vma->vm_flags;
82358
82359 /* If it was private or non-writable, the write bit is already clear */
82360 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82361 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82362 return 0;
82363
82364 /* The backer wishes to know when pages are first written to? */
82365 @@ -1405,16 +1522,30 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82366 unsigned long charged = 0;
82367 struct inode *inode = file ? file->f_path.dentry->d_inode : NULL;
82368
82369 +#ifdef CONFIG_PAX_SEGMEXEC
82370 + struct vm_area_struct *vma_m = NULL;
82371 +#endif
82372 +
82373 + /*
82374 + * mm->mmap_sem is required to protect against another thread
82375 + * changing the mappings in case we sleep.
82376 + */
82377 + verify_mm_writelocked(mm);
82378 +
82379 /* Clear old maps */
82380 error = -ENOMEM;
82381 -munmap_back:
82382 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82383 if (do_munmap(mm, addr, len))
82384 return -ENOMEM;
82385 - goto munmap_back;
82386 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82387 }
82388
82389 /* Check against address space limit. */
82390 +
82391 +#ifdef CONFIG_PAX_RANDMMAP
82392 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82393 +#endif
82394 +
82395 if (!may_expand_vm(mm, len >> PAGE_SHIFT))
82396 return -ENOMEM;
82397
82398 @@ -1460,6 +1591,16 @@ munmap_back:
82399 goto unacct_error;
82400 }
82401
82402 +#ifdef CONFIG_PAX_SEGMEXEC
82403 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82404 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82405 + if (!vma_m) {
82406 + error = -ENOMEM;
82407 + goto free_vma;
82408 + }
82409 + }
82410 +#endif
82411 +
82412 vma->vm_mm = mm;
82413 vma->vm_start = addr;
82414 vma->vm_end = addr + len;
82415 @@ -1484,6 +1625,13 @@ munmap_back:
82416 if (error)
82417 goto unmap_and_free_vma;
82418
82419 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82420 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82421 + vma->vm_flags |= VM_PAGEEXEC;
82422 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82423 + }
82424 +#endif
82425 +
82426 /* Can addr have changed??
82427 *
82428 * Answer: Yes, several device drivers can do it in their
82429 @@ -1522,6 +1670,11 @@ munmap_back:
82430 vma_link(mm, vma, prev, rb_link, rb_parent);
82431 file = vma->vm_file;
82432
82433 +#ifdef CONFIG_PAX_SEGMEXEC
82434 + if (vma_m)
82435 + BUG_ON(pax_mirror_vma(vma_m, vma));
82436 +#endif
82437 +
82438 /* Once vma denies write, undo our temporary denial count */
82439 if (correct_wcount)
82440 atomic_inc(&inode->i_writecount);
82441 @@ -1529,6 +1682,7 @@ out:
82442 perf_event_mmap(vma);
82443
82444 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82445 + track_exec_limit(mm, addr, addr + len, vm_flags);
82446 if (vm_flags & VM_LOCKED) {
82447 if (!mlock_vma_pages_range(vma, addr, addr + len))
82448 mm->locked_vm += (len >> PAGE_SHIFT);
82449 @@ -1550,6 +1704,12 @@ unmap_and_free_vma:
82450 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82451 charged = 0;
82452 free_vma:
82453 +
82454 +#ifdef CONFIG_PAX_SEGMEXEC
82455 + if (vma_m)
82456 + kmem_cache_free(vm_area_cachep, vma_m);
82457 +#endif
82458 +
82459 kmem_cache_free(vm_area_cachep, vma);
82460 unacct_error:
82461 if (charged)
82462 @@ -1557,6 +1717,62 @@ unacct_error:
82463 return error;
82464 }
82465
82466 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82467 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82468 +{
82469 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82470 + return (random32() & 0xFF) << PAGE_SHIFT;
82471 +
82472 + return 0;
82473 +}
82474 +#endif
82475 +
82476 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82477 +{
82478 + if (!vma) {
82479 +#ifdef CONFIG_STACK_GROWSUP
82480 + if (addr > sysctl_heap_stack_gap)
82481 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82482 + else
82483 + vma = find_vma(current->mm, 0);
82484 + if (vma && (vma->vm_flags & VM_GROWSUP))
82485 + return false;
82486 +#endif
82487 + return true;
82488 + }
82489 +
82490 + if (addr + len > vma->vm_start)
82491 + return false;
82492 +
82493 + if (vma->vm_flags & VM_GROWSDOWN)
82494 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82495 +#ifdef CONFIG_STACK_GROWSUP
82496 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82497 + return addr - vma->vm_prev->vm_end <= sysctl_heap_stack_gap;
82498 +#endif
82499 + else if (offset)
82500 + return offset <= vma->vm_start - addr - len;
82501 +
82502 + return true;
82503 +}
82504 +
82505 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82506 +{
82507 + if (vma->vm_start < len)
82508 + return -ENOMEM;
82509 +
82510 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82511 + if (offset <= vma->vm_start - len)
82512 + return vma->vm_start - len - offset;
82513 + else
82514 + return -ENOMEM;
82515 + }
82516 +
82517 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82518 + return vma->vm_start - len - sysctl_heap_stack_gap;
82519 + return -ENOMEM;
82520 +}
82521 +
82522 unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82523 {
82524 /*
82525 @@ -1776,6 +1992,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82526 struct mm_struct *mm = current->mm;
82527 struct vm_area_struct *vma;
82528 struct vm_unmapped_area_info info;
82529 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82530
82531 if (len > TASK_SIZE)
82532 return -ENOMEM;
82533 @@ -1783,17 +2000,26 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82534 if (flags & MAP_FIXED)
82535 return addr;
82536
82537 +#ifdef CONFIG_PAX_RANDMMAP
82538 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82539 +#endif
82540 +
82541 if (addr) {
82542 addr = PAGE_ALIGN(addr);
82543 vma = find_vma(mm, addr);
82544 - if (TASK_SIZE - len >= addr &&
82545 - (!vma || addr + len <= vma->vm_start))
82546 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82547 return addr;
82548 }
82549
82550 info.flags = 0;
82551 info.length = len;
82552 info.low_limit = TASK_UNMAPPED_BASE;
82553 +
82554 +#ifdef CONFIG_PAX_RANDMMAP
82555 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82556 + info.low_limit += mm->delta_mmap;
82557 +#endif
82558 +
82559 info.high_limit = TASK_SIZE;
82560 info.align_mask = 0;
82561 return vm_unmapped_area(&info);
82562 @@ -1802,10 +2028,16 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82563
82564 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82565 {
82566 +
82567 +#ifdef CONFIG_PAX_SEGMEXEC
82568 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82569 + return;
82570 +#endif
82571 +
82572 /*
82573 * Is this a new hole at the lowest possible address?
82574 */
82575 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82576 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82577 mm->free_area_cache = addr;
82578 }
82579
82580 @@ -1823,6 +2055,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82581 struct mm_struct *mm = current->mm;
82582 unsigned long addr = addr0;
82583 struct vm_unmapped_area_info info;
82584 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82585
82586 /* requested length too big for entire address space */
82587 if (len > TASK_SIZE)
82588 @@ -1831,12 +2064,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82589 if (flags & MAP_FIXED)
82590 return addr;
82591
82592 +#ifdef CONFIG_PAX_RANDMMAP
82593 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82594 +#endif
82595 +
82596 /* requesting a specific address */
82597 if (addr) {
82598 addr = PAGE_ALIGN(addr);
82599 vma = find_vma(mm, addr);
82600 - if (TASK_SIZE - len >= addr &&
82601 - (!vma || addr + len <= vma->vm_start))
82602 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82603 return addr;
82604 }
82605
82606 @@ -1857,6 +2093,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82607 VM_BUG_ON(addr != -ENOMEM);
82608 info.flags = 0;
82609 info.low_limit = TASK_UNMAPPED_BASE;
82610 +
82611 +#ifdef CONFIG_PAX_RANDMMAP
82612 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82613 + info.low_limit += mm->delta_mmap;
82614 +#endif
82615 +
82616 info.high_limit = TASK_SIZE;
82617 addr = vm_unmapped_area(&info);
82618 }
82619 @@ -1867,6 +2109,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82620
82621 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82622 {
82623 +
82624 +#ifdef CONFIG_PAX_SEGMEXEC
82625 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82626 + return;
82627 +#endif
82628 +
82629 /*
82630 * Is this a new hole at the highest possible address?
82631 */
82632 @@ -1874,8 +2122,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
82633 mm->free_area_cache = addr;
82634
82635 /* dont allow allocations above current base */
82636 - if (mm->free_area_cache > mm->mmap_base)
82637 + if (mm->free_area_cache > mm->mmap_base) {
82638 mm->free_area_cache = mm->mmap_base;
82639 + mm->cached_hole_size = ~0UL;
82640 + }
82641 }
82642
82643 unsigned long
82644 @@ -1974,6 +2224,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
82645 return vma;
82646 }
82647
82648 +#ifdef CONFIG_PAX_SEGMEXEC
82649 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
82650 +{
82651 + struct vm_area_struct *vma_m;
82652 +
82653 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
82654 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
82655 + BUG_ON(vma->vm_mirror);
82656 + return NULL;
82657 + }
82658 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
82659 + vma_m = vma->vm_mirror;
82660 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
82661 + BUG_ON(vma->vm_file != vma_m->vm_file);
82662 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
82663 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
82664 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
82665 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
82666 + return vma_m;
82667 +}
82668 +#endif
82669 +
82670 /*
82671 * Verify that the stack growth is acceptable and
82672 * update accounting. This is shared with both the
82673 @@ -1990,6 +2262,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82674 return -ENOMEM;
82675
82676 /* Stack limit test */
82677 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
82678 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
82679 return -ENOMEM;
82680
82681 @@ -2000,6 +2273,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82682 locked = mm->locked_vm + grow;
82683 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
82684 limit >>= PAGE_SHIFT;
82685 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82686 if (locked > limit && !capable(CAP_IPC_LOCK))
82687 return -ENOMEM;
82688 }
82689 @@ -2029,37 +2303,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
82690 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
82691 * vma is the last one with address > vma->vm_end. Have to extend vma.
82692 */
82693 +#ifndef CONFIG_IA64
82694 +static
82695 +#endif
82696 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82697 {
82698 int error;
82699 + bool locknext;
82700
82701 if (!(vma->vm_flags & VM_GROWSUP))
82702 return -EFAULT;
82703
82704 + /* Also guard against wrapping around to address 0. */
82705 + if (address < PAGE_ALIGN(address+1))
82706 + address = PAGE_ALIGN(address+1);
82707 + else
82708 + return -ENOMEM;
82709 +
82710 /*
82711 * We must make sure the anon_vma is allocated
82712 * so that the anon_vma locking is not a noop.
82713 */
82714 if (unlikely(anon_vma_prepare(vma)))
82715 return -ENOMEM;
82716 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
82717 + if (locknext && anon_vma_prepare(vma->vm_next))
82718 + return -ENOMEM;
82719 vma_lock_anon_vma(vma);
82720 + if (locknext)
82721 + vma_lock_anon_vma(vma->vm_next);
82722
82723 /*
82724 * vma->vm_start/vm_end cannot change under us because the caller
82725 * is required to hold the mmap_sem in read mode. We need the
82726 - * anon_vma lock to serialize against concurrent expand_stacks.
82727 - * Also guard against wrapping around to address 0.
82728 + * anon_vma locks to serialize against concurrent expand_stacks
82729 + * and expand_upwards.
82730 */
82731 - if (address < PAGE_ALIGN(address+4))
82732 - address = PAGE_ALIGN(address+4);
82733 - else {
82734 - vma_unlock_anon_vma(vma);
82735 - return -ENOMEM;
82736 - }
82737 error = 0;
82738
82739 /* Somebody else might have raced and expanded it already */
82740 - if (address > vma->vm_end) {
82741 + 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)
82742 + error = -ENOMEM;
82743 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
82744 unsigned long size, grow;
82745
82746 size = address - vma->vm_start;
82747 @@ -2094,6 +2379,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
82748 }
82749 }
82750 }
82751 + if (locknext)
82752 + vma_unlock_anon_vma(vma->vm_next);
82753 vma_unlock_anon_vma(vma);
82754 khugepaged_enter_vma_merge(vma);
82755 validate_mm(vma->vm_mm);
82756 @@ -2108,6 +2395,8 @@ int expand_downwards(struct vm_area_struct *vma,
82757 unsigned long address)
82758 {
82759 int error;
82760 + bool lockprev = false;
82761 + struct vm_area_struct *prev;
82762
82763 /*
82764 * We must make sure the anon_vma is allocated
82765 @@ -2121,6 +2410,15 @@ int expand_downwards(struct vm_area_struct *vma,
82766 if (error)
82767 return error;
82768
82769 + prev = vma->vm_prev;
82770 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
82771 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
82772 +#endif
82773 + if (lockprev && anon_vma_prepare(prev))
82774 + return -ENOMEM;
82775 + if (lockprev)
82776 + vma_lock_anon_vma(prev);
82777 +
82778 vma_lock_anon_vma(vma);
82779
82780 /*
82781 @@ -2130,9 +2428,17 @@ int expand_downwards(struct vm_area_struct *vma,
82782 */
82783
82784 /* Somebody else might have raced and expanded it already */
82785 - if (address < vma->vm_start) {
82786 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
82787 + error = -ENOMEM;
82788 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
82789 unsigned long size, grow;
82790
82791 +#ifdef CONFIG_PAX_SEGMEXEC
82792 + struct vm_area_struct *vma_m;
82793 +
82794 + vma_m = pax_find_mirror_vma(vma);
82795 +#endif
82796 +
82797 size = vma->vm_end - address;
82798 grow = (vma->vm_start - address) >> PAGE_SHIFT;
82799
82800 @@ -2157,6 +2463,18 @@ int expand_downwards(struct vm_area_struct *vma,
82801 vma->vm_pgoff -= grow;
82802 anon_vma_interval_tree_post_update_vma(vma);
82803 vma_gap_update(vma);
82804 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
82805 +
82806 +#ifdef CONFIG_PAX_SEGMEXEC
82807 + if (vma_m) {
82808 + anon_vma_interval_tree_pre_update_vma(vma_m);
82809 + vma_m->vm_start -= grow << PAGE_SHIFT;
82810 + vma_m->vm_pgoff -= grow;
82811 + anon_vma_interval_tree_post_update_vma(vma_m);
82812 + vma_gap_update(vma_m);
82813 + }
82814 +#endif
82815 +
82816 spin_unlock(&vma->vm_mm->page_table_lock);
82817
82818 perf_event_mmap(vma);
82819 @@ -2263,6 +2581,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
82820 do {
82821 long nrpages = vma_pages(vma);
82822
82823 +#ifdef CONFIG_PAX_SEGMEXEC
82824 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
82825 + vma = remove_vma(vma);
82826 + continue;
82827 + }
82828 +#endif
82829 +
82830 if (vma->vm_flags & VM_ACCOUNT)
82831 nr_accounted += nrpages;
82832 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
82833 @@ -2308,6 +2633,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
82834 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
82835 vma->vm_prev = NULL;
82836 do {
82837 +
82838 +#ifdef CONFIG_PAX_SEGMEXEC
82839 + if (vma->vm_mirror) {
82840 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
82841 + vma->vm_mirror->vm_mirror = NULL;
82842 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
82843 + vma->vm_mirror = NULL;
82844 + }
82845 +#endif
82846 +
82847 vma_rb_erase(vma, &mm->mm_rb);
82848 mm->map_count--;
82849 tail_vma = vma;
82850 @@ -2339,14 +2674,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82851 struct vm_area_struct *new;
82852 int err = -ENOMEM;
82853
82854 +#ifdef CONFIG_PAX_SEGMEXEC
82855 + struct vm_area_struct *vma_m, *new_m = NULL;
82856 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
82857 +#endif
82858 +
82859 if (is_vm_hugetlb_page(vma) && (addr &
82860 ~(huge_page_mask(hstate_vma(vma)))))
82861 return -EINVAL;
82862
82863 +#ifdef CONFIG_PAX_SEGMEXEC
82864 + vma_m = pax_find_mirror_vma(vma);
82865 +#endif
82866 +
82867 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82868 if (!new)
82869 goto out_err;
82870
82871 +#ifdef CONFIG_PAX_SEGMEXEC
82872 + if (vma_m) {
82873 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82874 + if (!new_m) {
82875 + kmem_cache_free(vm_area_cachep, new);
82876 + goto out_err;
82877 + }
82878 + }
82879 +#endif
82880 +
82881 /* most fields are the same, copy all, and then fixup */
82882 *new = *vma;
82883
82884 @@ -2359,6 +2713,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82885 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
82886 }
82887
82888 +#ifdef CONFIG_PAX_SEGMEXEC
82889 + if (vma_m) {
82890 + *new_m = *vma_m;
82891 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
82892 + new_m->vm_mirror = new;
82893 + new->vm_mirror = new_m;
82894 +
82895 + if (new_below)
82896 + new_m->vm_end = addr_m;
82897 + else {
82898 + new_m->vm_start = addr_m;
82899 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
82900 + }
82901 + }
82902 +#endif
82903 +
82904 pol = mpol_dup(vma_policy(vma));
82905 if (IS_ERR(pol)) {
82906 err = PTR_ERR(pol);
82907 @@ -2381,6 +2751,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82908 else
82909 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
82910
82911 +#ifdef CONFIG_PAX_SEGMEXEC
82912 + if (!err && vma_m) {
82913 + if (anon_vma_clone(new_m, vma_m))
82914 + goto out_free_mpol;
82915 +
82916 + mpol_get(pol);
82917 + vma_set_policy(new_m, pol);
82918 +
82919 + if (new_m->vm_file)
82920 + get_file(new_m->vm_file);
82921 +
82922 + if (new_m->vm_ops && new_m->vm_ops->open)
82923 + new_m->vm_ops->open(new_m);
82924 +
82925 + if (new_below)
82926 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
82927 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
82928 + else
82929 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
82930 +
82931 + if (err) {
82932 + if (new_m->vm_ops && new_m->vm_ops->close)
82933 + new_m->vm_ops->close(new_m);
82934 + if (new_m->vm_file)
82935 + fput(new_m->vm_file);
82936 + mpol_put(pol);
82937 + }
82938 + }
82939 +#endif
82940 +
82941 /* Success. */
82942 if (!err)
82943 return 0;
82944 @@ -2390,10 +2790,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82945 new->vm_ops->close(new);
82946 if (new->vm_file)
82947 fput(new->vm_file);
82948 - unlink_anon_vmas(new);
82949 out_free_mpol:
82950 mpol_put(pol);
82951 out_free_vma:
82952 +
82953 +#ifdef CONFIG_PAX_SEGMEXEC
82954 + if (new_m) {
82955 + unlink_anon_vmas(new_m);
82956 + kmem_cache_free(vm_area_cachep, new_m);
82957 + }
82958 +#endif
82959 +
82960 + unlink_anon_vmas(new);
82961 kmem_cache_free(vm_area_cachep, new);
82962 out_err:
82963 return err;
82964 @@ -2406,6 +2814,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
82965 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82966 unsigned long addr, int new_below)
82967 {
82968 +
82969 +#ifdef CONFIG_PAX_SEGMEXEC
82970 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82971 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
82972 + if (mm->map_count >= sysctl_max_map_count-1)
82973 + return -ENOMEM;
82974 + } else
82975 +#endif
82976 +
82977 if (mm->map_count >= sysctl_max_map_count)
82978 return -ENOMEM;
82979
82980 @@ -2417,11 +2834,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
82981 * work. This now handles partial unmappings.
82982 * Jeremy Fitzhardinge <jeremy@goop.org>
82983 */
82984 +#ifdef CONFIG_PAX_SEGMEXEC
82985 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82986 {
82987 + int ret = __do_munmap(mm, start, len);
82988 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
82989 + return ret;
82990 +
82991 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
82992 +}
82993 +
82994 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82995 +#else
82996 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
82997 +#endif
82998 +{
82999 unsigned long end;
83000 struct vm_area_struct *vma, *prev, *last;
83001
83002 + /*
83003 + * mm->mmap_sem is required to protect against another thread
83004 + * changing the mappings in case we sleep.
83005 + */
83006 + verify_mm_writelocked(mm);
83007 +
83008 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83009 return -EINVAL;
83010
83011 @@ -2496,6 +2932,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83012 /* Fix up all other VM information */
83013 remove_vma_list(mm, vma);
83014
83015 + track_exec_limit(mm, start, end, 0UL);
83016 +
83017 return 0;
83018 }
83019
83020 @@ -2504,6 +2942,13 @@ int vm_munmap(unsigned long start, size_t len)
83021 int ret;
83022 struct mm_struct *mm = current->mm;
83023
83024 +
83025 +#ifdef CONFIG_PAX_SEGMEXEC
83026 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83027 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83028 + return -EINVAL;
83029 +#endif
83030 +
83031 down_write(&mm->mmap_sem);
83032 ret = do_munmap(mm, start, len);
83033 up_write(&mm->mmap_sem);
83034 @@ -2517,16 +2962,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83035 return vm_munmap(addr, len);
83036 }
83037
83038 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83039 -{
83040 -#ifdef CONFIG_DEBUG_VM
83041 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83042 - WARN_ON(1);
83043 - up_read(&mm->mmap_sem);
83044 - }
83045 -#endif
83046 -}
83047 -
83048 /*
83049 * this is really a simplified "do_mmap". it only handles
83050 * anonymous maps. eventually we may be able to do some
83051 @@ -2540,6 +2975,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83052 struct rb_node ** rb_link, * rb_parent;
83053 pgoff_t pgoff = addr >> PAGE_SHIFT;
83054 int error;
83055 + unsigned long charged;
83056
83057 len = PAGE_ALIGN(len);
83058 if (!len)
83059 @@ -2547,16 +2983,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83060
83061 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83062
83063 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83064 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83065 + flags &= ~VM_EXEC;
83066 +
83067 +#ifdef CONFIG_PAX_MPROTECT
83068 + if (mm->pax_flags & MF_PAX_MPROTECT)
83069 + flags &= ~VM_MAYEXEC;
83070 +#endif
83071 +
83072 + }
83073 +#endif
83074 +
83075 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83076 if (error & ~PAGE_MASK)
83077 return error;
83078
83079 + charged = len >> PAGE_SHIFT;
83080 +
83081 /*
83082 * mlock MCL_FUTURE?
83083 */
83084 if (mm->def_flags & VM_LOCKED) {
83085 unsigned long locked, lock_limit;
83086 - locked = len >> PAGE_SHIFT;
83087 + locked = charged;
83088 locked += mm->locked_vm;
83089 lock_limit = rlimit(RLIMIT_MEMLOCK);
83090 lock_limit >>= PAGE_SHIFT;
83091 @@ -2573,21 +3023,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83092 /*
83093 * Clear old maps. this also does some error checking for us
83094 */
83095 - munmap_back:
83096 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83097 if (do_munmap(mm, addr, len))
83098 return -ENOMEM;
83099 - goto munmap_back;
83100 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83101 }
83102
83103 /* Check against address space limits *after* clearing old maps... */
83104 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83105 + if (!may_expand_vm(mm, charged))
83106 return -ENOMEM;
83107
83108 if (mm->map_count > sysctl_max_map_count)
83109 return -ENOMEM;
83110
83111 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83112 + if (security_vm_enough_memory_mm(mm, charged))
83113 return -ENOMEM;
83114
83115 /* Can we just expand an old private anonymous mapping? */
83116 @@ -2601,7 +3050,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83117 */
83118 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83119 if (!vma) {
83120 - vm_unacct_memory(len >> PAGE_SHIFT);
83121 + vm_unacct_memory(charged);
83122 return -ENOMEM;
83123 }
83124
83125 @@ -2615,11 +3064,12 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83126 vma_link(mm, vma, prev, rb_link, rb_parent);
83127 out:
83128 perf_event_mmap(vma);
83129 - mm->total_vm += len >> PAGE_SHIFT;
83130 + mm->total_vm += charged;
83131 if (flags & VM_LOCKED) {
83132 if (!mlock_vma_pages_range(vma, addr, addr + len))
83133 - mm->locked_vm += (len >> PAGE_SHIFT);
83134 + mm->locked_vm += charged;
83135 }
83136 + track_exec_limit(mm, addr, addr + len, flags);
83137 return addr;
83138 }
83139
83140 @@ -2677,6 +3127,7 @@ void exit_mmap(struct mm_struct *mm)
83141 while (vma) {
83142 if (vma->vm_flags & VM_ACCOUNT)
83143 nr_accounted += vma_pages(vma);
83144 + vma->vm_mirror = NULL;
83145 vma = remove_vma(vma);
83146 }
83147 vm_unacct_memory(nr_accounted);
83148 @@ -2693,6 +3144,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83149 struct vm_area_struct *prev;
83150 struct rb_node **rb_link, *rb_parent;
83151
83152 +#ifdef CONFIG_PAX_SEGMEXEC
83153 + struct vm_area_struct *vma_m = NULL;
83154 +#endif
83155 +
83156 + if (security_mmap_addr(vma->vm_start))
83157 + return -EPERM;
83158 +
83159 /*
83160 * The vm_pgoff of a purely anonymous vma should be irrelevant
83161 * until its first write fault, when page's anon_vma and index
83162 @@ -2716,7 +3174,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83163 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83164 return -ENOMEM;
83165
83166 +#ifdef CONFIG_PAX_SEGMEXEC
83167 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83168 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83169 + if (!vma_m)
83170 + return -ENOMEM;
83171 + }
83172 +#endif
83173 +
83174 vma_link(mm, vma, prev, rb_link, rb_parent);
83175 +
83176 +#ifdef CONFIG_PAX_SEGMEXEC
83177 + if (vma_m)
83178 + BUG_ON(pax_mirror_vma(vma_m, vma));
83179 +#endif
83180 +
83181 return 0;
83182 }
83183
83184 @@ -2736,6 +3208,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83185 struct mempolicy *pol;
83186 bool faulted_in_anon_vma = true;
83187
83188 + BUG_ON(vma->vm_mirror);
83189 +
83190 /*
83191 * If anonymous vma has not yet been faulted, update new pgoff
83192 * to match new location, to increase its chance of merging.
83193 @@ -2802,6 +3276,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83194 return NULL;
83195 }
83196
83197 +#ifdef CONFIG_PAX_SEGMEXEC
83198 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83199 +{
83200 + struct vm_area_struct *prev_m;
83201 + struct rb_node **rb_link_m, *rb_parent_m;
83202 + struct mempolicy *pol_m;
83203 +
83204 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83205 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83206 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83207 + *vma_m = *vma;
83208 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83209 + if (anon_vma_clone(vma_m, vma))
83210 + return -ENOMEM;
83211 + pol_m = vma_policy(vma_m);
83212 + mpol_get(pol_m);
83213 + vma_set_policy(vma_m, pol_m);
83214 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83215 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83216 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83217 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83218 + if (vma_m->vm_file)
83219 + get_file(vma_m->vm_file);
83220 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83221 + vma_m->vm_ops->open(vma_m);
83222 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83223 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83224 + vma_m->vm_mirror = vma;
83225 + vma->vm_mirror = vma_m;
83226 + return 0;
83227 +}
83228 +#endif
83229 +
83230 /*
83231 * Return true if the calling process may expand its vm space by the passed
83232 * number of pages
83233 @@ -2813,6 +3320,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83234
83235 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83236
83237 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83238 if (cur + npages > lim)
83239 return 0;
83240 return 1;
83241 @@ -2883,6 +3391,22 @@ int install_special_mapping(struct mm_struct *mm,
83242 vma->vm_start = addr;
83243 vma->vm_end = addr + len;
83244
83245 +#ifdef CONFIG_PAX_MPROTECT
83246 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83247 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83248 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83249 + return -EPERM;
83250 + if (!(vm_flags & VM_EXEC))
83251 + vm_flags &= ~VM_MAYEXEC;
83252 +#else
83253 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83254 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83255 +#endif
83256 + else
83257 + vm_flags &= ~VM_MAYWRITE;
83258 + }
83259 +#endif
83260 +
83261 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83262 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83263
83264 diff --git a/mm/mprotect.c b/mm/mprotect.c
83265 index 94722a4..9837984 100644
83266 --- a/mm/mprotect.c
83267 +++ b/mm/mprotect.c
83268 @@ -23,10 +23,17 @@
83269 #include <linux/mmu_notifier.h>
83270 #include <linux/migrate.h>
83271 #include <linux/perf_event.h>
83272 +
83273 +#ifdef CONFIG_PAX_MPROTECT
83274 +#include <linux/elf.h>
83275 +#include <linux/binfmts.h>
83276 +#endif
83277 +
83278 #include <asm/uaccess.h>
83279 #include <asm/pgtable.h>
83280 #include <asm/cacheflush.h>
83281 #include <asm/tlbflush.h>
83282 +#include <asm/mmu_context.h>
83283
83284 #ifndef pgprot_modify
83285 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83286 @@ -233,6 +240,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83287 return pages;
83288 }
83289
83290 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83291 +/* called while holding the mmap semaphor for writing except stack expansion */
83292 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83293 +{
83294 + unsigned long oldlimit, newlimit = 0UL;
83295 +
83296 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83297 + return;
83298 +
83299 + spin_lock(&mm->page_table_lock);
83300 + oldlimit = mm->context.user_cs_limit;
83301 + if ((prot & VM_EXEC) && oldlimit < end)
83302 + /* USER_CS limit moved up */
83303 + newlimit = end;
83304 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83305 + /* USER_CS limit moved down */
83306 + newlimit = start;
83307 +
83308 + if (newlimit) {
83309 + mm->context.user_cs_limit = newlimit;
83310 +
83311 +#ifdef CONFIG_SMP
83312 + wmb();
83313 + cpus_clear(mm->context.cpu_user_cs_mask);
83314 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83315 +#endif
83316 +
83317 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83318 + }
83319 + spin_unlock(&mm->page_table_lock);
83320 + if (newlimit == end) {
83321 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83322 +
83323 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83324 + if (is_vm_hugetlb_page(vma))
83325 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83326 + else
83327 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83328 + }
83329 +}
83330 +#endif
83331 +
83332 int
83333 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83334 unsigned long start, unsigned long end, unsigned long newflags)
83335 @@ -245,11 +294,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83336 int error;
83337 int dirty_accountable = 0;
83338
83339 +#ifdef CONFIG_PAX_SEGMEXEC
83340 + struct vm_area_struct *vma_m = NULL;
83341 + unsigned long start_m, end_m;
83342 +
83343 + start_m = start + SEGMEXEC_TASK_SIZE;
83344 + end_m = end + SEGMEXEC_TASK_SIZE;
83345 +#endif
83346 +
83347 if (newflags == oldflags) {
83348 *pprev = vma;
83349 return 0;
83350 }
83351
83352 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83353 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83354 +
83355 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83356 + return -ENOMEM;
83357 +
83358 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83359 + return -ENOMEM;
83360 + }
83361 +
83362 /*
83363 * If we make a private mapping writable we increase our commit;
83364 * but (without finer accounting) cannot reduce our commit if we
83365 @@ -266,6 +333,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83366 }
83367 }
83368
83369 +#ifdef CONFIG_PAX_SEGMEXEC
83370 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83371 + if (start != vma->vm_start) {
83372 + error = split_vma(mm, vma, start, 1);
83373 + if (error)
83374 + goto fail;
83375 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83376 + *pprev = (*pprev)->vm_next;
83377 + }
83378 +
83379 + if (end != vma->vm_end) {
83380 + error = split_vma(mm, vma, end, 0);
83381 + if (error)
83382 + goto fail;
83383 + }
83384 +
83385 + if (pax_find_mirror_vma(vma)) {
83386 + error = __do_munmap(mm, start_m, end_m - start_m);
83387 + if (error)
83388 + goto fail;
83389 + } else {
83390 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83391 + if (!vma_m) {
83392 + error = -ENOMEM;
83393 + goto fail;
83394 + }
83395 + vma->vm_flags = newflags;
83396 + error = pax_mirror_vma(vma_m, vma);
83397 + if (error) {
83398 + vma->vm_flags = oldflags;
83399 + goto fail;
83400 + }
83401 + }
83402 + }
83403 +#endif
83404 +
83405 /*
83406 * First try to merge with previous and/or next vma.
83407 */
83408 @@ -296,9 +399,21 @@ success:
83409 * vm_flags and vm_page_prot are protected by the mmap_sem
83410 * held in write mode.
83411 */
83412 +
83413 +#ifdef CONFIG_PAX_SEGMEXEC
83414 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83415 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83416 +#endif
83417 +
83418 vma->vm_flags = newflags;
83419 +
83420 +#ifdef CONFIG_PAX_MPROTECT
83421 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83422 + mm->binfmt->handle_mprotect(vma, newflags);
83423 +#endif
83424 +
83425 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83426 - vm_get_page_prot(newflags));
83427 + vm_get_page_prot(vma->vm_flags));
83428
83429 if (vma_wants_writenotify(vma)) {
83430 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83431 @@ -337,6 +452,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83432 end = start + len;
83433 if (end <= start)
83434 return -ENOMEM;
83435 +
83436 +#ifdef CONFIG_PAX_SEGMEXEC
83437 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83438 + if (end > SEGMEXEC_TASK_SIZE)
83439 + return -EINVAL;
83440 + } else
83441 +#endif
83442 +
83443 + if (end > TASK_SIZE)
83444 + return -EINVAL;
83445 +
83446 if (!arch_validate_prot(prot))
83447 return -EINVAL;
83448
83449 @@ -344,7 +470,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83450 /*
83451 * Does the application expect PROT_READ to imply PROT_EXEC:
83452 */
83453 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83454 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83455 prot |= PROT_EXEC;
83456
83457 vm_flags = calc_vm_prot_bits(prot);
83458 @@ -376,6 +502,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83459 if (start > vma->vm_start)
83460 prev = vma;
83461
83462 +#ifdef CONFIG_PAX_MPROTECT
83463 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83464 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83465 +#endif
83466 +
83467 for (nstart = start ; ; ) {
83468 unsigned long newflags;
83469
83470 @@ -386,6 +517,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83471
83472 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83473 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83474 + if (prot & (PROT_WRITE | PROT_EXEC))
83475 + gr_log_rwxmprotect(vma->vm_file);
83476 +
83477 + error = -EACCES;
83478 + goto out;
83479 + }
83480 +
83481 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83482 error = -EACCES;
83483 goto out;
83484 }
83485 @@ -400,6 +539,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83486 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83487 if (error)
83488 goto out;
83489 +
83490 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83491 +
83492 nstart = tmp;
83493
83494 if (nstart < prev->vm_end)
83495 diff --git a/mm/mremap.c b/mm/mremap.c
83496 index e1031e1..1f2a0a1 100644
83497 --- a/mm/mremap.c
83498 +++ b/mm/mremap.c
83499 @@ -125,6 +125,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83500 continue;
83501 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83502 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83503 +
83504 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83505 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83506 + pte = pte_exprotect(pte);
83507 +#endif
83508 +
83509 set_pte_at(mm, new_addr, new_pte, pte);
83510 }
83511
83512 @@ -319,6 +325,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83513 if (is_vm_hugetlb_page(vma))
83514 goto Einval;
83515
83516 +#ifdef CONFIG_PAX_SEGMEXEC
83517 + if (pax_find_mirror_vma(vma))
83518 + goto Einval;
83519 +#endif
83520 +
83521 /* We can't remap across vm area boundaries */
83522 if (old_len > vma->vm_end - addr)
83523 goto Efault;
83524 @@ -375,20 +386,25 @@ static unsigned long mremap_to(unsigned long addr,
83525 unsigned long ret = -EINVAL;
83526 unsigned long charged = 0;
83527 unsigned long map_flags;
83528 + unsigned long pax_task_size = TASK_SIZE;
83529
83530 if (new_addr & ~PAGE_MASK)
83531 goto out;
83532
83533 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83534 +#ifdef CONFIG_PAX_SEGMEXEC
83535 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83536 + pax_task_size = SEGMEXEC_TASK_SIZE;
83537 +#endif
83538 +
83539 + pax_task_size -= PAGE_SIZE;
83540 +
83541 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83542 goto out;
83543
83544 /* Check if the location we're moving into overlaps the
83545 * old location at all, and fail if it does.
83546 */
83547 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83548 - goto out;
83549 -
83550 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83551 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83552 goto out;
83553
83554 ret = do_munmap(mm, new_addr, new_len);
83555 @@ -456,6 +472,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83556 struct vm_area_struct *vma;
83557 unsigned long ret = -EINVAL;
83558 unsigned long charged = 0;
83559 + unsigned long pax_task_size = TASK_SIZE;
83560
83561 down_write(&current->mm->mmap_sem);
83562
83563 @@ -476,6 +493,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83564 if (!new_len)
83565 goto out;
83566
83567 +#ifdef CONFIG_PAX_SEGMEXEC
83568 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83569 + pax_task_size = SEGMEXEC_TASK_SIZE;
83570 +#endif
83571 +
83572 + pax_task_size -= PAGE_SIZE;
83573 +
83574 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83575 + old_len > pax_task_size || addr > pax_task_size-old_len)
83576 + goto out;
83577 +
83578 if (flags & MREMAP_FIXED) {
83579 if (flags & MREMAP_MAYMOVE)
83580 ret = mremap_to(addr, old_len, new_addr, new_len);
83581 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83582 addr + new_len);
83583 }
83584 ret = addr;
83585 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83586 goto out;
83587 }
83588 }
83589 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83590 goto out;
83591 }
83592
83593 + map_flags = vma->vm_flags;
83594 ret = move_vma(vma, addr, old_len, new_len, new_addr);
83595 + if (!(ret & ~PAGE_MASK)) {
83596 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
83597 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
83598 + }
83599 }
83600 out:
83601 if (ret & ~PAGE_MASK)
83602 diff --git a/mm/nommu.c b/mm/nommu.c
83603 index bbe1f3f..b2601ea 100644
83604 --- a/mm/nommu.c
83605 +++ b/mm/nommu.c
83606 @@ -62,7 +62,6 @@ int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
83607 int sysctl_overcommit_ratio = 50; /* default is 50% */
83608 int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
83609 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
83610 -int heap_stack_gap = 0;
83611
83612 atomic_long_t mmap_pages_allocated;
83613
83614 @@ -839,15 +838,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
83615 EXPORT_SYMBOL(find_vma);
83616
83617 /*
83618 - * find a VMA
83619 - * - we don't extend stack VMAs under NOMMU conditions
83620 - */
83621 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
83622 -{
83623 - return find_vma(mm, addr);
83624 -}
83625 -
83626 -/*
83627 * expand a stack to a given address
83628 * - not supported under NOMMU conditions
83629 */
83630 @@ -1555,6 +1545,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83631
83632 /* most fields are the same, copy all, and then fixup */
83633 *new = *vma;
83634 + INIT_LIST_HEAD(&new->anon_vma_chain);
83635 *region = *vma->vm_region;
83636 new->vm_region = region;
83637
83638 @@ -1975,8 +1966,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
83639 }
83640 EXPORT_SYMBOL(generic_file_remap_pages);
83641
83642 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83643 - unsigned long addr, void *buf, int len, int write)
83644 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83645 + unsigned long addr, void *buf, size_t len, int write)
83646 {
83647 struct vm_area_struct *vma;
83648
83649 @@ -2017,8 +2008,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
83650 *
83651 * The caller must hold a reference on @mm.
83652 */
83653 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83654 - void *buf, int len, int write)
83655 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
83656 + void *buf, size_t len, int write)
83657 {
83658 return __access_remote_vm(NULL, mm, addr, buf, len, write);
83659 }
83660 @@ -2027,7 +2018,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
83661 * Access another process' address space.
83662 * - source/target buffer must be kernel space
83663 */
83664 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
83665 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
83666 {
83667 struct mm_struct *mm;
83668
83669 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
83670 index 0713bfb..b95bb87 100644
83671 --- a/mm/page-writeback.c
83672 +++ b/mm/page-writeback.c
83673 @@ -655,7 +655,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
83674 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
83675 * - the bdi dirty thresh drops quickly due to change of JBOD workload
83676 */
83677 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
83678 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
83679 unsigned long thresh,
83680 unsigned long bg_thresh,
83681 unsigned long dirty,
83682 @@ -1630,7 +1630,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
83683 }
83684 }
83685
83686 -static struct notifier_block __cpuinitdata ratelimit_nb = {
83687 +static struct notifier_block ratelimit_nb = {
83688 .notifier_call = ratelimit_handler,
83689 .next = NULL,
83690 };
83691 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
83692 index 6a83cd3..3ab04ef 100644
83693 --- a/mm/page_alloc.c
83694 +++ b/mm/page_alloc.c
83695 @@ -58,6 +58,7 @@
83696 #include <linux/prefetch.h>
83697 #include <linux/migrate.h>
83698 #include <linux/page-debug-flags.h>
83699 +#include <linux/random.h>
83700
83701 #include <asm/tlbflush.h>
83702 #include <asm/div64.h>
83703 @@ -338,7 +339,7 @@ out:
83704 * This usage means that zero-order pages may not be compound.
83705 */
83706
83707 -static void free_compound_page(struct page *page)
83708 +void free_compound_page(struct page *page)
83709 {
83710 __free_pages_ok(page, compound_order(page));
83711 }
83712 @@ -693,6 +694,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83713 int i;
83714 int bad = 0;
83715
83716 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83717 + unsigned long index = 1UL << order;
83718 +#endif
83719 +
83720 trace_mm_page_free(page, order);
83721 kmemcheck_free_shadow(page, order);
83722
83723 @@ -708,6 +713,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
83724 debug_check_no_obj_freed(page_address(page),
83725 PAGE_SIZE << order);
83726 }
83727 +
83728 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
83729 + for (; index; --index)
83730 + sanitize_highpage(page + index - 1);
83731 +#endif
83732 +
83733 arch_free_page(page, order);
83734 kernel_map_pages(page, 1 << order, 0);
83735
83736 @@ -730,6 +741,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
83737 local_irq_restore(flags);
83738 }
83739
83740 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83741 +bool __meminitdata extra_latent_entropy;
83742 +
83743 +static int __init setup_pax_extra_latent_entropy(char *str)
83744 +{
83745 + extra_latent_entropy = true;
83746 + return 0;
83747 +}
83748 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
83749 +
83750 +volatile u64 latent_entropy;
83751 +#endif
83752 +
83753 /*
83754 * Read access to zone->managed_pages is safe because it's unsigned long,
83755 * but we still need to serialize writers. Currently all callers of
83756 @@ -752,6 +776,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
83757 set_page_count(p, 0);
83758 }
83759
83760 +#ifdef CONFIG_PAX_LATENT_ENTROPY
83761 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
83762 + u64 hash = 0;
83763 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
83764 + const u64 *data = lowmem_page_address(page);
83765 +
83766 + for (index = 0; index < end; index++)
83767 + hash ^= hash + data[index];
83768 + latent_entropy ^= hash;
83769 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
83770 + }
83771 +#endif
83772 +
83773 page_zone(page)->managed_pages += 1 << order;
83774 set_page_refcounted(page);
83775 __free_pages(page, order);
83776 @@ -861,8 +898,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
83777 arch_alloc_page(page, order);
83778 kernel_map_pages(page, 1 << order, 1);
83779
83780 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
83781 if (gfp_flags & __GFP_ZERO)
83782 prep_zero_page(page, order, gfp_flags);
83783 +#endif
83784
83785 if (order && (gfp_flags & __GFP_COMP))
83786 prep_compound_page(page, order);
83787 @@ -3752,7 +3791,13 @@ static int pageblock_is_reserved(unsigned long start_pfn, unsigned long end_pfn)
83788 unsigned long pfn;
83789
83790 for (pfn = start_pfn; pfn < end_pfn; pfn++) {
83791 +#ifdef CONFIG_X86_32
83792 + /* boot failures in VMware 8 on 32bit vanilla since
83793 + this change */
83794 + if (!pfn_valid(pfn) || PageReserved(pfn_to_page(pfn)))
83795 +#else
83796 if (!pfn_valid_within(pfn) || PageReserved(pfn_to_page(pfn)))
83797 +#endif
83798 return 1;
83799 }
83800 return 0;
83801 diff --git a/mm/percpu.c b/mm/percpu.c
83802 index 8c8e08f..73a5cda 100644
83803 --- a/mm/percpu.c
83804 +++ b/mm/percpu.c
83805 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
83806 static unsigned int pcpu_high_unit_cpu __read_mostly;
83807
83808 /* the address of the first chunk which starts with the kernel static area */
83809 -void *pcpu_base_addr __read_mostly;
83810 +void *pcpu_base_addr __read_only;
83811 EXPORT_SYMBOL_GPL(pcpu_base_addr);
83812
83813 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
83814 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
83815 index fd26d04..0cea1b0 100644
83816 --- a/mm/process_vm_access.c
83817 +++ b/mm/process_vm_access.c
83818 @@ -13,6 +13,7 @@
83819 #include <linux/uio.h>
83820 #include <linux/sched.h>
83821 #include <linux/highmem.h>
83822 +#include <linux/security.h>
83823 #include <linux/ptrace.h>
83824 #include <linux/slab.h>
83825 #include <linux/syscalls.h>
83826 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83827 size_t iov_l_curr_offset = 0;
83828 ssize_t iov_len;
83829
83830 + return -ENOSYS; // PaX: until properly audited
83831 +
83832 /*
83833 * Work out how many pages of struct pages we're going to need
83834 * when eventually calling get_user_pages
83835 */
83836 for (i = 0; i < riovcnt; i++) {
83837 iov_len = rvec[i].iov_len;
83838 - if (iov_len > 0) {
83839 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
83840 - + iov_len)
83841 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
83842 - / PAGE_SIZE + 1;
83843 - nr_pages = max(nr_pages, nr_pages_iov);
83844 - }
83845 + if (iov_len <= 0)
83846 + continue;
83847 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
83848 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
83849 + nr_pages = max(nr_pages, nr_pages_iov);
83850 }
83851
83852 if (nr_pages == 0)
83853 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
83854 goto free_proc_pages;
83855 }
83856
83857 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
83858 + rc = -EPERM;
83859 + goto put_task_struct;
83860 + }
83861 +
83862 mm = mm_access(task, PTRACE_MODE_ATTACH);
83863 if (!mm || IS_ERR(mm)) {
83864 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
83865 diff --git a/mm/rmap.c b/mm/rmap.c
83866 index 2c78f8c..9e9c624 100644
83867 --- a/mm/rmap.c
83868 +++ b/mm/rmap.c
83869 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83870 struct anon_vma *anon_vma = vma->anon_vma;
83871 struct anon_vma_chain *avc;
83872
83873 +#ifdef CONFIG_PAX_SEGMEXEC
83874 + struct anon_vma_chain *avc_m = NULL;
83875 +#endif
83876 +
83877 might_sleep();
83878 if (unlikely(!anon_vma)) {
83879 struct mm_struct *mm = vma->vm_mm;
83880 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83881 if (!avc)
83882 goto out_enomem;
83883
83884 +#ifdef CONFIG_PAX_SEGMEXEC
83885 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
83886 + if (!avc_m)
83887 + goto out_enomem_free_avc;
83888 +#endif
83889 +
83890 anon_vma = find_mergeable_anon_vma(vma);
83891 allocated = NULL;
83892 if (!anon_vma) {
83893 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83894 /* page_table_lock to protect against threads */
83895 spin_lock(&mm->page_table_lock);
83896 if (likely(!vma->anon_vma)) {
83897 +
83898 +#ifdef CONFIG_PAX_SEGMEXEC
83899 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
83900 +
83901 + if (vma_m) {
83902 + BUG_ON(vma_m->anon_vma);
83903 + vma_m->anon_vma = anon_vma;
83904 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
83905 + avc_m = NULL;
83906 + }
83907 +#endif
83908 +
83909 vma->anon_vma = anon_vma;
83910 anon_vma_chain_link(vma, avc, anon_vma);
83911 allocated = NULL;
83912 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
83913
83914 if (unlikely(allocated))
83915 put_anon_vma(allocated);
83916 +
83917 +#ifdef CONFIG_PAX_SEGMEXEC
83918 + if (unlikely(avc_m))
83919 + anon_vma_chain_free(avc_m);
83920 +#endif
83921 +
83922 if (unlikely(avc))
83923 anon_vma_chain_free(avc);
83924 }
83925 return 0;
83926
83927 out_enomem_free_avc:
83928 +
83929 +#ifdef CONFIG_PAX_SEGMEXEC
83930 + if (avc_m)
83931 + anon_vma_chain_free(avc_m);
83932 +#endif
83933 +
83934 anon_vma_chain_free(avc);
83935 out_enomem:
83936 return -ENOMEM;
83937 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
83938 * Attach the anon_vmas from src to dst.
83939 * Returns 0 on success, -ENOMEM on failure.
83940 */
83941 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83942 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
83943 {
83944 struct anon_vma_chain *avc, *pavc;
83945 struct anon_vma *root = NULL;
83946 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
83947 * the corresponding VMA in the parent process is attached to.
83948 * Returns 0 on success, non-zero on failure.
83949 */
83950 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
83951 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
83952 {
83953 struct anon_vma_chain *avc;
83954 struct anon_vma *anon_vma;
83955 diff --git a/mm/shmem.c b/mm/shmem.c
83956 index efd0b3a..994b702 100644
83957 --- a/mm/shmem.c
83958 +++ b/mm/shmem.c
83959 @@ -31,7 +31,7 @@
83960 #include <linux/export.h>
83961 #include <linux/swap.h>
83962
83963 -static struct vfsmount *shm_mnt;
83964 +struct vfsmount *shm_mnt;
83965
83966 #ifdef CONFIG_SHMEM
83967 /*
83968 @@ -75,7 +75,7 @@ static struct vfsmount *shm_mnt;
83969 #define BOGO_DIRENT_SIZE 20
83970
83971 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
83972 -#define SHORT_SYMLINK_LEN 128
83973 +#define SHORT_SYMLINK_LEN 64
83974
83975 /*
83976 * shmem_fallocate and shmem_writepage communicate via inode->i_private
83977 @@ -2202,6 +2202,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
83978 static int shmem_xattr_validate(const char *name)
83979 {
83980 struct { const char *prefix; size_t len; } arr[] = {
83981 +
83982 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83983 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
83984 +#endif
83985 +
83986 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
83987 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
83988 };
83989 @@ -2257,6 +2262,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
83990 if (err)
83991 return err;
83992
83993 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
83994 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
83995 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
83996 + return -EOPNOTSUPP;
83997 + if (size > 8)
83998 + return -EINVAL;
83999 + }
84000 +#endif
84001 +
84002 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84003 }
84004
84005 @@ -2562,8 +2576,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84006 int err = -ENOMEM;
84007
84008 /* Round up to L1_CACHE_BYTES to resist false sharing */
84009 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84010 - L1_CACHE_BYTES), GFP_KERNEL);
84011 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84012 if (!sbinfo)
84013 return -ENOMEM;
84014
84015 diff --git a/mm/slab.c b/mm/slab.c
84016 index e7667a3..a48e73b 100644
84017 --- a/mm/slab.c
84018 +++ b/mm/slab.c
84019 @@ -306,7 +306,7 @@ struct kmem_list3 {
84020 * Need this for bootstrapping a per node allocator.
84021 */
84022 #define NUM_INIT_LISTS (3 * MAX_NUMNODES)
84023 -static struct kmem_list3 __initdata initkmem_list3[NUM_INIT_LISTS];
84024 +static struct kmem_list3 initkmem_list3[NUM_INIT_LISTS];
84025 #define CACHE_CACHE 0
84026 #define SIZE_AC MAX_NUMNODES
84027 #define SIZE_L3 (2 * MAX_NUMNODES)
84028 @@ -407,10 +407,10 @@ static void kmem_list3_init(struct kmem_list3 *parent)
84029 if ((x)->max_freeable < i) \
84030 (x)->max_freeable = i; \
84031 } while (0)
84032 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84033 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84034 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84035 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84036 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84037 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84038 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84039 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84040 #else
84041 #define STATS_INC_ACTIVE(x) do { } while (0)
84042 #define STATS_DEC_ACTIVE(x) do { } while (0)
84043 @@ -518,7 +518,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84044 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84045 */
84046 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84047 - const struct slab *slab, void *obj)
84048 + const struct slab *slab, const void *obj)
84049 {
84050 u32 offset = (obj - slab->s_mem);
84051 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84052 @@ -539,12 +539,13 @@ EXPORT_SYMBOL(malloc_sizes);
84053 struct cache_names {
84054 char *name;
84055 char *name_dma;
84056 + char *name_usercopy;
84057 };
84058
84059 static struct cache_names __initdata cache_names[] = {
84060 -#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)" },
84061 +#define CACHE(x) { .name = "size-" #x, .name_dma = "size-" #x "(DMA)", .name_usercopy = "size-" #x "(USERCOPY)" },
84062 #include <linux/kmalloc_sizes.h>
84063 - {NULL,}
84064 + {NULL}
84065 #undef CACHE
84066 };
84067
84068 @@ -729,6 +730,12 @@ static inline struct kmem_cache *__find_general_cachep(size_t size,
84069 if (unlikely(gfpflags & GFP_DMA))
84070 return csizep->cs_dmacachep;
84071 #endif
84072 +
84073 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84074 + if (unlikely(gfpflags & GFP_USERCOPY))
84075 + return csizep->cs_usercopycachep;
84076 +#endif
84077 +
84078 return csizep->cs_cachep;
84079 }
84080
84081 @@ -1482,7 +1489,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84082 return notifier_from_errno(err);
84083 }
84084
84085 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84086 +static struct notifier_block cpucache_notifier = {
84087 &cpuup_callback, NULL, 0
84088 };
84089
84090 @@ -1667,12 +1674,12 @@ void __init kmem_cache_init(void)
84091 */
84092
84093 sizes[INDEX_AC].cs_cachep = create_kmalloc_cache(names[INDEX_AC].name,
84094 - sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS);
84095 + sizes[INDEX_AC].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84096
84097 if (INDEX_AC != INDEX_L3)
84098 sizes[INDEX_L3].cs_cachep =
84099 create_kmalloc_cache(names[INDEX_L3].name,
84100 - sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS);
84101 + sizes[INDEX_L3].cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84102
84103 slab_early_init = 0;
84104
84105 @@ -1686,13 +1693,20 @@ void __init kmem_cache_init(void)
84106 */
84107 if (!sizes->cs_cachep)
84108 sizes->cs_cachep = create_kmalloc_cache(names->name,
84109 - sizes->cs_size, ARCH_KMALLOC_FLAGS);
84110 + sizes->cs_size, ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84111
84112 #ifdef CONFIG_ZONE_DMA
84113 sizes->cs_dmacachep = create_kmalloc_cache(
84114 names->name_dma, sizes->cs_size,
84115 SLAB_CACHE_DMA|ARCH_KMALLOC_FLAGS);
84116 #endif
84117 +
84118 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84119 + sizes->cs_usercopycachep = create_kmalloc_cache(
84120 + names->name_usercopy, sizes->cs_size,
84121 + ARCH_KMALLOC_FLAGS|SLAB_USERCOPY);
84122 +#endif
84123 +
84124 sizes++;
84125 names++;
84126 }
84127 @@ -3924,6 +3938,7 @@ void kfree(const void *objp)
84128
84129 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84130 return;
84131 + VM_BUG_ON(!virt_addr_valid(objp));
84132 local_irq_save(flags);
84133 kfree_debugcheck(objp);
84134 c = virt_to_cache(objp);
84135 @@ -4365,10 +4380,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84136 }
84137 /* cpu stats */
84138 {
84139 - unsigned long allochit = atomic_read(&cachep->allochit);
84140 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84141 - unsigned long freehit = atomic_read(&cachep->freehit);
84142 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84143 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84144 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84145 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84146 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84147
84148 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84149 allochit, allocmiss, freehit, freemiss);
84150 @@ -4600,13 +4615,71 @@ static const struct file_operations proc_slabstats_operations = {
84151 static int __init slab_proc_init(void)
84152 {
84153 #ifdef CONFIG_DEBUG_SLAB_LEAK
84154 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84155 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84156 #endif
84157 return 0;
84158 }
84159 module_init(slab_proc_init);
84160 #endif
84161
84162 +bool is_usercopy_object(const void *ptr)
84163 +{
84164 + struct page *page;
84165 + struct kmem_cache *cachep;
84166 +
84167 + if (ZERO_OR_NULL_PTR(ptr))
84168 + return false;
84169 +
84170 + if (!slab_is_available())
84171 + return false;
84172 +
84173 + if (!virt_addr_valid(ptr))
84174 + return false;
84175 +
84176 + page = virt_to_head_page(ptr);
84177 +
84178 + if (!PageSlab(page))
84179 + return false;
84180 +
84181 + cachep = page->slab_cache;
84182 + return cachep->flags & SLAB_USERCOPY;
84183 +}
84184 +
84185 +#ifdef CONFIG_PAX_USERCOPY
84186 +const char *check_heap_object(const void *ptr, unsigned long n)
84187 +{
84188 + struct page *page;
84189 + struct kmem_cache *cachep;
84190 + struct slab *slabp;
84191 + unsigned int objnr;
84192 + unsigned long offset;
84193 +
84194 + if (ZERO_OR_NULL_PTR(ptr))
84195 + return "<null>";
84196 +
84197 + if (!virt_addr_valid(ptr))
84198 + return NULL;
84199 +
84200 + page = virt_to_head_page(ptr);
84201 +
84202 + if (!PageSlab(page))
84203 + return NULL;
84204 +
84205 + cachep = page->slab_cache;
84206 + if (!(cachep->flags & SLAB_USERCOPY))
84207 + return cachep->name;
84208 +
84209 + slabp = page->slab_page;
84210 + objnr = obj_to_index(cachep, slabp, ptr);
84211 + BUG_ON(objnr >= cachep->num);
84212 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84213 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84214 + return NULL;
84215 +
84216 + return cachep->name;
84217 +}
84218 +#endif
84219 +
84220 /**
84221 * ksize - get the actual amount of memory allocated for a given object
84222 * @objp: Pointer to the object
84223 diff --git a/mm/slab.h b/mm/slab.h
84224 index 34a98d6..73633d1 100644
84225 --- a/mm/slab.h
84226 +++ b/mm/slab.h
84227 @@ -58,7 +58,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84228
84229 /* Legal flag mask for kmem_cache_create(), for various configurations */
84230 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84231 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84232 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84233
84234 #if defined(CONFIG_DEBUG_SLAB)
84235 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84236 @@ -220,6 +220,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84237 return s;
84238
84239 page = virt_to_head_page(x);
84240 +
84241 + BUG_ON(!PageSlab(page));
84242 +
84243 cachep = page->slab_cache;
84244 if (slab_equal_or_root(cachep, s))
84245 return cachep;
84246 diff --git a/mm/slab_common.c b/mm/slab_common.c
84247 index 3f3cd97..93b0236 100644
84248 --- a/mm/slab_common.c
84249 +++ b/mm/slab_common.c
84250 @@ -22,7 +22,7 @@
84251
84252 #include "slab.h"
84253
84254 -enum slab_state slab_state;
84255 +enum slab_state slab_state __read_only;
84256 LIST_HEAD(slab_caches);
84257 DEFINE_MUTEX(slab_mutex);
84258 struct kmem_cache *kmem_cache;
84259 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84260
84261 err = __kmem_cache_create(s, flags);
84262 if (!err) {
84263 - s->refcount = 1;
84264 + atomic_set(&s->refcount, 1);
84265 list_add(&s->list, &slab_caches);
84266 memcg_cache_list_add(memcg, s);
84267 } else {
84268 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84269
84270 get_online_cpus();
84271 mutex_lock(&slab_mutex);
84272 - s->refcount--;
84273 - if (!s->refcount) {
84274 + if (atomic_dec_and_test(&s->refcount)) {
84275 list_del(&s->list);
84276
84277 if (!__kmem_cache_shutdown(s)) {
84278 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84279 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
84280 name, size, err);
84281
84282 - s->refcount = -1; /* Exempt from merging for now */
84283 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84284 }
84285
84286 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84287 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84288
84289 create_boot_cache(s, name, size, flags);
84290 list_add(&s->list, &slab_caches);
84291 - s->refcount = 1;
84292 + atomic_set(&s->refcount, 1);
84293 return s;
84294 }
84295
84296 diff --git a/mm/slob.c b/mm/slob.c
84297 index a99fdf7..6ee34ec 100644
84298 --- a/mm/slob.c
84299 +++ b/mm/slob.c
84300 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84301 /*
84302 * Return the size of a slob block.
84303 */
84304 -static slobidx_t slob_units(slob_t *s)
84305 +static slobidx_t slob_units(const slob_t *s)
84306 {
84307 if (s->units > 0)
84308 return s->units;
84309 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84310 /*
84311 * Return the next free slob block pointer after this one.
84312 */
84313 -static slob_t *slob_next(slob_t *s)
84314 +static slob_t *slob_next(const slob_t *s)
84315 {
84316 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84317 slobidx_t next;
84318 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84319 /*
84320 * Returns true if s is the last free block in its page.
84321 */
84322 -static int slob_last(slob_t *s)
84323 +static int slob_last(const slob_t *s)
84324 {
84325 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84326 }
84327
84328 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84329 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84330 {
84331 - void *page;
84332 + struct page *page;
84333
84334 #ifdef CONFIG_NUMA
84335 if (node != NUMA_NO_NODE)
84336 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84337 if (!page)
84338 return NULL;
84339
84340 - return page_address(page);
84341 + __SetPageSlab(page);
84342 + return page;
84343 }
84344
84345 -static void slob_free_pages(void *b, int order)
84346 +static void slob_free_pages(struct page *sp, int order)
84347 {
84348 if (current->reclaim_state)
84349 current->reclaim_state->reclaimed_slab += 1 << order;
84350 - free_pages((unsigned long)b, order);
84351 + __ClearPageSlab(sp);
84352 + reset_page_mapcount(sp);
84353 + sp->private = 0;
84354 + __free_pages(sp, order);
84355 }
84356
84357 /*
84358 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84359
84360 /* Not enough space: must allocate a new page */
84361 if (!b) {
84362 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84363 - if (!b)
84364 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84365 + if (!sp)
84366 return NULL;
84367 - sp = virt_to_page(b);
84368 - __SetPageSlab(sp);
84369 + b = page_address(sp);
84370
84371 spin_lock_irqsave(&slob_lock, flags);
84372 sp->units = SLOB_UNITS(PAGE_SIZE);
84373 sp->freelist = b;
84374 + sp->private = 0;
84375 INIT_LIST_HEAD(&sp->list);
84376 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84377 set_slob_page_free(sp, slob_list);
84378 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84379 if (slob_page_free(sp))
84380 clear_slob_page_free(sp);
84381 spin_unlock_irqrestore(&slob_lock, flags);
84382 - __ClearPageSlab(sp);
84383 - reset_page_mapcount(sp);
84384 - slob_free_pages(b, 0);
84385 + slob_free_pages(sp, 0);
84386 return;
84387 }
84388
84389 @@ -424,11 +426,10 @@ out:
84390 */
84391
84392 static __always_inline void *
84393 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84394 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84395 {
84396 - unsigned int *m;
84397 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84398 - void *ret;
84399 + slob_t *m;
84400 + void *ret = NULL;
84401
84402 gfp &= gfp_allowed_mask;
84403
84404 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84405
84406 if (!m)
84407 return NULL;
84408 - *m = size;
84409 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84410 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84411 + m[0].units = size;
84412 + m[1].units = align;
84413 ret = (void *)m + align;
84414
84415 trace_kmalloc_node(caller, ret,
84416 size, size + align, gfp, node);
84417 } else {
84418 unsigned int order = get_order(size);
84419 + struct page *page;
84420
84421 if (likely(order))
84422 gfp |= __GFP_COMP;
84423 - ret = slob_new_pages(gfp, order, node);
84424 + page = slob_new_pages(gfp, order, node);
84425 + if (page) {
84426 + ret = page_address(page);
84427 + page->private = size;
84428 + }
84429
84430 trace_kmalloc_node(caller, ret,
84431 size, PAGE_SIZE << order, gfp, node);
84432 }
84433
84434 - kmemleak_alloc(ret, size, 1, gfp);
84435 + return ret;
84436 +}
84437 +
84438 +static __always_inline void *
84439 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84440 +{
84441 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84442 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84443 +
84444 + if (!ZERO_OR_NULL_PTR(ret))
84445 + kmemleak_alloc(ret, size, 1, gfp);
84446 return ret;
84447 }
84448
84449 @@ -493,34 +512,112 @@ void kfree(const void *block)
84450 return;
84451 kmemleak_free(block);
84452
84453 + VM_BUG_ON(!virt_addr_valid(block));
84454 sp = virt_to_page(block);
84455 - if (PageSlab(sp)) {
84456 + VM_BUG_ON(!PageSlab(sp));
84457 + if (!sp->private) {
84458 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84459 - unsigned int *m = (unsigned int *)(block - align);
84460 - slob_free(m, *m + align);
84461 - } else
84462 + slob_t *m = (slob_t *)(block - align);
84463 + slob_free(m, m[0].units + align);
84464 + } else {
84465 + __ClearPageSlab(sp);
84466 + reset_page_mapcount(sp);
84467 + sp->private = 0;
84468 __free_pages(sp, compound_order(sp));
84469 + }
84470 }
84471 EXPORT_SYMBOL(kfree);
84472
84473 +bool is_usercopy_object(const void *ptr)
84474 +{
84475 + if (!slab_is_available())
84476 + return false;
84477 +
84478 + // PAX: TODO
84479 +
84480 + return false;
84481 +}
84482 +
84483 +#ifdef CONFIG_PAX_USERCOPY
84484 +const char *check_heap_object(const void *ptr, unsigned long n)
84485 +{
84486 + struct page *page;
84487 + const slob_t *free;
84488 + const void *base;
84489 + unsigned long flags;
84490 +
84491 + if (ZERO_OR_NULL_PTR(ptr))
84492 + return "<null>";
84493 +
84494 + if (!virt_addr_valid(ptr))
84495 + return NULL;
84496 +
84497 + page = virt_to_head_page(ptr);
84498 + if (!PageSlab(page))
84499 + return NULL;
84500 +
84501 + if (page->private) {
84502 + base = page;
84503 + if (base <= ptr && n <= page->private - (ptr - base))
84504 + return NULL;
84505 + return "<slob>";
84506 + }
84507 +
84508 + /* some tricky double walking to find the chunk */
84509 + spin_lock_irqsave(&slob_lock, flags);
84510 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84511 + free = page->freelist;
84512 +
84513 + while (!slob_last(free) && (void *)free <= ptr) {
84514 + base = free + slob_units(free);
84515 + free = slob_next(free);
84516 + }
84517 +
84518 + while (base < (void *)free) {
84519 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84520 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84521 + int offset;
84522 +
84523 + if (ptr < base + align)
84524 + break;
84525 +
84526 + offset = ptr - base - align;
84527 + if (offset >= m) {
84528 + base += size;
84529 + continue;
84530 + }
84531 +
84532 + if (n > m - offset)
84533 + break;
84534 +
84535 + spin_unlock_irqrestore(&slob_lock, flags);
84536 + return NULL;
84537 + }
84538 +
84539 + spin_unlock_irqrestore(&slob_lock, flags);
84540 + return "<slob>";
84541 +}
84542 +#endif
84543 +
84544 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84545 size_t ksize(const void *block)
84546 {
84547 struct page *sp;
84548 int align;
84549 - unsigned int *m;
84550 + slob_t *m;
84551
84552 BUG_ON(!block);
84553 if (unlikely(block == ZERO_SIZE_PTR))
84554 return 0;
84555
84556 sp = virt_to_page(block);
84557 - if (unlikely(!PageSlab(sp)))
84558 - return PAGE_SIZE << compound_order(sp);
84559 + VM_BUG_ON(!PageSlab(sp));
84560 + if (sp->private)
84561 + return sp->private;
84562
84563 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84564 - m = (unsigned int *)(block - align);
84565 - return SLOB_UNITS(*m) * SLOB_UNIT;
84566 + m = (slob_t *)(block - align);
84567 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84568 }
84569 EXPORT_SYMBOL(ksize);
84570
84571 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84572
84573 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84574 {
84575 - void *b;
84576 + void *b = NULL;
84577
84578 flags &= gfp_allowed_mask;
84579
84580 lockdep_trace_alloc(flags);
84581
84582 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84583 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84584 +#else
84585 if (c->size < PAGE_SIZE) {
84586 b = slob_alloc(c->size, flags, c->align, node);
84587 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84588 SLOB_UNITS(c->size) * SLOB_UNIT,
84589 flags, node);
84590 } else {
84591 - b = slob_new_pages(flags, get_order(c->size), node);
84592 + struct page *sp;
84593 +
84594 + sp = slob_new_pages(flags, get_order(c->size), node);
84595 + if (sp) {
84596 + b = page_address(sp);
84597 + sp->private = c->size;
84598 + }
84599 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84600 PAGE_SIZE << get_order(c->size),
84601 flags, node);
84602 }
84603 +#endif
84604
84605 if (c->ctor)
84606 c->ctor(b);
84607 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
84608
84609 static void __kmem_cache_free(void *b, int size)
84610 {
84611 - if (size < PAGE_SIZE)
84612 + struct page *sp;
84613 +
84614 + sp = virt_to_page(b);
84615 + BUG_ON(!PageSlab(sp));
84616 + if (!sp->private)
84617 slob_free(b, size);
84618 else
84619 - slob_free_pages(b, get_order(size));
84620 + slob_free_pages(sp, get_order(size));
84621 }
84622
84623 static void kmem_rcu_free(struct rcu_head *head)
84624 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
84625
84626 void kmem_cache_free(struct kmem_cache *c, void *b)
84627 {
84628 + int size = c->size;
84629 +
84630 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84631 + if (size + c->align < PAGE_SIZE) {
84632 + size += c->align;
84633 + b -= c->align;
84634 + }
84635 +#endif
84636 +
84637 kmemleak_free_recursive(b, c->flags);
84638 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
84639 struct slob_rcu *slob_rcu;
84640 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
84641 - slob_rcu->size = c->size;
84642 + slob_rcu = b + (size - sizeof(struct slob_rcu));
84643 + slob_rcu->size = size;
84644 call_rcu(&slob_rcu->head, kmem_rcu_free);
84645 } else {
84646 - __kmem_cache_free(b, c->size);
84647 + __kmem_cache_free(b, size);
84648 }
84649
84650 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84651 + trace_kfree(_RET_IP_, b);
84652 +#else
84653 trace_kmem_cache_free(_RET_IP_, b);
84654 +#endif
84655 +
84656 }
84657 EXPORT_SYMBOL(kmem_cache_free);
84658
84659 diff --git a/mm/slub.c b/mm/slub.c
84660 index ba2ca53..991c4f7 100644
84661 --- a/mm/slub.c
84662 +++ b/mm/slub.c
84663 @@ -197,7 +197,7 @@ struct track {
84664
84665 enum track_item { TRACK_ALLOC, TRACK_FREE };
84666
84667 -#ifdef CONFIG_SYSFS
84668 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84669 static int sysfs_slab_add(struct kmem_cache *);
84670 static int sysfs_slab_alias(struct kmem_cache *, const char *);
84671 static void sysfs_slab_remove(struct kmem_cache *);
84672 @@ -518,7 +518,7 @@ static void print_track(const char *s, struct track *t)
84673 if (!t->addr)
84674 return;
84675
84676 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
84677 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
84678 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
84679 #ifdef CONFIG_STACKTRACE
84680 {
84681 @@ -2653,7 +2653,7 @@ static int slub_min_objects;
84682 * Merge control. If this is set then no merging of slab caches will occur.
84683 * (Could be removed. This was introduced to pacify the merge skeptics.)
84684 */
84685 -static int slub_nomerge;
84686 +static int slub_nomerge = 1;
84687
84688 /*
84689 * Calculate the order of allocation given an slab object size.
84690 @@ -3181,6 +3181,10 @@ EXPORT_SYMBOL(kmalloc_caches);
84691 static struct kmem_cache *kmalloc_dma_caches[SLUB_PAGE_SHIFT];
84692 #endif
84693
84694 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84695 +static struct kmem_cache *kmalloc_usercopy_caches[SLUB_PAGE_SHIFT];
84696 +#endif
84697 +
84698 static int __init setup_slub_min_order(char *str)
84699 {
84700 get_option(&str, &slub_min_order);
84701 @@ -3272,6 +3276,13 @@ static struct kmem_cache *get_slab(size_t size, gfp_t flags)
84702 return kmalloc_dma_caches[index];
84703
84704 #endif
84705 +
84706 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84707 + if (flags & SLAB_USERCOPY)
84708 + return kmalloc_usercopy_caches[index];
84709 +
84710 +#endif
84711 +
84712 return kmalloc_caches[index];
84713 }
84714
84715 @@ -3340,6 +3351,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
84716 EXPORT_SYMBOL(__kmalloc_node);
84717 #endif
84718
84719 +bool is_usercopy_object(const void *ptr)
84720 +{
84721 + struct page *page;
84722 + struct kmem_cache *s;
84723 +
84724 + if (ZERO_OR_NULL_PTR(ptr))
84725 + return false;
84726 +
84727 + if (!slab_is_available())
84728 + return false;
84729 +
84730 + if (!virt_addr_valid(ptr))
84731 + return false;
84732 +
84733 + page = virt_to_head_page(ptr);
84734 +
84735 + if (!PageSlab(page))
84736 + return false;
84737 +
84738 + s = page->slab_cache;
84739 + return s->flags & SLAB_USERCOPY;
84740 +}
84741 +
84742 +#ifdef CONFIG_PAX_USERCOPY
84743 +const char *check_heap_object(const void *ptr, unsigned long n)
84744 +{
84745 + struct page *page;
84746 + struct kmem_cache *s;
84747 + unsigned long offset;
84748 +
84749 + if (ZERO_OR_NULL_PTR(ptr))
84750 + return "<null>";
84751 +
84752 + if (!virt_addr_valid(ptr))
84753 + return NULL;
84754 +
84755 + page = virt_to_head_page(ptr);
84756 +
84757 + if (!PageSlab(page))
84758 + return NULL;
84759 +
84760 + s = page->slab_cache;
84761 + if (!(s->flags & SLAB_USERCOPY))
84762 + return s->name;
84763 +
84764 + offset = (ptr - page_address(page)) % s->size;
84765 + if (offset <= s->object_size && n <= s->object_size - offset)
84766 + return NULL;
84767 +
84768 + return s->name;
84769 +}
84770 +#endif
84771 +
84772 size_t ksize(const void *object)
84773 {
84774 struct page *page;
84775 @@ -3404,6 +3468,7 @@ void kfree(const void *x)
84776 if (unlikely(ZERO_OR_NULL_PTR(x)))
84777 return;
84778
84779 + VM_BUG_ON(!virt_addr_valid(x));
84780 page = virt_to_head_page(x);
84781 if (unlikely(!PageSlab(page))) {
84782 BUG_ON(!PageCompound(page));
84783 @@ -3712,17 +3777,17 @@ void __init kmem_cache_init(void)
84784
84785 /* Caches that are not of the two-to-the-power-of size */
84786 if (KMALLOC_MIN_SIZE <= 32) {
84787 - kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, 0);
84788 + kmalloc_caches[1] = create_kmalloc_cache("kmalloc-96", 96, SLAB_USERCOPY);
84789 caches++;
84790 }
84791
84792 if (KMALLOC_MIN_SIZE <= 64) {
84793 - kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, 0);
84794 + kmalloc_caches[2] = create_kmalloc_cache("kmalloc-192", 192, SLAB_USERCOPY);
84795 caches++;
84796 }
84797
84798 for (i = KMALLOC_SHIFT_LOW; i < SLUB_PAGE_SHIFT; i++) {
84799 - kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, 0);
84800 + kmalloc_caches[i] = create_kmalloc_cache("kmalloc", 1 << i, SLAB_USERCOPY);
84801 caches++;
84802 }
84803
84804 @@ -3764,6 +3829,22 @@ void __init kmem_cache_init(void)
84805 }
84806 }
84807 #endif
84808 +
84809 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84810 + for (i = 0; i < SLUB_PAGE_SHIFT; i++) {
84811 + struct kmem_cache *s = kmalloc_caches[i];
84812 +
84813 + if (s && s->size) {
84814 + char *name = kasprintf(GFP_NOWAIT,
84815 + "usercopy-kmalloc-%d", s->object_size);
84816 +
84817 + BUG_ON(!name);
84818 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(name,
84819 + s->object_size, SLAB_USERCOPY);
84820 + }
84821 + }
84822 +#endif
84823 +
84824 printk(KERN_INFO
84825 "SLUB: Genslabs=%d, HWalign=%d, Order=%d-%d, MinObjects=%d,"
84826 " CPUs=%d, Nodes=%d\n",
84827 @@ -3790,7 +3871,7 @@ static int slab_unmergeable(struct kmem_cache *s)
84828 /*
84829 * We may have set a slab to be unmergeable during bootstrap.
84830 */
84831 - if (s->refcount < 0)
84832 + if (atomic_read(&s->refcount) < 0)
84833 return 1;
84834
84835 return 0;
84836 @@ -3848,7 +3929,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84837
84838 s = find_mergeable(memcg, size, align, flags, name, ctor);
84839 if (s) {
84840 - s->refcount++;
84841 + atomic_inc(&s->refcount);
84842 /*
84843 * Adjust the object sizes so that we clear
84844 * the complete object on kzalloc.
84845 @@ -3857,7 +3938,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84846 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
84847
84848 if (sysfs_slab_alias(s, name)) {
84849 - s->refcount--;
84850 + atomic_dec(&s->refcount);
84851 s = NULL;
84852 }
84853 }
84854 @@ -3919,7 +4000,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
84855 return NOTIFY_OK;
84856 }
84857
84858 -static struct notifier_block __cpuinitdata slab_notifier = {
84859 +static struct notifier_block slab_notifier = {
84860 .notifier_call = slab_cpuup_callback
84861 };
84862
84863 @@ -3977,7 +4058,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
84864 }
84865 #endif
84866
84867 -#ifdef CONFIG_SYSFS
84868 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84869 static int count_inuse(struct page *page)
84870 {
84871 return page->inuse;
84872 @@ -4364,12 +4445,12 @@ static void resiliency_test(void)
84873 validate_slab_cache(kmalloc_caches[9]);
84874 }
84875 #else
84876 -#ifdef CONFIG_SYSFS
84877 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84878 static void resiliency_test(void) {};
84879 #endif
84880 #endif
84881
84882 -#ifdef CONFIG_SYSFS
84883 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84884 enum slab_stat_type {
84885 SL_ALL, /* All slabs */
84886 SL_PARTIAL, /* Only partially allocated slabs */
84887 @@ -4613,7 +4694,7 @@ SLAB_ATTR_RO(ctor);
84888
84889 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
84890 {
84891 - return sprintf(buf, "%d\n", s->refcount - 1);
84892 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
84893 }
84894 SLAB_ATTR_RO(aliases);
84895
84896 @@ -5266,6 +5347,7 @@ static char *create_unique_id(struct kmem_cache *s)
84897 return name;
84898 }
84899
84900 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84901 static int sysfs_slab_add(struct kmem_cache *s)
84902 {
84903 int err;
84904 @@ -5323,6 +5405,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
84905 kobject_del(&s->kobj);
84906 kobject_put(&s->kobj);
84907 }
84908 +#endif
84909
84910 /*
84911 * Need to buffer aliases during bootup until sysfs becomes
84912 @@ -5336,6 +5419,7 @@ struct saved_alias {
84913
84914 static struct saved_alias *alias_list;
84915
84916 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
84917 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84918 {
84919 struct saved_alias *al;
84920 @@ -5358,6 +5442,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
84921 alias_list = al;
84922 return 0;
84923 }
84924 +#endif
84925
84926 static int __init slab_sysfs_init(void)
84927 {
84928 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
84929 index 1b7e22a..3fcd4f3 100644
84930 --- a/mm/sparse-vmemmap.c
84931 +++ b/mm/sparse-vmemmap.c
84932 @@ -128,7 +128,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
84933 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84934 if (!p)
84935 return NULL;
84936 - pud_populate(&init_mm, pud, p);
84937 + pud_populate_kernel(&init_mm, pud, p);
84938 }
84939 return pud;
84940 }
84941 @@ -140,7 +140,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
84942 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
84943 if (!p)
84944 return NULL;
84945 - pgd_populate(&init_mm, pgd, p);
84946 + pgd_populate_kernel(&init_mm, pgd, p);
84947 }
84948 return pgd;
84949 }
84950 diff --git a/mm/sparse.c b/mm/sparse.c
84951 index 6b5fb76..db0c190 100644
84952 --- a/mm/sparse.c
84953 +++ b/mm/sparse.c
84954 @@ -782,7 +782,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
84955
84956 for (i = 0; i < PAGES_PER_SECTION; i++) {
84957 if (PageHWPoison(&memmap[i])) {
84958 - atomic_long_sub(1, &mce_bad_pages);
84959 + atomic_long_sub_unchecked(1, &mce_bad_pages);
84960 ClearPageHWPoison(&memmap[i]);
84961 }
84962 }
84963 diff --git a/mm/swap.c b/mm/swap.c
84964 index 6310dc2..3662b3f 100644
84965 --- a/mm/swap.c
84966 +++ b/mm/swap.c
84967 @@ -30,6 +30,7 @@
84968 #include <linux/backing-dev.h>
84969 #include <linux/memcontrol.h>
84970 #include <linux/gfp.h>
84971 +#include <linux/hugetlb.h>
84972
84973 #include "internal.h"
84974
84975 @@ -72,6 +73,8 @@ static void __put_compound_page(struct page *page)
84976
84977 __page_cache_release(page);
84978 dtor = get_compound_page_dtor(page);
84979 + if (!PageHuge(page))
84980 + BUG_ON(dtor != free_compound_page);
84981 (*dtor)(page);
84982 }
84983
84984 diff --git a/mm/swapfile.c b/mm/swapfile.c
84985 index e97a0e5..b50e796 100644
84986 --- a/mm/swapfile.c
84987 +++ b/mm/swapfile.c
84988 @@ -64,7 +64,7 @@ static DEFINE_MUTEX(swapon_mutex);
84989
84990 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
84991 /* Activity counter to indicate that a swapon or swapoff has occurred */
84992 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
84993 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
84994
84995 static inline unsigned char swap_count(unsigned char ent)
84996 {
84997 @@ -1608,7 +1608,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
84998 }
84999 filp_close(swap_file, NULL);
85000 err = 0;
85001 - atomic_inc(&proc_poll_event);
85002 + atomic_inc_unchecked(&proc_poll_event);
85003 wake_up_interruptible(&proc_poll_wait);
85004
85005 out_dput:
85006 @@ -1625,8 +1625,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85007
85008 poll_wait(file, &proc_poll_wait, wait);
85009
85010 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85011 - seq->poll_event = atomic_read(&proc_poll_event);
85012 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85013 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85014 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85015 }
85016
85017 @@ -1724,7 +1724,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85018 return ret;
85019
85020 seq = file->private_data;
85021 - seq->poll_event = atomic_read(&proc_poll_event);
85022 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85023 return 0;
85024 }
85025
85026 @@ -2066,7 +2066,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85027 (frontswap_map) ? "FS" : "");
85028
85029 mutex_unlock(&swapon_mutex);
85030 - atomic_inc(&proc_poll_event);
85031 + atomic_inc_unchecked(&proc_poll_event);
85032 wake_up_interruptible(&proc_poll_wait);
85033
85034 if (S_ISREG(inode->i_mode))
85035 diff --git a/mm/util.c b/mm/util.c
85036 index c55e26b..3f913a9 100644
85037 --- a/mm/util.c
85038 +++ b/mm/util.c
85039 @@ -292,6 +292,12 @@ done:
85040 void arch_pick_mmap_layout(struct mm_struct *mm)
85041 {
85042 mm->mmap_base = TASK_UNMAPPED_BASE;
85043 +
85044 +#ifdef CONFIG_PAX_RANDMMAP
85045 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85046 + mm->mmap_base += mm->delta_mmap;
85047 +#endif
85048 +
85049 mm->get_unmapped_area = arch_get_unmapped_area;
85050 mm->unmap_area = arch_unmap_area;
85051 }
85052 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85053 index 5123a16..f234a48 100644
85054 --- a/mm/vmalloc.c
85055 +++ b/mm/vmalloc.c
85056 @@ -39,8 +39,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85057
85058 pte = pte_offset_kernel(pmd, addr);
85059 do {
85060 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85061 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85062 +
85063 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85064 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85065 + BUG_ON(!pte_exec(*pte));
85066 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85067 + continue;
85068 + }
85069 +#endif
85070 +
85071 + {
85072 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85073 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85074 + }
85075 } while (pte++, addr += PAGE_SIZE, addr != end);
85076 }
85077
85078 @@ -100,16 +111,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85079 pte = pte_alloc_kernel(pmd, addr);
85080 if (!pte)
85081 return -ENOMEM;
85082 +
85083 + pax_open_kernel();
85084 do {
85085 struct page *page = pages[*nr];
85086
85087 - if (WARN_ON(!pte_none(*pte)))
85088 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85089 + if (pgprot_val(prot) & _PAGE_NX)
85090 +#endif
85091 +
85092 + if (!pte_none(*pte)) {
85093 + pax_close_kernel();
85094 + WARN_ON(1);
85095 return -EBUSY;
85096 - if (WARN_ON(!page))
85097 + }
85098 + if (!page) {
85099 + pax_close_kernel();
85100 + WARN_ON(1);
85101 return -ENOMEM;
85102 + }
85103 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85104 (*nr)++;
85105 } while (pte++, addr += PAGE_SIZE, addr != end);
85106 + pax_close_kernel();
85107 return 0;
85108 }
85109
85110 @@ -119,7 +143,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85111 pmd_t *pmd;
85112 unsigned long next;
85113
85114 - pmd = pmd_alloc(&init_mm, pud, addr);
85115 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85116 if (!pmd)
85117 return -ENOMEM;
85118 do {
85119 @@ -136,7 +160,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85120 pud_t *pud;
85121 unsigned long next;
85122
85123 - pud = pud_alloc(&init_mm, pgd, addr);
85124 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85125 if (!pud)
85126 return -ENOMEM;
85127 do {
85128 @@ -191,11 +215,20 @@ int is_vmalloc_or_module_addr(const void *x)
85129 * and fall back on vmalloc() if that fails. Others
85130 * just put it in the vmalloc space.
85131 */
85132 -#if defined(CONFIG_MODULES) && defined(MODULES_VADDR)
85133 +#ifdef CONFIG_MODULES
85134 +#ifdef MODULES_VADDR
85135 unsigned long addr = (unsigned long)x;
85136 if (addr >= MODULES_VADDR && addr < MODULES_END)
85137 return 1;
85138 #endif
85139 +
85140 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85141 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85142 + return 1;
85143 +#endif
85144 +
85145 +#endif
85146 +
85147 return is_vmalloc_addr(x);
85148 }
85149
85150 @@ -216,8 +249,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85151
85152 if (!pgd_none(*pgd)) {
85153 pud_t *pud = pud_offset(pgd, addr);
85154 +#ifdef CONFIG_X86
85155 + if (!pud_large(*pud))
85156 +#endif
85157 if (!pud_none(*pud)) {
85158 pmd_t *pmd = pmd_offset(pud, addr);
85159 +#ifdef CONFIG_X86
85160 + if (!pmd_large(*pmd))
85161 +#endif
85162 if (!pmd_none(*pmd)) {
85163 pte_t *ptep, pte;
85164
85165 @@ -329,7 +368,7 @@ static void purge_vmap_area_lazy(void);
85166 * Allocate a region of KVA of the specified size and alignment, within the
85167 * vstart and vend.
85168 */
85169 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85170 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85171 unsigned long align,
85172 unsigned long vstart, unsigned long vend,
85173 int node, gfp_t gfp_mask)
85174 @@ -1328,6 +1367,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85175 struct vm_struct *area;
85176
85177 BUG_ON(in_interrupt());
85178 +
85179 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85180 + if (flags & VM_KERNEXEC) {
85181 + if (start != VMALLOC_START || end != VMALLOC_END)
85182 + return NULL;
85183 + start = (unsigned long)MODULES_EXEC_VADDR;
85184 + end = (unsigned long)MODULES_EXEC_END;
85185 + }
85186 +#endif
85187 +
85188 if (flags & VM_IOREMAP) {
85189 int bit = fls(size);
85190
85191 @@ -1568,6 +1617,11 @@ void *vmap(struct page **pages, unsigned int count,
85192 if (count > totalram_pages)
85193 return NULL;
85194
85195 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85196 + if (!(pgprot_val(prot) & _PAGE_NX))
85197 + flags |= VM_KERNEXEC;
85198 +#endif
85199 +
85200 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85201 __builtin_return_address(0));
85202 if (!area)
85203 @@ -1669,6 +1723,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85204 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85205 goto fail;
85206
85207 +#if defined(CONFIG_MODULES) && defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85208 + if (!(pgprot_val(prot) & _PAGE_NX))
85209 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85210 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85211 + else
85212 +#endif
85213 +
85214 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85215 start, end, node, gfp_mask, caller);
85216 if (!area)
85217 @@ -1842,10 +1903,9 @@ EXPORT_SYMBOL(vzalloc_node);
85218 * For tight control over page level allocator and protection flags
85219 * use __vmalloc() instead.
85220 */
85221 -
85222 void *vmalloc_exec(unsigned long size)
85223 {
85224 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85225 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85226 -1, __builtin_return_address(0));
85227 }
85228
85229 @@ -2136,6 +2196,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85230 unsigned long uaddr = vma->vm_start;
85231 unsigned long usize = vma->vm_end - vma->vm_start;
85232
85233 + BUG_ON(vma->vm_mirror);
85234 +
85235 if ((PAGE_SIZE-1) & (unsigned long)addr)
85236 return -EINVAL;
85237
85238 @@ -2575,7 +2637,11 @@ static int s_show(struct seq_file *m, void *p)
85239 v->addr, v->addr + v->size, v->size);
85240
85241 if (v->caller)
85242 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85243 + seq_printf(m, " %pK", v->caller);
85244 +#else
85245 seq_printf(m, " %pS", v->caller);
85246 +#endif
85247
85248 if (v->nr_pages)
85249 seq_printf(m, " pages=%d", v->nr_pages);
85250 diff --git a/mm/vmstat.c b/mm/vmstat.c
85251 index 9800306..76b4b27 100644
85252 --- a/mm/vmstat.c
85253 +++ b/mm/vmstat.c
85254 @@ -78,7 +78,7 @@ void vm_events_fold_cpu(int cpu)
85255 *
85256 * vm_stat contains the global counters
85257 */
85258 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85259 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85260 EXPORT_SYMBOL(vm_stat);
85261
85262 #ifdef CONFIG_SMP
85263 @@ -454,7 +454,7 @@ void refresh_cpu_vm_stats(int cpu)
85264 v = p->vm_stat_diff[i];
85265 p->vm_stat_diff[i] = 0;
85266 local_irq_restore(flags);
85267 - atomic_long_add(v, &zone->vm_stat[i]);
85268 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85269 global_diff[i] += v;
85270 #ifdef CONFIG_NUMA
85271 /* 3 seconds idle till flush */
85272 @@ -492,7 +492,7 @@ void refresh_cpu_vm_stats(int cpu)
85273
85274 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85275 if (global_diff[i])
85276 - atomic_long_add(global_diff[i], &vm_stat[i]);
85277 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85278 }
85279
85280 void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85281 @@ -503,8 +503,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85282 if (pset->vm_stat_diff[i]) {
85283 int v = pset->vm_stat_diff[i];
85284 pset->vm_stat_diff[i] = 0;
85285 - atomic_long_add(v, &zone->vm_stat[i]);
85286 - atomic_long_add(v, &vm_stat[i]);
85287 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85288 + atomic_long_add_unchecked(v, &vm_stat[i]);
85289 }
85290 }
85291 #endif
85292 @@ -1223,7 +1223,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85293 return NOTIFY_OK;
85294 }
85295
85296 -static struct notifier_block __cpuinitdata vmstat_notifier =
85297 +static struct notifier_block vmstat_notifier =
85298 { &vmstat_cpuup_callback, NULL, 0 };
85299 #endif
85300
85301 @@ -1238,10 +1238,20 @@ static int __init setup_vmstat(void)
85302 start_cpu_timer(cpu);
85303 #endif
85304 #ifdef CONFIG_PROC_FS
85305 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85306 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85307 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85308 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85309 + {
85310 + mode_t gr_mode = S_IRUGO;
85311 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85312 + gr_mode = S_IRUSR;
85313 +#endif
85314 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85315 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85316 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85317 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85318 +#else
85319 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85320 +#endif
85321 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85322 + }
85323 #endif
85324 return 0;
85325 }
85326 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85327 index acc74ad..be02639 100644
85328 --- a/net/8021q/vlan.c
85329 +++ b/net/8021q/vlan.c
85330 @@ -108,6 +108,13 @@ void unregister_vlan_dev(struct net_device *dev, struct list_head *head)
85331 if (vlan_id)
85332 vlan_vid_del(real_dev, vlan_id);
85333
85334 + /* Take it out of our own structures, but be sure to interlock with
85335 + * HW accelerating devices or SW vlan input packet processing if
85336 + * VLAN is not 0 (leave it there for 802.1p).
85337 + */
85338 + if (vlan_id)
85339 + vlan_vid_del(real_dev, vlan_id);
85340 +
85341 /* Get rid of the vlan's reference to real_dev */
85342 dev_put(real_dev);
85343 }
85344 @@ -485,7 +492,7 @@ out:
85345 return NOTIFY_DONE;
85346 }
85347
85348 -static struct notifier_block vlan_notifier_block __read_mostly = {
85349 +static struct notifier_block vlan_notifier_block = {
85350 .notifier_call = vlan_device_event,
85351 };
85352
85353 @@ -560,8 +567,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85354 err = -EPERM;
85355 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85356 break;
85357 - if ((args.u.name_type >= 0) &&
85358 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85359 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85360 struct vlan_net *vn;
85361
85362 vn = net_generic(net, vlan_net_id);
85363 diff --git a/net/9p/mod.c b/net/9p/mod.c
85364 index 6ab36ae..6f1841b 100644
85365 --- a/net/9p/mod.c
85366 +++ b/net/9p/mod.c
85367 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85368 void v9fs_register_trans(struct p9_trans_module *m)
85369 {
85370 spin_lock(&v9fs_trans_lock);
85371 - list_add_tail(&m->list, &v9fs_trans_list);
85372 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85373 spin_unlock(&v9fs_trans_lock);
85374 }
85375 EXPORT_SYMBOL(v9fs_register_trans);
85376 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85377 void v9fs_unregister_trans(struct p9_trans_module *m)
85378 {
85379 spin_lock(&v9fs_trans_lock);
85380 - list_del_init(&m->list);
85381 + pax_list_del_init((struct list_head *)&m->list);
85382 spin_unlock(&v9fs_trans_lock);
85383 }
85384 EXPORT_SYMBOL(v9fs_unregister_trans);
85385 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85386 index 02efb25..41541a9 100644
85387 --- a/net/9p/trans_fd.c
85388 +++ b/net/9p/trans_fd.c
85389 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85390 oldfs = get_fs();
85391 set_fs(get_ds());
85392 /* The cast to a user pointer is valid due to the set_fs() */
85393 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85394 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85395 set_fs(oldfs);
85396
85397 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85398 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85399 index 876fbe8..8bbea9f 100644
85400 --- a/net/atm/atm_misc.c
85401 +++ b/net/atm/atm_misc.c
85402 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85403 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85404 return 1;
85405 atm_return(vcc, truesize);
85406 - atomic_inc(&vcc->stats->rx_drop);
85407 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85408 return 0;
85409 }
85410 EXPORT_SYMBOL(atm_charge);
85411 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85412 }
85413 }
85414 atm_return(vcc, guess);
85415 - atomic_inc(&vcc->stats->rx_drop);
85416 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85417 return NULL;
85418 }
85419 EXPORT_SYMBOL(atm_alloc_charge);
85420 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85421
85422 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85423 {
85424 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85425 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85426 __SONET_ITEMS
85427 #undef __HANDLE_ITEM
85428 }
85429 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85430
85431 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85432 {
85433 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85434 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85435 __SONET_ITEMS
85436 #undef __HANDLE_ITEM
85437 }
85438 diff --git a/net/atm/lec.h b/net/atm/lec.h
85439 index a86aff9..3a0d6f6 100644
85440 --- a/net/atm/lec.h
85441 +++ b/net/atm/lec.h
85442 @@ -48,7 +48,7 @@ struct lane2_ops {
85443 const u8 *tlvs, u32 sizeoftlvs);
85444 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85445 const u8 *tlvs, u32 sizeoftlvs);
85446 -};
85447 +} __no_const;
85448
85449 /*
85450 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85451 diff --git a/net/atm/proc.c b/net/atm/proc.c
85452 index 0d020de..011c7bb 100644
85453 --- a/net/atm/proc.c
85454 +++ b/net/atm/proc.c
85455 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85456 const struct k_atm_aal_stats *stats)
85457 {
85458 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85459 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85460 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85461 - atomic_read(&stats->rx_drop));
85462 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85463 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85464 + atomic_read_unchecked(&stats->rx_drop));
85465 }
85466
85467 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85468 diff --git a/net/atm/resources.c b/net/atm/resources.c
85469 index 0447d5d..3cf4728 100644
85470 --- a/net/atm/resources.c
85471 +++ b/net/atm/resources.c
85472 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85473 static void copy_aal_stats(struct k_atm_aal_stats *from,
85474 struct atm_aal_stats *to)
85475 {
85476 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85477 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85478 __AAL_STAT_ITEMS
85479 #undef __HANDLE_ITEM
85480 }
85481 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85482 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85483 struct atm_aal_stats *to)
85484 {
85485 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85486 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85487 __AAL_STAT_ITEMS
85488 #undef __HANDLE_ITEM
85489 }
85490 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85491 index d5744b7..506bae3 100644
85492 --- a/net/ax25/sysctl_net_ax25.c
85493 +++ b/net/ax25/sysctl_net_ax25.c
85494 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85495 {
85496 char path[sizeof("net/ax25/") + IFNAMSIZ];
85497 int k;
85498 - struct ctl_table *table;
85499 + ctl_table_no_const *table;
85500
85501 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85502 if (!table)
85503 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85504 index 1ee94d0..14beea2 100644
85505 --- a/net/batman-adv/bat_iv_ogm.c
85506 +++ b/net/batman-adv/bat_iv_ogm.c
85507 @@ -63,7 +63,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85508
85509 /* randomize initial seqno to avoid collision */
85510 get_random_bytes(&random_seqno, sizeof(random_seqno));
85511 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85512 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85513
85514 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85515 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85516 @@ -615,9 +615,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85517 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85518
85519 /* change sequence number to network order */
85520 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85521 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85522 batadv_ogm_packet->seqno = htonl(seqno);
85523 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85524 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85525
85526 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85527 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85528 @@ -1022,7 +1022,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85529 return;
85530
85531 /* could be changed by schedule_own_packet() */
85532 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85533 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85534
85535 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85536 has_directlink_flag = 1;
85537 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85538 index f1d37cd..4190879 100644
85539 --- a/net/batman-adv/hard-interface.c
85540 +++ b/net/batman-adv/hard-interface.c
85541 @@ -370,7 +370,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85542 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85543 dev_add_pack(&hard_iface->batman_adv_ptype);
85544
85545 - atomic_set(&hard_iface->frag_seqno, 1);
85546 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85547 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85548 hard_iface->net_dev->name);
85549
85550 @@ -493,7 +493,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85551 /* This can't be called via a bat_priv callback because
85552 * we have no bat_priv yet.
85553 */
85554 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85555 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85556 hard_iface->bat_iv.ogm_buff = NULL;
85557
85558 return hard_iface;
85559 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85560 index 6b548fd..fc32c8d 100644
85561 --- a/net/batman-adv/soft-interface.c
85562 +++ b/net/batman-adv/soft-interface.c
85563 @@ -252,7 +252,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85564 primary_if->net_dev->dev_addr, ETH_ALEN);
85565
85566 /* set broadcast sequence number */
85567 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85568 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85569 bcast_packet->seqno = htonl(seqno);
85570
85571 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85572 @@ -497,7 +497,7 @@ struct net_device *batadv_softif_create(const char *name)
85573 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85574
85575 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85576 - atomic_set(&bat_priv->bcast_seqno, 1);
85577 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85578 atomic_set(&bat_priv->tt.vn, 0);
85579 atomic_set(&bat_priv->tt.local_changes, 0);
85580 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85581 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85582 index ae9ac9a..11e0fe7 100644
85583 --- a/net/batman-adv/types.h
85584 +++ b/net/batman-adv/types.h
85585 @@ -48,7 +48,7 @@
85586 struct batadv_hard_iface_bat_iv {
85587 unsigned char *ogm_buff;
85588 int ogm_buff_len;
85589 - atomic_t ogm_seqno;
85590 + atomic_unchecked_t ogm_seqno;
85591 };
85592
85593 struct batadv_hard_iface {
85594 @@ -56,7 +56,7 @@ struct batadv_hard_iface {
85595 int16_t if_num;
85596 char if_status;
85597 struct net_device *net_dev;
85598 - atomic_t frag_seqno;
85599 + atomic_unchecked_t frag_seqno;
85600 struct kobject *hardif_obj;
85601 atomic_t refcount;
85602 struct packet_type batman_adv_ptype;
85603 @@ -284,7 +284,7 @@ struct batadv_priv {
85604 atomic_t orig_interval; /* uint */
85605 atomic_t hop_penalty; /* uint */
85606 atomic_t log_level; /* uint */
85607 - atomic_t bcast_seqno;
85608 + atomic_unchecked_t bcast_seqno;
85609 atomic_t bcast_queue_left;
85610 atomic_t batman_queue_left;
85611 char num_ifaces;
85612 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85613 index 10aff49..ea8e021 100644
85614 --- a/net/batman-adv/unicast.c
85615 +++ b/net/batman-adv/unicast.c
85616 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85617 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85618 frag2->flags = large_tail;
85619
85620 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85621 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85622 frag1->seqno = htons(seqno - 1);
85623 frag2->seqno = htons(seqno);
85624
85625 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85626 index 07f0739..3c42e34 100644
85627 --- a/net/bluetooth/hci_sock.c
85628 +++ b/net/bluetooth/hci_sock.c
85629 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
85630 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
85631 }
85632
85633 - len = min_t(unsigned int, len, sizeof(uf));
85634 + len = min((size_t)len, sizeof(uf));
85635 if (copy_from_user(&uf, optval, len)) {
85636 err = -EFAULT;
85637 break;
85638 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
85639 index 22e6583..426e2f3 100644
85640 --- a/net/bluetooth/l2cap_core.c
85641 +++ b/net/bluetooth/l2cap_core.c
85642 @@ -3400,8 +3400,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
85643 break;
85644
85645 case L2CAP_CONF_RFC:
85646 - if (olen == sizeof(rfc))
85647 - memcpy(&rfc, (void *)val, olen);
85648 + if (olen != sizeof(rfc))
85649 + break;
85650 +
85651 + memcpy(&rfc, (void *)val, olen);
85652
85653 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
85654 rfc.mode != chan->mode)
85655 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
85656 index 1bcfb84..dad9f98 100644
85657 --- a/net/bluetooth/l2cap_sock.c
85658 +++ b/net/bluetooth/l2cap_sock.c
85659 @@ -479,7 +479,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85660 struct sock *sk = sock->sk;
85661 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
85662 struct l2cap_options opts;
85663 - int len, err = 0;
85664 + int err = 0;
85665 + size_t len = optlen;
85666 u32 opt;
85667
85668 BT_DBG("sk %p", sk);
85669 @@ -501,7 +502,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
85670 opts.max_tx = chan->max_tx;
85671 opts.txwin_size = chan->tx_win;
85672
85673 - len = min_t(unsigned int, sizeof(opts), optlen);
85674 + len = min(sizeof(opts), len);
85675 if (copy_from_user((char *) &opts, optval, len)) {
85676 err = -EFAULT;
85677 break;
85678 @@ -581,7 +582,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85679 struct bt_security sec;
85680 struct bt_power pwr;
85681 struct l2cap_conn *conn;
85682 - int len, err = 0;
85683 + int err = 0;
85684 + size_t len = optlen;
85685 u32 opt;
85686
85687 BT_DBG("sk %p", sk);
85688 @@ -604,7 +606,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85689
85690 sec.level = BT_SECURITY_LOW;
85691
85692 - len = min_t(unsigned int, sizeof(sec), optlen);
85693 + len = min(sizeof(sec), len);
85694 if (copy_from_user((char *) &sec, optval, len)) {
85695 err = -EFAULT;
85696 break;
85697 @@ -701,7 +703,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
85698
85699 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
85700
85701 - len = min_t(unsigned int, sizeof(pwr), optlen);
85702 + len = min(sizeof(pwr), len);
85703 if (copy_from_user((char *) &pwr, optval, len)) {
85704 err = -EFAULT;
85705 break;
85706 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
85707 index ce3f665..2c7d08f 100644
85708 --- a/net/bluetooth/rfcomm/sock.c
85709 +++ b/net/bluetooth/rfcomm/sock.c
85710 @@ -667,7 +667,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85711 struct sock *sk = sock->sk;
85712 struct bt_security sec;
85713 int err = 0;
85714 - size_t len;
85715 + size_t len = optlen;
85716 u32 opt;
85717
85718 BT_DBG("sk %p", sk);
85719 @@ -689,7 +689,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
85720
85721 sec.level = BT_SECURITY_LOW;
85722
85723 - len = min_t(unsigned int, sizeof(sec), optlen);
85724 + len = min(sizeof(sec), len);
85725 if (copy_from_user((char *) &sec, optval, len)) {
85726 err = -EFAULT;
85727 break;
85728 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
85729 index bd6fd0f..6492cba 100644
85730 --- a/net/bluetooth/rfcomm/tty.c
85731 +++ b/net/bluetooth/rfcomm/tty.c
85732 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
85733 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
85734
85735 spin_lock_irqsave(&dev->port.lock, flags);
85736 - if (dev->port.count > 0) {
85737 + if (atomic_read(&dev->port.count) > 0) {
85738 spin_unlock_irqrestore(&dev->port.lock, flags);
85739 return;
85740 }
85741 @@ -664,10 +664,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
85742 return -ENODEV;
85743
85744 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
85745 - dev->channel, dev->port.count);
85746 + dev->channel, atomic_read(&dev->port.count));
85747
85748 spin_lock_irqsave(&dev->port.lock, flags);
85749 - if (++dev->port.count > 1) {
85750 + if (atomic_inc_return(&dev->port.count) > 1) {
85751 spin_unlock_irqrestore(&dev->port.lock, flags);
85752 return 0;
85753 }
85754 @@ -732,10 +732,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
85755 return;
85756
85757 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
85758 - dev->port.count);
85759 + atomic_read(&dev->port.count));
85760
85761 spin_lock_irqsave(&dev->port.lock, flags);
85762 - if (!--dev->port.count) {
85763 + if (!atomic_dec_return(&dev->port.count)) {
85764 spin_unlock_irqrestore(&dev->port.lock, flags);
85765 if (dev->tty_dev->parent)
85766 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
85767 diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
85768 index d9576e6..85f4f4e 100644
85769 --- a/net/bridge/br_fdb.c
85770 +++ b/net/bridge/br_fdb.c
85771 @@ -386,7 +386,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
85772 return 0;
85773 br_warn(br, "adding interface %s with same address "
85774 "as a received packet\n",
85775 - source->dev->name);
85776 + source ? source->dev->name : br->dev->name);
85777 fdb_delete(br, fdb);
85778 }
85779
85780 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
85781 index 5fe2ff3..121d696 100644
85782 --- a/net/bridge/netfilter/ebtables.c
85783 +++ b/net/bridge/netfilter/ebtables.c
85784 @@ -1523,7 +1523,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
85785 tmp.valid_hooks = t->table->valid_hooks;
85786 }
85787 mutex_unlock(&ebt_mutex);
85788 - if (copy_to_user(user, &tmp, *len) != 0){
85789 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
85790 BUGPRINT("c2u Didn't work\n");
85791 ret = -EFAULT;
85792 break;
85793 @@ -2327,7 +2327,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85794 goto out;
85795 tmp.valid_hooks = t->valid_hooks;
85796
85797 - if (copy_to_user(user, &tmp, *len) != 0) {
85798 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85799 ret = -EFAULT;
85800 break;
85801 }
85802 @@ -2338,7 +2338,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
85803 tmp.entries_size = t->table->entries_size;
85804 tmp.valid_hooks = t->table->valid_hooks;
85805
85806 - if (copy_to_user(user, &tmp, *len) != 0) {
85807 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
85808 ret = -EFAULT;
85809 break;
85810 }
85811 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
85812 index a376ec1..1fbd6be 100644
85813 --- a/net/caif/cfctrl.c
85814 +++ b/net/caif/cfctrl.c
85815 @@ -10,6 +10,7 @@
85816 #include <linux/spinlock.h>
85817 #include <linux/slab.h>
85818 #include <linux/pkt_sched.h>
85819 +#include <linux/sched.h>
85820 #include <net/caif/caif_layer.h>
85821 #include <net/caif/cfpkt.h>
85822 #include <net/caif/cfctrl.h>
85823 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
85824 memset(&dev_info, 0, sizeof(dev_info));
85825 dev_info.id = 0xff;
85826 cfsrvl_init(&this->serv, 0, &dev_info, false);
85827 - atomic_set(&this->req_seq_no, 1);
85828 - atomic_set(&this->rsp_seq_no, 1);
85829 + atomic_set_unchecked(&this->req_seq_no, 1);
85830 + atomic_set_unchecked(&this->rsp_seq_no, 1);
85831 this->serv.layer.receive = cfctrl_recv;
85832 sprintf(this->serv.layer.name, "ctrl");
85833 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
85834 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
85835 struct cfctrl_request_info *req)
85836 {
85837 spin_lock_bh(&ctrl->info_list_lock);
85838 - atomic_inc(&ctrl->req_seq_no);
85839 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
85840 + atomic_inc_unchecked(&ctrl->req_seq_no);
85841 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
85842 list_add_tail(&req->list, &ctrl->list);
85843 spin_unlock_bh(&ctrl->info_list_lock);
85844 }
85845 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
85846 if (p != first)
85847 pr_warn("Requests are not received in order\n");
85848
85849 - atomic_set(&ctrl->rsp_seq_no,
85850 + atomic_set_unchecked(&ctrl->rsp_seq_no,
85851 p->sequence_no);
85852 list_del(&p->list);
85853 goto out;
85854 diff --git a/net/can/af_can.c b/net/can/af_can.c
85855 index ddac1ee..3ee0a78 100644
85856 --- a/net/can/af_can.c
85857 +++ b/net/can/af_can.c
85858 @@ -872,7 +872,7 @@ static const struct net_proto_family can_family_ops = {
85859 };
85860
85861 /* notifier block for netdevice event */
85862 -static struct notifier_block can_netdev_notifier __read_mostly = {
85863 +static struct notifier_block can_netdev_notifier = {
85864 .notifier_call = can_notifier,
85865 };
85866
85867 diff --git a/net/can/gw.c b/net/can/gw.c
85868 index 28e7bdc..d42c4cd 100644
85869 --- a/net/can/gw.c
85870 +++ b/net/can/gw.c
85871 @@ -67,7 +67,6 @@ MODULE_AUTHOR("Oliver Hartkopp <oliver.hartkopp@volkswagen.de>");
85872 MODULE_ALIAS("can-gw");
85873
85874 static HLIST_HEAD(cgw_list);
85875 -static struct notifier_block notifier;
85876
85877 static struct kmem_cache *cgw_cache __read_mostly;
85878
85879 @@ -893,6 +892,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
85880 return err;
85881 }
85882
85883 +static struct notifier_block notifier = {
85884 + .notifier_call = cgw_notifier
85885 +};
85886 +
85887 static __init int cgw_module_init(void)
85888 {
85889 printk(banner);
85890 @@ -904,7 +907,6 @@ static __init int cgw_module_init(void)
85891 return -ENOMEM;
85892
85893 /* set notifier */
85894 - notifier.notifier_call = cgw_notifier;
85895 register_netdevice_notifier(&notifier);
85896
85897 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
85898 diff --git a/net/compat.c b/net/compat.c
85899 index 79ae884..17c5c09 100644
85900 --- a/net/compat.c
85901 +++ b/net/compat.c
85902 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
85903 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
85904 __get_user(kmsg->msg_flags, &umsg->msg_flags))
85905 return -EFAULT;
85906 - kmsg->msg_name = compat_ptr(tmp1);
85907 - kmsg->msg_iov = compat_ptr(tmp2);
85908 - kmsg->msg_control = compat_ptr(tmp3);
85909 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
85910 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
85911 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
85912 return 0;
85913 }
85914
85915 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85916
85917 if (kern_msg->msg_namelen) {
85918 if (mode == VERIFY_READ) {
85919 - int err = move_addr_to_kernel(kern_msg->msg_name,
85920 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
85921 kern_msg->msg_namelen,
85922 kern_address);
85923 if (err < 0)
85924 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85925 kern_msg->msg_name = NULL;
85926
85927 tot_len = iov_from_user_compat_to_kern(kern_iov,
85928 - (struct compat_iovec __user *)kern_msg->msg_iov,
85929 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
85930 kern_msg->msg_iovlen);
85931 if (tot_len >= 0)
85932 kern_msg->msg_iov = kern_iov;
85933 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
85934
85935 #define CMSG_COMPAT_FIRSTHDR(msg) \
85936 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
85937 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
85938 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
85939 (struct compat_cmsghdr __user *)NULL)
85940
85941 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
85942 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
85943 (ucmlen) <= (unsigned long) \
85944 ((mhdr)->msg_controllen - \
85945 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
85946 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
85947
85948 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
85949 struct compat_cmsghdr __user *cmsg, int cmsg_len)
85950 {
85951 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
85952 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
85953 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
85954 msg->msg_controllen)
85955 return NULL;
85956 return (struct compat_cmsghdr __user *)ptr;
85957 @@ -219,7 +219,7 @@ Efault:
85958
85959 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
85960 {
85961 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85962 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85963 struct compat_cmsghdr cmhdr;
85964 struct compat_timeval ctv;
85965 struct compat_timespec cts[3];
85966 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
85967
85968 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
85969 {
85970 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
85971 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
85972 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
85973 int fdnum = scm->fp->count;
85974 struct file **fp = scm->fp->fp;
85975 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
85976 return -EFAULT;
85977 old_fs = get_fs();
85978 set_fs(KERNEL_DS);
85979 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
85980 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
85981 set_fs(old_fs);
85982
85983 return err;
85984 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
85985 len = sizeof(ktime);
85986 old_fs = get_fs();
85987 set_fs(KERNEL_DS);
85988 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
85989 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
85990 set_fs(old_fs);
85991
85992 if (!err) {
85993 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
85994 case MCAST_JOIN_GROUP:
85995 case MCAST_LEAVE_GROUP:
85996 {
85997 - struct compat_group_req __user *gr32 = (void *)optval;
85998 + struct compat_group_req __user *gr32 = (void __user *)optval;
85999 struct group_req __user *kgr =
86000 compat_alloc_user_space(sizeof(struct group_req));
86001 u32 interface;
86002 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86003 case MCAST_BLOCK_SOURCE:
86004 case MCAST_UNBLOCK_SOURCE:
86005 {
86006 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86007 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86008 struct group_source_req __user *kgsr = compat_alloc_user_space(
86009 sizeof(struct group_source_req));
86010 u32 interface;
86011 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86012 }
86013 case MCAST_MSFILTER:
86014 {
86015 - struct compat_group_filter __user *gf32 = (void *)optval;
86016 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86017 struct group_filter __user *kgf;
86018 u32 interface, fmode, numsrc;
86019
86020 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86021 char __user *optval, int __user *optlen,
86022 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86023 {
86024 - struct compat_group_filter __user *gf32 = (void *)optval;
86025 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86026 struct group_filter __user *kgf;
86027 int __user *koptlen;
86028 u32 interface, fmode, numsrc;
86029 @@ -796,7 +796,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86030
86031 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86032 return -EINVAL;
86033 - if (copy_from_user(a, args, nas[call]))
86034 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86035 return -EFAULT;
86036 a0 = a[0];
86037 a1 = a[1];
86038 diff --git a/net/core/datagram.c b/net/core/datagram.c
86039 index 368f9c3..f82d4a3 100644
86040 --- a/net/core/datagram.c
86041 +++ b/net/core/datagram.c
86042 @@ -289,7 +289,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86043 }
86044
86045 kfree_skb(skb);
86046 - atomic_inc(&sk->sk_drops);
86047 + atomic_inc_unchecked(&sk->sk_drops);
86048 sk_mem_reclaim_partial(sk);
86049
86050 return err;
86051 diff --git a/net/core/dev.c b/net/core/dev.c
86052 index 5d9c43d..b471558 100644
86053 --- a/net/core/dev.c
86054 +++ b/net/core/dev.c
86055 @@ -1250,9 +1250,13 @@ void dev_load(struct net *net, const char *name)
86056 if (no_module && capable(CAP_NET_ADMIN))
86057 no_module = request_module("netdev-%s", name);
86058 if (no_module && capable(CAP_SYS_MODULE)) {
86059 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86060 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86061 +#else
86062 if (!request_module("%s", name))
86063 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86064 name);
86065 +#endif
86066 }
86067 }
86068 EXPORT_SYMBOL(dev_load);
86069 @@ -1714,7 +1718,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86070 {
86071 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86072 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86073 - atomic_long_inc(&dev->rx_dropped);
86074 + atomic_long_inc_unchecked(&dev->rx_dropped);
86075 kfree_skb(skb);
86076 return NET_RX_DROP;
86077 }
86078 @@ -1724,7 +1728,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86079 nf_reset(skb);
86080
86081 if (unlikely(!is_skb_forwardable(dev, skb))) {
86082 - atomic_long_inc(&dev->rx_dropped);
86083 + atomic_long_inc_unchecked(&dev->rx_dropped);
86084 kfree_skb(skb);
86085 return NET_RX_DROP;
86086 }
86087 @@ -2179,7 +2183,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86088
86089 struct dev_gso_cb {
86090 void (*destructor)(struct sk_buff *skb);
86091 -};
86092 +} __no_const;
86093
86094 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86095
86096 @@ -3052,7 +3056,7 @@ enqueue:
86097
86098 local_irq_restore(flags);
86099
86100 - atomic_long_inc(&skb->dev->rx_dropped);
86101 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86102 kfree_skb(skb);
86103 return NET_RX_DROP;
86104 }
86105 @@ -3124,7 +3128,7 @@ int netif_rx_ni(struct sk_buff *skb)
86106 }
86107 EXPORT_SYMBOL(netif_rx_ni);
86108
86109 -static void net_tx_action(struct softirq_action *h)
86110 +static void net_tx_action(void)
86111 {
86112 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86113
86114 @@ -3462,7 +3466,7 @@ ncls:
86115 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86116 } else {
86117 drop:
86118 - atomic_long_inc(&skb->dev->rx_dropped);
86119 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86120 kfree_skb(skb);
86121 /* Jamal, now you will not able to escape explaining
86122 * me how you were going to use this. :-)
86123 @@ -4045,7 +4049,7 @@ void netif_napi_del(struct napi_struct *napi)
86124 }
86125 EXPORT_SYMBOL(netif_napi_del);
86126
86127 -static void net_rx_action(struct softirq_action *h)
86128 +static void net_rx_action(void)
86129 {
86130 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86131 unsigned long time_limit = jiffies + 2;
86132 @@ -4529,8 +4533,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86133 else
86134 seq_printf(seq, "%04x", ntohs(pt->type));
86135
86136 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86137 + seq_printf(seq, " %-8s %p\n",
86138 + pt->dev ? pt->dev->name : "", NULL);
86139 +#else
86140 seq_printf(seq, " %-8s %pF\n",
86141 pt->dev ? pt->dev->name : "", pt->func);
86142 +#endif
86143 }
86144
86145 return 0;
86146 @@ -6102,7 +6111,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86147 } else {
86148 netdev_stats_to_stats64(storage, &dev->stats);
86149 }
86150 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86151 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86152 return storage;
86153 }
86154 EXPORT_SYMBOL(dev_get_stats);
86155 diff --git a/net/core/flow.c b/net/core/flow.c
86156 index 3bad824..2071a55 100644
86157 --- a/net/core/flow.c
86158 +++ b/net/core/flow.c
86159 @@ -61,7 +61,7 @@ struct flow_cache {
86160 struct timer_list rnd_timer;
86161 };
86162
86163 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86164 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86165 EXPORT_SYMBOL(flow_cache_genid);
86166 static struct flow_cache flow_cache_global;
86167 static struct kmem_cache *flow_cachep __read_mostly;
86168 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86169
86170 static int flow_entry_valid(struct flow_cache_entry *fle)
86171 {
86172 - if (atomic_read(&flow_cache_genid) != fle->genid)
86173 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86174 return 0;
86175 if (fle->object && !fle->object->ops->check(fle->object))
86176 return 0;
86177 @@ -259,7 +259,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86178 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86179 fcp->hash_count++;
86180 }
86181 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86182 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86183 flo = fle->object;
86184 if (!flo)
86185 goto ret_object;
86186 @@ -280,7 +280,7 @@ nocache:
86187 }
86188 flo = resolver(net, key, family, dir, flo, ctx);
86189 if (fle) {
86190 - fle->genid = atomic_read(&flow_cache_genid);
86191 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86192 if (!IS_ERR(flo))
86193 fle->object = flo;
86194 else
86195 diff --git a/net/core/iovec.c b/net/core/iovec.c
86196 index 7e7aeb0..2a998cb 100644
86197 --- a/net/core/iovec.c
86198 +++ b/net/core/iovec.c
86199 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86200 if (m->msg_namelen) {
86201 if (mode == VERIFY_READ) {
86202 void __user *namep;
86203 - namep = (void __user __force *) m->msg_name;
86204 + namep = (void __force_user *) m->msg_name;
86205 err = move_addr_to_kernel(namep, m->msg_namelen,
86206 address);
86207 if (err < 0)
86208 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86209 }
86210
86211 size = m->msg_iovlen * sizeof(struct iovec);
86212 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86213 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86214 return -EFAULT;
86215
86216 m->msg_iov = iov;
86217 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86218 index c815f28..e6403f2 100644
86219 --- a/net/core/neighbour.c
86220 +++ b/net/core/neighbour.c
86221 @@ -2776,7 +2776,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86222 size_t *lenp, loff_t *ppos)
86223 {
86224 int size, ret;
86225 - ctl_table tmp = *ctl;
86226 + ctl_table_no_const tmp = *ctl;
86227
86228 tmp.extra1 = &zero;
86229 tmp.extra2 = &unres_qlen_max;
86230 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86231 index 28c5f5a..7edf2e2 100644
86232 --- a/net/core/net-sysfs.c
86233 +++ b/net/core/net-sysfs.c
86234 @@ -1455,7 +1455,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86235 }
86236 EXPORT_SYMBOL(netdev_class_remove_file);
86237
86238 -int netdev_kobject_init(void)
86239 +int __init netdev_kobject_init(void)
86240 {
86241 kobj_ns_type_register(&net_ns_type_operations);
86242 return class_register(&net_class);
86243 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86244 index 8acce01..2e306bb 100644
86245 --- a/net/core/net_namespace.c
86246 +++ b/net/core/net_namespace.c
86247 @@ -442,7 +442,7 @@ static int __register_pernet_operations(struct list_head *list,
86248 int error;
86249 LIST_HEAD(net_exit_list);
86250
86251 - list_add_tail(&ops->list, list);
86252 + pax_list_add_tail((struct list_head *)&ops->list, list);
86253 if (ops->init || (ops->id && ops->size)) {
86254 for_each_net(net) {
86255 error = ops_init(ops, net);
86256 @@ -455,7 +455,7 @@ static int __register_pernet_operations(struct list_head *list,
86257
86258 out_undo:
86259 /* If I have an error cleanup all namespaces I initialized */
86260 - list_del(&ops->list);
86261 + pax_list_del((struct list_head *)&ops->list);
86262 ops_exit_list(ops, &net_exit_list);
86263 ops_free_list(ops, &net_exit_list);
86264 return error;
86265 @@ -466,7 +466,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86266 struct net *net;
86267 LIST_HEAD(net_exit_list);
86268
86269 - list_del(&ops->list);
86270 + pax_list_del((struct list_head *)&ops->list);
86271 for_each_net(net)
86272 list_add_tail(&net->exit_list, &net_exit_list);
86273 ops_exit_list(ops, &net_exit_list);
86274 @@ -600,7 +600,7 @@ int register_pernet_device(struct pernet_operations *ops)
86275 mutex_lock(&net_mutex);
86276 error = register_pernet_operations(&pernet_list, ops);
86277 if (!error && (first_device == &pernet_list))
86278 - first_device = &ops->list;
86279 + first_device = (struct list_head *)&ops->list;
86280 mutex_unlock(&net_mutex);
86281 return error;
86282 }
86283 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86284 index 6212ec9..5ee16b2 100644
86285 --- a/net/core/rtnetlink.c
86286 +++ b/net/core/rtnetlink.c
86287 @@ -58,7 +58,7 @@ struct rtnl_link {
86288 rtnl_doit_func doit;
86289 rtnl_dumpit_func dumpit;
86290 rtnl_calcit_func calcit;
86291 -};
86292 +} __no_const;
86293
86294 static DEFINE_MUTEX(rtnl_mutex);
86295
86296 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86297 if (rtnl_link_ops_get(ops->kind))
86298 return -EEXIST;
86299
86300 - if (!ops->dellink)
86301 - ops->dellink = unregister_netdevice_queue;
86302 + if (!ops->dellink) {
86303 + pax_open_kernel();
86304 + *(void **)&ops->dellink = unregister_netdevice_queue;
86305 + pax_close_kernel();
86306 + }
86307
86308 - list_add_tail(&ops->list, &link_ops);
86309 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86310 return 0;
86311 }
86312 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86313 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86314 for_each_net(net) {
86315 __rtnl_kill_links(net, ops);
86316 }
86317 - list_del(&ops->list);
86318 + pax_list_del((struct list_head *)&ops->list);
86319 }
86320 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86321
86322 @@ -1068,7 +1071,7 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
86323 rcu_read_lock();
86324 cb->seq = net->dev_base_seq;
86325
86326 - if (nlmsg_parse(cb->nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86327 + if (nlmsg_parse(cb->nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86328 ifla_policy) >= 0) {
86329
86330 if (tb[IFLA_EXT_MASK])
86331 @@ -1924,7 +1927,7 @@ static u16 rtnl_calcit(struct sk_buff *skb, struct nlmsghdr *nlh)
86332 u32 ext_filter_mask = 0;
86333 u16 min_ifinfo_dump_size = 0;
86334
86335 - if (nlmsg_parse(nlh, sizeof(struct rtgenmsg), tb, IFLA_MAX,
86336 + if (nlmsg_parse(nlh, sizeof(struct ifinfomsg), tb, IFLA_MAX,
86337 ifla_policy) >= 0) {
86338 if (tb[IFLA_EXT_MASK])
86339 ext_filter_mask = nla_get_u32(tb[IFLA_EXT_MASK]);
86340 diff --git a/net/core/scm.c b/net/core/scm.c
86341 index 2dc6cda..2159524 100644
86342 --- a/net/core/scm.c
86343 +++ b/net/core/scm.c
86344 @@ -226,7 +226,7 @@ EXPORT_SYMBOL(__scm_send);
86345 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86346 {
86347 struct cmsghdr __user *cm
86348 - = (__force struct cmsghdr __user *)msg->msg_control;
86349 + = (struct cmsghdr __force_user *)msg->msg_control;
86350 struct cmsghdr cmhdr;
86351 int cmlen = CMSG_LEN(len);
86352 int err;
86353 @@ -249,7 +249,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86354 err = -EFAULT;
86355 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86356 goto out;
86357 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86358 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86359 goto out;
86360 cmlen = CMSG_SPACE(len);
86361 if (msg->msg_controllen < cmlen)
86362 @@ -265,7 +265,7 @@ EXPORT_SYMBOL(put_cmsg);
86363 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86364 {
86365 struct cmsghdr __user *cm
86366 - = (__force struct cmsghdr __user*)msg->msg_control;
86367 + = (struct cmsghdr __force_user *)msg->msg_control;
86368
86369 int fdmax = 0;
86370 int fdnum = scm->fp->count;
86371 @@ -285,7 +285,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86372 if (fdnum < fdmax)
86373 fdmax = fdnum;
86374
86375 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86376 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86377 i++, cmfptr++)
86378 {
86379 struct socket *sock;
86380 diff --git a/net/core/sock.c b/net/core/sock.c
86381 index bc131d4..029e378 100644
86382 --- a/net/core/sock.c
86383 +++ b/net/core/sock.c
86384 @@ -388,7 +388,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86385 struct sk_buff_head *list = &sk->sk_receive_queue;
86386
86387 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86388 - atomic_inc(&sk->sk_drops);
86389 + atomic_inc_unchecked(&sk->sk_drops);
86390 trace_sock_rcvqueue_full(sk, skb);
86391 return -ENOMEM;
86392 }
86393 @@ -398,7 +398,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86394 return err;
86395
86396 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86397 - atomic_inc(&sk->sk_drops);
86398 + atomic_inc_unchecked(&sk->sk_drops);
86399 return -ENOBUFS;
86400 }
86401
86402 @@ -418,7 +418,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86403 skb_dst_force(skb);
86404
86405 spin_lock_irqsave(&list->lock, flags);
86406 - skb->dropcount = atomic_read(&sk->sk_drops);
86407 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86408 __skb_queue_tail(list, skb);
86409 spin_unlock_irqrestore(&list->lock, flags);
86410
86411 @@ -438,7 +438,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86412 skb->dev = NULL;
86413
86414 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86415 - atomic_inc(&sk->sk_drops);
86416 + atomic_inc_unchecked(&sk->sk_drops);
86417 goto discard_and_relse;
86418 }
86419 if (nested)
86420 @@ -456,7 +456,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86421 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86422 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86423 bh_unlock_sock(sk);
86424 - atomic_inc(&sk->sk_drops);
86425 + atomic_inc_unchecked(&sk->sk_drops);
86426 goto discard_and_relse;
86427 }
86428
86429 @@ -930,12 +930,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86430 struct timeval tm;
86431 } v;
86432
86433 - int lv = sizeof(int);
86434 - int len;
86435 + unsigned int lv = sizeof(int);
86436 + unsigned int len;
86437
86438 if (get_user(len, optlen))
86439 return -EFAULT;
86440 - if (len < 0)
86441 + if (len > INT_MAX)
86442 return -EINVAL;
86443
86444 memset(&v, 0, sizeof(v));
86445 @@ -1083,11 +1083,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86446
86447 case SO_PEERNAME:
86448 {
86449 - char address[128];
86450 + char address[_K_SS_MAXSIZE];
86451
86452 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86453 return -ENOTCONN;
86454 - if (lv < len)
86455 + if (lv < len || sizeof address < len)
86456 return -EINVAL;
86457 if (copy_to_user(optval, address, len))
86458 return -EFAULT;
86459 @@ -1146,7 +1146,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86460
86461 if (len > lv)
86462 len = lv;
86463 - if (copy_to_user(optval, &v, len))
86464 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86465 return -EFAULT;
86466 lenout:
86467 if (put_user(len, optlen))
86468 @@ -2276,7 +2276,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86469 */
86470 smp_wmb();
86471 atomic_set(&sk->sk_refcnt, 1);
86472 - atomic_set(&sk->sk_drops, 0);
86473 + atomic_set_unchecked(&sk->sk_drops, 0);
86474 }
86475 EXPORT_SYMBOL(sock_init_data);
86476
86477 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86478 index 750f44f..922399c 100644
86479 --- a/net/core/sock_diag.c
86480 +++ b/net/core/sock_diag.c
86481 @@ -9,26 +9,33 @@
86482 #include <linux/inet_diag.h>
86483 #include <linux/sock_diag.h>
86484
86485 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86486 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86487 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86488 static DEFINE_MUTEX(sock_diag_table_mutex);
86489
86490 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86491 {
86492 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86493 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86494 cookie[1] != INET_DIAG_NOCOOKIE) &&
86495 ((u32)(unsigned long)sk != cookie[0] ||
86496 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86497 return -ESTALE;
86498 else
86499 +#endif
86500 return 0;
86501 }
86502 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86503
86504 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86505 {
86506 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86507 + cookie[0] = 0;
86508 + cookie[1] = 0;
86509 +#else
86510 cookie[0] = (u32)(unsigned long)sk;
86511 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86512 +#endif
86513 }
86514 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86515
86516 @@ -75,8 +82,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86517 mutex_lock(&sock_diag_table_mutex);
86518 if (sock_diag_handlers[hndl->family])
86519 err = -EBUSY;
86520 - else
86521 + else {
86522 + pax_open_kernel();
86523 sock_diag_handlers[hndl->family] = hndl;
86524 + pax_close_kernel();
86525 + }
86526 mutex_unlock(&sock_diag_table_mutex);
86527
86528 return err;
86529 @@ -92,26 +102,13 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86530
86531 mutex_lock(&sock_diag_table_mutex);
86532 BUG_ON(sock_diag_handlers[family] != hnld);
86533 + pax_open_kernel();
86534 sock_diag_handlers[family] = NULL;
86535 + pax_close_kernel();
86536 mutex_unlock(&sock_diag_table_mutex);
86537 }
86538 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86539
86540 -static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
86541 -{
86542 - if (sock_diag_handlers[family] == NULL)
86543 - request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86544 - NETLINK_SOCK_DIAG, family);
86545 -
86546 - mutex_lock(&sock_diag_table_mutex);
86547 - return sock_diag_handlers[family];
86548 -}
86549 -
86550 -static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
86551 -{
86552 - mutex_unlock(&sock_diag_table_mutex);
86553 -}
86554 -
86555 static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86556 {
86557 int err;
86558 @@ -124,12 +121,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
86559 if (req->sdiag_family >= AF_MAX)
86560 return -EINVAL;
86561
86562 - hndl = sock_diag_lock_handler(req->sdiag_family);
86563 + if (sock_diag_handlers[req->sdiag_family] == NULL)
86564 + request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
86565 + NETLINK_SOCK_DIAG, req->sdiag_family);
86566 +
86567 + mutex_lock(&sock_diag_table_mutex);
86568 + hndl = sock_diag_handlers[req->sdiag_family];
86569 if (hndl == NULL)
86570 err = -ENOENT;
86571 else
86572 err = hndl->dump(skb, nlh);
86573 - sock_diag_unlock_handler(hndl);
86574 + mutex_unlock(&sock_diag_table_mutex);
86575
86576 return err;
86577 }
86578 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86579 index d1b0804..98cf5f7 100644
86580 --- a/net/core/sysctl_net_core.c
86581 +++ b/net/core/sysctl_net_core.c
86582 @@ -26,7 +26,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86583 {
86584 unsigned int orig_size, size;
86585 int ret, i;
86586 - ctl_table tmp = {
86587 + ctl_table_no_const tmp = {
86588 .data = &size,
86589 .maxlen = sizeof(size),
86590 .mode = table->mode
86591 @@ -205,13 +205,12 @@ static struct ctl_table netns_core_table[] = {
86592
86593 static __net_init int sysctl_core_net_init(struct net *net)
86594 {
86595 - struct ctl_table *tbl;
86596 + ctl_table_no_const *tbl = NULL;
86597
86598 net->core.sysctl_somaxconn = SOMAXCONN;
86599
86600 - tbl = netns_core_table;
86601 if (!net_eq(net, &init_net)) {
86602 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86603 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86604 if (tbl == NULL)
86605 goto err_dup;
86606
86607 @@ -221,17 +220,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86608 if (net->user_ns != &init_user_ns) {
86609 tbl[0].procname = NULL;
86610 }
86611 - }
86612 -
86613 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86614 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86615 + } else
86616 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86617 if (net->core.sysctl_hdr == NULL)
86618 goto err_reg;
86619
86620 return 0;
86621
86622 err_reg:
86623 - if (tbl != netns_core_table)
86624 - kfree(tbl);
86625 + kfree(tbl);
86626 err_dup:
86627 return -ENOMEM;
86628 }
86629 @@ -246,7 +244,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86630 kfree(tbl);
86631 }
86632
86633 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86634 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86635 .init = sysctl_core_net_init,
86636 .exit = sysctl_core_net_exit,
86637 };
86638 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86639 index 307c322..78a4c6f 100644
86640 --- a/net/decnet/af_decnet.c
86641 +++ b/net/decnet/af_decnet.c
86642 @@ -468,6 +468,7 @@ static struct proto dn_proto = {
86643 .sysctl_rmem = sysctl_decnet_rmem,
86644 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86645 .obj_size = sizeof(struct dn_sock),
86646 + .slab_flags = SLAB_USERCOPY,
86647 };
86648
86649 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86650 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86651 index a55eecc..dd8428c 100644
86652 --- a/net/decnet/sysctl_net_decnet.c
86653 +++ b/net/decnet/sysctl_net_decnet.c
86654 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86655
86656 if (len > *lenp) len = *lenp;
86657
86658 - if (copy_to_user(buffer, addr, len))
86659 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86660 return -EFAULT;
86661
86662 *lenp = len;
86663 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86664
86665 if (len > *lenp) len = *lenp;
86666
86667 - if (copy_to_user(buffer, devname, len))
86668 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86669 return -EFAULT;
86670
86671 *lenp = len;
86672 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86673 index fcf104e..95552d4 100644
86674 --- a/net/ipv4/af_inet.c
86675 +++ b/net/ipv4/af_inet.c
86676 @@ -1717,13 +1717,9 @@ static int __init inet_init(void)
86677
86678 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > sizeof(dummy_skb->cb));
86679
86680 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86681 - if (!sysctl_local_reserved_ports)
86682 - goto out;
86683 -
86684 rc = proto_register(&tcp_prot, 1);
86685 if (rc)
86686 - goto out_free_reserved_ports;
86687 + goto out;
86688
86689 rc = proto_register(&udp_prot, 1);
86690 if (rc)
86691 @@ -1832,8 +1828,6 @@ out_unregister_udp_proto:
86692 proto_unregister(&udp_prot);
86693 out_unregister_tcp_proto:
86694 proto_unregister(&tcp_prot);
86695 -out_free_reserved_ports:
86696 - kfree(sysctl_local_reserved_ports);
86697 goto out;
86698 }
86699
86700 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
86701 index a69b4e4..dbccba5 100644
86702 --- a/net/ipv4/ah4.c
86703 +++ b/net/ipv4/ah4.c
86704 @@ -421,7 +421,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
86705 return;
86706
86707 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86708 - atomic_inc(&flow_cache_genid);
86709 + atomic_inc_unchecked(&flow_cache_genid);
86710 rt_genid_bump(net);
86711
86712 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
86713 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
86714 index a8e4f26..25e5f40 100644
86715 --- a/net/ipv4/devinet.c
86716 +++ b/net/ipv4/devinet.c
86717 @@ -1763,7 +1763,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
86718 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
86719 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
86720
86721 -static struct devinet_sysctl_table {
86722 +static const struct devinet_sysctl_table {
86723 struct ctl_table_header *sysctl_header;
86724 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
86725 } devinet_sysctl = {
86726 @@ -1881,7 +1881,7 @@ static __net_init int devinet_init_net(struct net *net)
86727 int err;
86728 struct ipv4_devconf *all, *dflt;
86729 #ifdef CONFIG_SYSCTL
86730 - struct ctl_table *tbl = ctl_forward_entry;
86731 + ctl_table_no_const *tbl = NULL;
86732 struct ctl_table_header *forw_hdr;
86733 #endif
86734
86735 @@ -1899,7 +1899,7 @@ static __net_init int devinet_init_net(struct net *net)
86736 goto err_alloc_dflt;
86737
86738 #ifdef CONFIG_SYSCTL
86739 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
86740 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
86741 if (tbl == NULL)
86742 goto err_alloc_ctl;
86743
86744 @@ -1919,7 +1919,10 @@ static __net_init int devinet_init_net(struct net *net)
86745 goto err_reg_dflt;
86746
86747 err = -ENOMEM;
86748 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86749 + if (!net_eq(net, &init_net))
86750 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
86751 + else
86752 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
86753 if (forw_hdr == NULL)
86754 goto err_reg_ctl;
86755 net->ipv4.forw_hdr = forw_hdr;
86756 @@ -1935,8 +1938,7 @@ err_reg_ctl:
86757 err_reg_dflt:
86758 __devinet_sysctl_unregister(all);
86759 err_reg_all:
86760 - if (tbl != ctl_forward_entry)
86761 - kfree(tbl);
86762 + kfree(tbl);
86763 err_alloc_ctl:
86764 #endif
86765 if (dflt != &ipv4_devconf_dflt)
86766 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
86767 index 3b4f0cd..8cb864c 100644
86768 --- a/net/ipv4/esp4.c
86769 +++ b/net/ipv4/esp4.c
86770 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
86771 return;
86772
86773 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
86774 - atomic_inc(&flow_cache_genid);
86775 + atomic_inc_unchecked(&flow_cache_genid);
86776 rt_genid_bump(net);
86777
86778 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
86779 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
86780 index 5cd75e2..f57ef39 100644
86781 --- a/net/ipv4/fib_frontend.c
86782 +++ b/net/ipv4/fib_frontend.c
86783 @@ -1020,12 +1020,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
86784 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86785 fib_sync_up(dev);
86786 #endif
86787 - atomic_inc(&net->ipv4.dev_addr_genid);
86788 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86789 rt_cache_flush(dev_net(dev));
86790 break;
86791 case NETDEV_DOWN:
86792 fib_del_ifaddr(ifa, NULL);
86793 - atomic_inc(&net->ipv4.dev_addr_genid);
86794 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86795 if (ifa->ifa_dev->ifa_list == NULL) {
86796 /* Last address was deleted from this interface.
86797 * Disable IP.
86798 @@ -1061,7 +1061,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
86799 #ifdef CONFIG_IP_ROUTE_MULTIPATH
86800 fib_sync_up(dev);
86801 #endif
86802 - atomic_inc(&net->ipv4.dev_addr_genid);
86803 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
86804 rt_cache_flush(net);
86805 break;
86806 case NETDEV_DOWN:
86807 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
86808 index 4797a80..2bd54e9 100644
86809 --- a/net/ipv4/fib_semantics.c
86810 +++ b/net/ipv4/fib_semantics.c
86811 @@ -767,7 +767,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
86812 nh->nh_saddr = inet_select_addr(nh->nh_dev,
86813 nh->nh_gw,
86814 nh->nh_parent->fib_scope);
86815 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
86816 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
86817
86818 return nh->nh_saddr;
86819 }
86820 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
86821 index d0670f0..744ac80 100644
86822 --- a/net/ipv4/inet_connection_sock.c
86823 +++ b/net/ipv4/inet_connection_sock.c
86824 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
86825 .range = { 32768, 61000 },
86826 };
86827
86828 -unsigned long *sysctl_local_reserved_ports;
86829 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
86830 EXPORT_SYMBOL(sysctl_local_reserved_ports);
86831
86832 void inet_get_local_port_range(int *low, int *high)
86833 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
86834 index fa3ae81..0dbe6b8 100644
86835 --- a/net/ipv4/inet_hashtables.c
86836 +++ b/net/ipv4/inet_hashtables.c
86837 @@ -18,12 +18,15 @@
86838 #include <linux/sched.h>
86839 #include <linux/slab.h>
86840 #include <linux/wait.h>
86841 +#include <linux/security.h>
86842
86843 #include <net/inet_connection_sock.h>
86844 #include <net/inet_hashtables.h>
86845 #include <net/secure_seq.h>
86846 #include <net/ip.h>
86847
86848 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
86849 +
86850 /*
86851 * Allocate and initialize a new local port bind bucket.
86852 * The bindhash mutex for snum's hash chain must be held here.
86853 @@ -540,6 +543,8 @@ ok:
86854 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
86855 spin_unlock(&head->lock);
86856
86857 + gr_update_task_in_ip_table(current, inet_sk(sk));
86858 +
86859 if (tw) {
86860 inet_twsk_deschedule(tw, death_row);
86861 while (twrefcnt) {
86862 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
86863 index 000e3d2..5472da3 100644
86864 --- a/net/ipv4/inetpeer.c
86865 +++ b/net/ipv4/inetpeer.c
86866 @@ -503,8 +503,8 @@ relookup:
86867 if (p) {
86868 p->daddr = *daddr;
86869 atomic_set(&p->refcnt, 1);
86870 - atomic_set(&p->rid, 0);
86871 - atomic_set(&p->ip_id_count,
86872 + atomic_set_unchecked(&p->rid, 0);
86873 + atomic_set_unchecked(&p->ip_id_count,
86874 (daddr->family == AF_INET) ?
86875 secure_ip_id(daddr->addr.a4) :
86876 secure_ipv6_id(daddr->addr.a6));
86877 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
86878 index a8fc332..4ca4ca65 100644
86879 --- a/net/ipv4/ip_fragment.c
86880 +++ b/net/ipv4/ip_fragment.c
86881 @@ -319,7 +319,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
86882 return 0;
86883
86884 start = qp->rid;
86885 - end = atomic_inc_return(&peer->rid);
86886 + end = atomic_inc_return_unchecked(&peer->rid);
86887 qp->rid = end;
86888
86889 rc = qp->q.fragments && (end - start) > max;
86890 @@ -786,12 +786,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
86891
86892 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86893 {
86894 - struct ctl_table *table;
86895 + ctl_table_no_const *table = NULL;
86896 struct ctl_table_header *hdr;
86897
86898 - table = ip4_frags_ns_ctl_table;
86899 if (!net_eq(net, &init_net)) {
86900 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86901 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
86902 if (table == NULL)
86903 goto err_alloc;
86904
86905 @@ -802,9 +801,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86906 /* Don't export sysctls to unprivileged users */
86907 if (net->user_ns != &init_user_ns)
86908 table[0].procname = NULL;
86909 - }
86910 + hdr = register_net_sysctl(net, "net/ipv4", table);
86911 + } else
86912 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
86913
86914 - hdr = register_net_sysctl(net, "net/ipv4", table);
86915 if (hdr == NULL)
86916 goto err_reg;
86917
86918 @@ -812,8 +812,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
86919 return 0;
86920
86921 err_reg:
86922 - if (!net_eq(net, &init_net))
86923 - kfree(table);
86924 + kfree(table);
86925 err_alloc:
86926 return -ENOMEM;
86927 }
86928 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
86929 index a85062b..2958a9b 100644
86930 --- a/net/ipv4/ip_gre.c
86931 +++ b/net/ipv4/ip_gre.c
86932 @@ -124,7 +124,7 @@ static bool log_ecn_error = true;
86933 module_param(log_ecn_error, bool, 0644);
86934 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
86935
86936 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
86937 +static struct rtnl_link_ops ipgre_link_ops;
86938 static int ipgre_tunnel_init(struct net_device *dev);
86939 static void ipgre_tunnel_setup(struct net_device *dev);
86940 static int ipgre_tunnel_bind_dev(struct net_device *dev);
86941 @@ -1753,7 +1753,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
86942 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
86943 };
86944
86945 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86946 +static struct rtnl_link_ops ipgre_link_ops = {
86947 .kind = "gre",
86948 .maxtype = IFLA_GRE_MAX,
86949 .policy = ipgre_policy,
86950 @@ -1766,7 +1766,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
86951 .fill_info = ipgre_fill_info,
86952 };
86953
86954 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
86955 +static struct rtnl_link_ops ipgre_tap_ops = {
86956 .kind = "gretap",
86957 .maxtype = IFLA_GRE_MAX,
86958 .policy = ipgre_policy,
86959 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
86960 index d9c4f11..02b82dbc 100644
86961 --- a/net/ipv4/ip_sockglue.c
86962 +++ b/net/ipv4/ip_sockglue.c
86963 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86964 len = min_t(unsigned int, len, opt->optlen);
86965 if (put_user(len, optlen))
86966 return -EFAULT;
86967 - if (copy_to_user(optval, opt->__data, len))
86968 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
86969 + copy_to_user(optval, opt->__data, len))
86970 return -EFAULT;
86971 return 0;
86972 }
86973 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
86974 if (sk->sk_type != SOCK_STREAM)
86975 return -ENOPROTOOPT;
86976
86977 - msg.msg_control = optval;
86978 + msg.msg_control = (void __force_kernel *)optval;
86979 msg.msg_controllen = len;
86980 msg.msg_flags = flags;
86981
86982 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
86983 index c3a4233..1412161 100644
86984 --- a/net/ipv4/ip_vti.c
86985 +++ b/net/ipv4/ip_vti.c
86986 @@ -47,7 +47,7 @@
86987 #define HASH_SIZE 16
86988 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
86989
86990 -static struct rtnl_link_ops vti_link_ops __read_mostly;
86991 +static struct rtnl_link_ops vti_link_ops;
86992
86993 static int vti_net_id __read_mostly;
86994 struct vti_net {
86995 @@ -886,7 +886,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
86996 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
86997 };
86998
86999 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87000 +static struct rtnl_link_ops vti_link_ops = {
87001 .kind = "vti",
87002 .maxtype = IFLA_VTI_MAX,
87003 .policy = vti_policy,
87004 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87005 index 9a46dae..5f793a0 100644
87006 --- a/net/ipv4/ipcomp.c
87007 +++ b/net/ipv4/ipcomp.c
87008 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87009 return;
87010
87011 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87012 - atomic_inc(&flow_cache_genid);
87013 + atomic_inc_unchecked(&flow_cache_genid);
87014 rt_genid_bump(net);
87015
87016 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87017 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87018 index a2e50ae..e152b7c 100644
87019 --- a/net/ipv4/ipconfig.c
87020 +++ b/net/ipv4/ipconfig.c
87021 @@ -323,7 +323,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87022
87023 mm_segment_t oldfs = get_fs();
87024 set_fs(get_ds());
87025 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87026 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87027 set_fs(oldfs);
87028 return res;
87029 }
87030 @@ -334,7 +334,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87031
87032 mm_segment_t oldfs = get_fs();
87033 set_fs(get_ds());
87034 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87035 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87036 set_fs(oldfs);
87037 return res;
87038 }
87039 @@ -345,7 +345,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87040
87041 mm_segment_t oldfs = get_fs();
87042 set_fs(get_ds());
87043 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87044 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87045 set_fs(oldfs);
87046 return res;
87047 }
87048 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87049 index 191fc24..1b3b804 100644
87050 --- a/net/ipv4/ipip.c
87051 +++ b/net/ipv4/ipip.c
87052 @@ -138,7 +138,7 @@ struct ipip_net {
87053 static int ipip_tunnel_init(struct net_device *dev);
87054 static void ipip_tunnel_setup(struct net_device *dev);
87055 static void ipip_dev_free(struct net_device *dev);
87056 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87057 +static struct rtnl_link_ops ipip_link_ops;
87058
87059 static struct rtnl_link_stats64 *ipip_get_stats64(struct net_device *dev,
87060 struct rtnl_link_stats64 *tot)
87061 @@ -972,7 +972,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87062 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87063 };
87064
87065 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87066 +static struct rtnl_link_ops ipip_link_ops = {
87067 .kind = "ipip",
87068 .maxtype = IFLA_IPTUN_MAX,
87069 .policy = ipip_policy,
87070 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87071 index 3ea4127..849297b 100644
87072 --- a/net/ipv4/netfilter/arp_tables.c
87073 +++ b/net/ipv4/netfilter/arp_tables.c
87074 @@ -879,14 +879,14 @@ static int compat_table_info(const struct xt_table_info *info,
87075 #endif
87076
87077 static int get_info(struct net *net, void __user *user,
87078 - const int *len, int compat)
87079 + int len, int compat)
87080 {
87081 char name[XT_TABLE_MAXNAMELEN];
87082 struct xt_table *t;
87083 int ret;
87084
87085 - if (*len != sizeof(struct arpt_getinfo)) {
87086 - duprintf("length %u != %Zu\n", *len,
87087 + if (len != sizeof(struct arpt_getinfo)) {
87088 + duprintf("length %u != %Zu\n", len,
87089 sizeof(struct arpt_getinfo));
87090 return -EINVAL;
87091 }
87092 @@ -923,7 +923,7 @@ static int get_info(struct net *net, void __user *user,
87093 info.size = private->size;
87094 strcpy(info.name, name);
87095
87096 - if (copy_to_user(user, &info, *len) != 0)
87097 + if (copy_to_user(user, &info, len) != 0)
87098 ret = -EFAULT;
87099 else
87100 ret = 0;
87101 @@ -1682,7 +1682,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87102
87103 switch (cmd) {
87104 case ARPT_SO_GET_INFO:
87105 - ret = get_info(sock_net(sk), user, len, 1);
87106 + ret = get_info(sock_net(sk), user, *len, 1);
87107 break;
87108 case ARPT_SO_GET_ENTRIES:
87109 ret = compat_get_entries(sock_net(sk), user, len);
87110 @@ -1727,7 +1727,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87111
87112 switch (cmd) {
87113 case ARPT_SO_GET_INFO:
87114 - ret = get_info(sock_net(sk), user, len, 0);
87115 + ret = get_info(sock_net(sk), user, *len, 0);
87116 break;
87117
87118 case ARPT_SO_GET_ENTRIES:
87119 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87120 index 17c5e06..1b91206 100644
87121 --- a/net/ipv4/netfilter/ip_tables.c
87122 +++ b/net/ipv4/netfilter/ip_tables.c
87123 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87124 #endif
87125
87126 static int get_info(struct net *net, void __user *user,
87127 - const int *len, int compat)
87128 + int len, int compat)
87129 {
87130 char name[XT_TABLE_MAXNAMELEN];
87131 struct xt_table *t;
87132 int ret;
87133
87134 - if (*len != sizeof(struct ipt_getinfo)) {
87135 - duprintf("length %u != %zu\n", *len,
87136 + if (len != sizeof(struct ipt_getinfo)) {
87137 + duprintf("length %u != %zu\n", len,
87138 sizeof(struct ipt_getinfo));
87139 return -EINVAL;
87140 }
87141 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87142 info.size = private->size;
87143 strcpy(info.name, name);
87144
87145 - if (copy_to_user(user, &info, *len) != 0)
87146 + if (copy_to_user(user, &info, len) != 0)
87147 ret = -EFAULT;
87148 else
87149 ret = 0;
87150 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87151
87152 switch (cmd) {
87153 case IPT_SO_GET_INFO:
87154 - ret = get_info(sock_net(sk), user, len, 1);
87155 + ret = get_info(sock_net(sk), user, *len, 1);
87156 break;
87157 case IPT_SO_GET_ENTRIES:
87158 ret = compat_get_entries(sock_net(sk), user, len);
87159 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87160
87161 switch (cmd) {
87162 case IPT_SO_GET_INFO:
87163 - ret = get_info(sock_net(sk), user, len, 0);
87164 + ret = get_info(sock_net(sk), user, *len, 0);
87165 break;
87166
87167 case IPT_SO_GET_ENTRIES:
87168 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87169 index dc454cc..5bb917f 100644
87170 --- a/net/ipv4/ping.c
87171 +++ b/net/ipv4/ping.c
87172 @@ -844,7 +844,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87173 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87174 0, sock_i_ino(sp),
87175 atomic_read(&sp->sk_refcnt), sp,
87176 - atomic_read(&sp->sk_drops), len);
87177 + atomic_read_unchecked(&sp->sk_drops), len);
87178 }
87179
87180 static int ping_seq_show(struct seq_file *seq, void *v)
87181 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87182 index 6f08991..55867ad 100644
87183 --- a/net/ipv4/raw.c
87184 +++ b/net/ipv4/raw.c
87185 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87186 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87187 {
87188 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87189 - atomic_inc(&sk->sk_drops);
87190 + atomic_inc_unchecked(&sk->sk_drops);
87191 kfree_skb(skb);
87192 return NET_RX_DROP;
87193 }
87194 @@ -747,16 +747,20 @@ static int raw_init(struct sock *sk)
87195
87196 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87197 {
87198 + struct icmp_filter filter;
87199 +
87200 if (optlen > sizeof(struct icmp_filter))
87201 optlen = sizeof(struct icmp_filter);
87202 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87203 + if (copy_from_user(&filter, optval, optlen))
87204 return -EFAULT;
87205 + raw_sk(sk)->filter = filter;
87206 return 0;
87207 }
87208
87209 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87210 {
87211 int len, ret = -EFAULT;
87212 + struct icmp_filter filter;
87213
87214 if (get_user(len, optlen))
87215 goto out;
87216 @@ -766,8 +770,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87217 if (len > sizeof(struct icmp_filter))
87218 len = sizeof(struct icmp_filter);
87219 ret = -EFAULT;
87220 - if (put_user(len, optlen) ||
87221 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87222 + filter = raw_sk(sk)->filter;
87223 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87224 goto out;
87225 ret = 0;
87226 out: return ret;
87227 @@ -998,7 +1002,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87228 0, 0L, 0,
87229 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87230 0, sock_i_ino(sp),
87231 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87232 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87233 }
87234
87235 static int raw_seq_show(struct seq_file *seq, void *v)
87236 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87237 index a0fcc47..32e2c89 100644
87238 --- a/net/ipv4/route.c
87239 +++ b/net/ipv4/route.c
87240 @@ -2552,34 +2552,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87241 .maxlen = sizeof(int),
87242 .mode = 0200,
87243 .proc_handler = ipv4_sysctl_rtcache_flush,
87244 + .extra1 = &init_net,
87245 },
87246 { },
87247 };
87248
87249 static __net_init int sysctl_route_net_init(struct net *net)
87250 {
87251 - struct ctl_table *tbl;
87252 + ctl_table_no_const *tbl = NULL;
87253
87254 - tbl = ipv4_route_flush_table;
87255 if (!net_eq(net, &init_net)) {
87256 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87257 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87258 if (tbl == NULL)
87259 goto err_dup;
87260
87261 /* Don't export sysctls to unprivileged users */
87262 if (net->user_ns != &init_user_ns)
87263 tbl[0].procname = NULL;
87264 - }
87265 - tbl[0].extra1 = net;
87266 + tbl[0].extra1 = net;
87267 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87268 + } else
87269 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87270
87271 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87272 if (net->ipv4.route_hdr == NULL)
87273 goto err_reg;
87274 return 0;
87275
87276 err_reg:
87277 - if (tbl != ipv4_route_flush_table)
87278 - kfree(tbl);
87279 + kfree(tbl);
87280 err_dup:
87281 return -ENOMEM;
87282 }
87283 @@ -2602,7 +2602,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87284
87285 static __net_init int rt_genid_init(struct net *net)
87286 {
87287 - atomic_set(&net->rt_genid, 0);
87288 + atomic_set_unchecked(&net->rt_genid, 0);
87289 get_random_bytes(&net->ipv4.dev_addr_genid,
87290 sizeof(net->ipv4.dev_addr_genid));
87291 return 0;
87292 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87293 index d84400b..62e066e 100644
87294 --- a/net/ipv4/sysctl_net_ipv4.c
87295 +++ b/net/ipv4/sysctl_net_ipv4.c
87296 @@ -54,7 +54,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87297 {
87298 int ret;
87299 int range[2];
87300 - ctl_table tmp = {
87301 + ctl_table_no_const tmp = {
87302 .data = &range,
87303 .maxlen = sizeof(range),
87304 .mode = table->mode,
87305 @@ -107,7 +107,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87306 int ret;
87307 gid_t urange[2];
87308 kgid_t low, high;
87309 - ctl_table tmp = {
87310 + ctl_table_no_const tmp = {
87311 .data = &urange,
87312 .maxlen = sizeof(urange),
87313 .mode = table->mode,
87314 @@ -138,7 +138,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87315 void __user *buffer, size_t *lenp, loff_t *ppos)
87316 {
87317 char val[TCP_CA_NAME_MAX];
87318 - ctl_table tbl = {
87319 + ctl_table_no_const tbl = {
87320 .data = val,
87321 .maxlen = TCP_CA_NAME_MAX,
87322 };
87323 @@ -157,7 +157,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87324 void __user *buffer, size_t *lenp,
87325 loff_t *ppos)
87326 {
87327 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87328 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87329 int ret;
87330
87331 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87332 @@ -174,7 +174,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87333 void __user *buffer, size_t *lenp,
87334 loff_t *ppos)
87335 {
87336 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87337 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87338 int ret;
87339
87340 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87341 @@ -200,15 +200,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87342 struct mem_cgroup *memcg;
87343 #endif
87344
87345 - ctl_table tmp = {
87346 + ctl_table_no_const tmp = {
87347 .data = &vec,
87348 .maxlen = sizeof(vec),
87349 .mode = ctl->mode,
87350 };
87351
87352 if (!write) {
87353 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87354 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87355 + ctl_table_no_const tcp_mem = *ctl;
87356 +
87357 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87358 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87359 }
87360
87361 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87362 @@ -235,7 +237,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87363 int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87364 size_t *lenp, loff_t *ppos)
87365 {
87366 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87367 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87368 struct tcp_fastopen_context *ctxt;
87369 int ret;
87370 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87371 @@ -476,7 +478,7 @@ static struct ctl_table ipv4_table[] = {
87372 },
87373 {
87374 .procname = "ip_local_reserved_ports",
87375 - .data = NULL, /* initialized in sysctl_ipv4_init */
87376 + .data = sysctl_local_reserved_ports,
87377 .maxlen = 65536,
87378 .mode = 0644,
87379 .proc_handler = proc_do_large_bitmap,
87380 @@ -860,11 +862,10 @@ static struct ctl_table ipv4_net_table[] = {
87381
87382 static __net_init int ipv4_sysctl_init_net(struct net *net)
87383 {
87384 - struct ctl_table *table;
87385 + ctl_table_no_const *table = NULL;
87386
87387 - table = ipv4_net_table;
87388 if (!net_eq(net, &init_net)) {
87389 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87390 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87391 if (table == NULL)
87392 goto err_alloc;
87393
87394 @@ -897,15 +898,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87395
87396 tcp_init_mem(net);
87397
87398 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87399 + if (!net_eq(net, &init_net))
87400 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87401 + else
87402 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87403 if (net->ipv4.ipv4_hdr == NULL)
87404 goto err_reg;
87405
87406 return 0;
87407
87408 err_reg:
87409 - if (!net_eq(net, &init_net))
87410 - kfree(table);
87411 + kfree(table);
87412 err_alloc:
87413 return -ENOMEM;
87414 }
87415 @@ -927,16 +930,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87416 static __init int sysctl_ipv4_init(void)
87417 {
87418 struct ctl_table_header *hdr;
87419 - struct ctl_table *i;
87420 -
87421 - for (i = ipv4_table; i->procname; i++) {
87422 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87423 - i->data = sysctl_local_reserved_ports;
87424 - break;
87425 - }
87426 - }
87427 - if (!i->procname)
87428 - return -EINVAL;
87429
87430 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87431 if (hdr == NULL)
87432 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87433 index 9841a71..ef60409 100644
87434 --- a/net/ipv4/tcp_input.c
87435 +++ b/net/ipv4/tcp_input.c
87436 @@ -4730,7 +4730,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87437 * simplifies code)
87438 */
87439 static void
87440 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87441 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87442 struct sk_buff *head, struct sk_buff *tail,
87443 u32 start, u32 end)
87444 {
87445 @@ -5847,6 +5847,7 @@ discard:
87446 tcp_paws_reject(&tp->rx_opt, 0))
87447 goto discard_and_undo;
87448
87449 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87450 if (th->syn) {
87451 /* We see SYN without ACK. It is attempt of
87452 * simultaneous connect with crossed SYNs.
87453 @@ -5897,6 +5898,7 @@ discard:
87454 goto discard;
87455 #endif
87456 }
87457 +#endif
87458 /* "fifth, if neither of the SYN or RST bits is set then
87459 * drop the segment and return."
87460 */
87461 @@ -5941,7 +5943,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87462 goto discard;
87463
87464 if (th->syn) {
87465 - if (th->fin)
87466 + if (th->fin || th->urg || th->psh)
87467 goto discard;
87468 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87469 return 1;
87470 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87471 index d9130a9..00328ff 100644
87472 --- a/net/ipv4/tcp_ipv4.c
87473 +++ b/net/ipv4/tcp_ipv4.c
87474 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87475 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87476
87477
87478 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87479 +extern int grsec_enable_blackhole;
87480 +#endif
87481 +
87482 #ifdef CONFIG_TCP_MD5SIG
87483 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87484 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87485 @@ -1895,6 +1899,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87486 return 0;
87487
87488 reset:
87489 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87490 + if (!grsec_enable_blackhole)
87491 +#endif
87492 tcp_v4_send_reset(rsk, skb);
87493 discard:
87494 kfree_skb(skb);
87495 @@ -1994,12 +2001,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87496 TCP_SKB_CB(skb)->sacked = 0;
87497
87498 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87499 - if (!sk)
87500 + if (!sk) {
87501 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87502 + ret = 1;
87503 +#endif
87504 goto no_tcp_socket;
87505 -
87506 + }
87507 process:
87508 - if (sk->sk_state == TCP_TIME_WAIT)
87509 + if (sk->sk_state == TCP_TIME_WAIT) {
87510 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87511 + ret = 2;
87512 +#endif
87513 goto do_time_wait;
87514 + }
87515
87516 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87517 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87518 @@ -2050,6 +2064,10 @@ no_tcp_socket:
87519 bad_packet:
87520 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87521 } else {
87522 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87523 + if (!grsec_enable_blackhole || (ret == 1 &&
87524 + (skb->dev->flags & IFF_LOOPBACK)))
87525 +#endif
87526 tcp_v4_send_reset(NULL, skb);
87527 }
87528
87529 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87530 index f35f2df..ccb5ca6 100644
87531 --- a/net/ipv4/tcp_minisocks.c
87532 +++ b/net/ipv4/tcp_minisocks.c
87533 @@ -27,6 +27,10 @@
87534 #include <net/inet_common.h>
87535 #include <net/xfrm.h>
87536
87537 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87538 +extern int grsec_enable_blackhole;
87539 +#endif
87540 +
87541 int sysctl_tcp_syncookies __read_mostly = 1;
87542 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87543
87544 @@ -742,7 +746,10 @@ embryonic_reset:
87545 * avoid becoming vulnerable to outside attack aiming at
87546 * resetting legit local connections.
87547 */
87548 - req->rsk_ops->send_reset(sk, skb);
87549 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87550 + if (!grsec_enable_blackhole)
87551 +#endif
87552 + req->rsk_ops->send_reset(sk, skb);
87553 } else if (fastopen) { /* received a valid RST pkt */
87554 reqsk_fastopen_remove(sk, req, true);
87555 tcp_reset(sk);
87556 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87557 index 4526fe6..1a34e43 100644
87558 --- a/net/ipv4/tcp_probe.c
87559 +++ b/net/ipv4/tcp_probe.c
87560 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87561 if (cnt + width >= len)
87562 break;
87563
87564 - if (copy_to_user(buf + cnt, tbuf, width))
87565 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87566 return -EFAULT;
87567 cnt += width;
87568 }
87569 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87570 index b78aac3..e18230b 100644
87571 --- a/net/ipv4/tcp_timer.c
87572 +++ b/net/ipv4/tcp_timer.c
87573 @@ -22,6 +22,10 @@
87574 #include <linux/gfp.h>
87575 #include <net/tcp.h>
87576
87577 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87578 +extern int grsec_lastack_retries;
87579 +#endif
87580 +
87581 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87582 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87583 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87584 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87585 }
87586 }
87587
87588 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87589 + if ((sk->sk_state == TCP_LAST_ACK) &&
87590 + (grsec_lastack_retries > 0) &&
87591 + (grsec_lastack_retries < retry_until))
87592 + retry_until = grsec_lastack_retries;
87593 +#endif
87594 +
87595 if (retransmits_timed_out(sk, retry_until,
87596 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87597 /* Has it gone just too far? */
87598 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87599 index 1f4d405..3524677 100644
87600 --- a/net/ipv4/udp.c
87601 +++ b/net/ipv4/udp.c
87602 @@ -87,6 +87,7 @@
87603 #include <linux/types.h>
87604 #include <linux/fcntl.h>
87605 #include <linux/module.h>
87606 +#include <linux/security.h>
87607 #include <linux/socket.h>
87608 #include <linux/sockios.h>
87609 #include <linux/igmp.h>
87610 @@ -111,6 +112,10 @@
87611 #include <trace/events/skb.h>
87612 #include "udp_impl.h"
87613
87614 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87615 +extern int grsec_enable_blackhole;
87616 +#endif
87617 +
87618 struct udp_table udp_table __read_mostly;
87619 EXPORT_SYMBOL(udp_table);
87620
87621 @@ -569,6 +574,9 @@ found:
87622 return s;
87623 }
87624
87625 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87626 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87627 +
87628 /*
87629 * This routine is called by the ICMP module when it gets some
87630 * sort of error condition. If err < 0 then the socket should
87631 @@ -864,9 +872,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87632 dport = usin->sin_port;
87633 if (dport == 0)
87634 return -EINVAL;
87635 +
87636 + err = gr_search_udp_sendmsg(sk, usin);
87637 + if (err)
87638 + return err;
87639 } else {
87640 if (sk->sk_state != TCP_ESTABLISHED)
87641 return -EDESTADDRREQ;
87642 +
87643 + err = gr_search_udp_sendmsg(sk, NULL);
87644 + if (err)
87645 + return err;
87646 +
87647 daddr = inet->inet_daddr;
87648 dport = inet->inet_dport;
87649 /* Open fast path for connected socket.
87650 @@ -1108,7 +1125,7 @@ static unsigned int first_packet_length(struct sock *sk)
87651 udp_lib_checksum_complete(skb)) {
87652 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87653 IS_UDPLITE(sk));
87654 - atomic_inc(&sk->sk_drops);
87655 + atomic_inc_unchecked(&sk->sk_drops);
87656 __skb_unlink(skb, rcvq);
87657 __skb_queue_tail(&list_kill, skb);
87658 }
87659 @@ -1194,6 +1211,10 @@ try_again:
87660 if (!skb)
87661 goto out;
87662
87663 + err = gr_search_udp_recvmsg(sk, skb);
87664 + if (err)
87665 + goto out_free;
87666 +
87667 ulen = skb->len - sizeof(struct udphdr);
87668 copied = len;
87669 if (copied > ulen)
87670 @@ -1227,7 +1248,7 @@ try_again:
87671 if (unlikely(err)) {
87672 trace_kfree_skb(skb, udp_recvmsg);
87673 if (!peeked) {
87674 - atomic_inc(&sk->sk_drops);
87675 + atomic_inc_unchecked(&sk->sk_drops);
87676 UDP_INC_STATS_USER(sock_net(sk),
87677 UDP_MIB_INERRORS, is_udplite);
87678 }
87679 @@ -1510,7 +1531,7 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
87680
87681 drop:
87682 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
87683 - atomic_inc(&sk->sk_drops);
87684 + atomic_inc_unchecked(&sk->sk_drops);
87685 kfree_skb(skb);
87686 return -1;
87687 }
87688 @@ -1529,7 +1550,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
87689 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
87690
87691 if (!skb1) {
87692 - atomic_inc(&sk->sk_drops);
87693 + atomic_inc_unchecked(&sk->sk_drops);
87694 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
87695 IS_UDPLITE(sk));
87696 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87697 @@ -1698,6 +1719,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
87698 goto csum_error;
87699
87700 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
87701 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87702 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
87703 +#endif
87704 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
87705
87706 /*
87707 @@ -2120,7 +2144,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
87708 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87709 0, sock_i_ino(sp),
87710 atomic_read(&sp->sk_refcnt), sp,
87711 - atomic_read(&sp->sk_drops), len);
87712 + atomic_read_unchecked(&sp->sk_drops), len);
87713 }
87714
87715 int udp4_seq_show(struct seq_file *seq, void *v)
87716 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
87717 index a36d17e..96d099f 100644
87718 --- a/net/ipv6/addrconf.c
87719 +++ b/net/ipv6/addrconf.c
87720 @@ -2272,7 +2272,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
87721 p.iph.ihl = 5;
87722 p.iph.protocol = IPPROTO_IPV6;
87723 p.iph.ttl = 64;
87724 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
87725 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
87726
87727 if (ops->ndo_do_ioctl) {
87728 mm_segment_t oldfs = get_fs();
87729 @@ -4388,7 +4388,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
87730 int *valp = ctl->data;
87731 int val = *valp;
87732 loff_t pos = *ppos;
87733 - ctl_table lctl;
87734 + ctl_table_no_const lctl;
87735 int ret;
87736
87737 /*
87738 @@ -4470,7 +4470,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
87739 int *valp = ctl->data;
87740 int val = *valp;
87741 loff_t pos = *ppos;
87742 - ctl_table lctl;
87743 + ctl_table_no_const lctl;
87744 int ret;
87745
87746 /*
87747 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
87748 index fff5bdd..15194fb 100644
87749 --- a/net/ipv6/icmp.c
87750 +++ b/net/ipv6/icmp.c
87751 @@ -973,7 +973,7 @@ ctl_table ipv6_icmp_table_template[] = {
87752
87753 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
87754 {
87755 - struct ctl_table *table;
87756 + ctl_table_no_const *table;
87757
87758 table = kmemdup(ipv6_icmp_table_template,
87759 sizeof(ipv6_icmp_table_template),
87760 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
87761 index 131dd09..f7ed64f 100644
87762 --- a/net/ipv6/ip6_gre.c
87763 +++ b/net/ipv6/ip6_gre.c
87764 @@ -73,7 +73,7 @@ struct ip6gre_net {
87765 struct net_device *fb_tunnel_dev;
87766 };
87767
87768 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
87769 +static struct rtnl_link_ops ip6gre_link_ops;
87770 static int ip6gre_tunnel_init(struct net_device *dev);
87771 static void ip6gre_tunnel_setup(struct net_device *dev);
87772 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
87773 @@ -1337,7 +1337,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
87774 }
87775
87776
87777 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
87778 +static struct inet6_protocol ip6gre_protocol = {
87779 .handler = ip6gre_rcv,
87780 .err_handler = ip6gre_err,
87781 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
87782 @@ -1671,7 +1671,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
87783 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
87784 };
87785
87786 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87787 +static struct rtnl_link_ops ip6gre_link_ops = {
87788 .kind = "ip6gre",
87789 .maxtype = IFLA_GRE_MAX,
87790 .policy = ip6gre_policy,
87791 @@ -1684,7 +1684,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
87792 .fill_info = ip6gre_fill_info,
87793 };
87794
87795 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
87796 +static struct rtnl_link_ops ip6gre_tap_ops = {
87797 .kind = "ip6gretap",
87798 .maxtype = IFLA_GRE_MAX,
87799 .policy = ip6gre_policy,
87800 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
87801 index a14f28b..b4b8956 100644
87802 --- a/net/ipv6/ip6_tunnel.c
87803 +++ b/net/ipv6/ip6_tunnel.c
87804 @@ -87,7 +87,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
87805
87806 static int ip6_tnl_dev_init(struct net_device *dev);
87807 static void ip6_tnl_dev_setup(struct net_device *dev);
87808 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
87809 +static struct rtnl_link_ops ip6_link_ops;
87810
87811 static int ip6_tnl_net_id __read_mostly;
87812 struct ip6_tnl_net {
87813 @@ -1686,7 +1686,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
87814 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
87815 };
87816
87817 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
87818 +static struct rtnl_link_ops ip6_link_ops = {
87819 .kind = "ip6tnl",
87820 .maxtype = IFLA_IPTUN_MAX,
87821 .policy = ip6_tnl_policy,
87822 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
87823 index d1e2e8e..51c19ae 100644
87824 --- a/net/ipv6/ipv6_sockglue.c
87825 +++ b/net/ipv6/ipv6_sockglue.c
87826 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
87827 if (sk->sk_type != SOCK_STREAM)
87828 return -ENOPROTOOPT;
87829
87830 - msg.msg_control = optval;
87831 + msg.msg_control = (void __force_kernel *)optval;
87832 msg.msg_controllen = len;
87833 msg.msg_flags = flags;
87834
87835 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
87836 index 125a90d..2a11f36 100644
87837 --- a/net/ipv6/netfilter/ip6_tables.c
87838 +++ b/net/ipv6/netfilter/ip6_tables.c
87839 @@ -1076,14 +1076,14 @@ static int compat_table_info(const struct xt_table_info *info,
87840 #endif
87841
87842 static int get_info(struct net *net, void __user *user,
87843 - const int *len, int compat)
87844 + int len, int compat)
87845 {
87846 char name[XT_TABLE_MAXNAMELEN];
87847 struct xt_table *t;
87848 int ret;
87849
87850 - if (*len != sizeof(struct ip6t_getinfo)) {
87851 - duprintf("length %u != %zu\n", *len,
87852 + if (len != sizeof(struct ip6t_getinfo)) {
87853 + duprintf("length %u != %zu\n", len,
87854 sizeof(struct ip6t_getinfo));
87855 return -EINVAL;
87856 }
87857 @@ -1120,7 +1120,7 @@ static int get_info(struct net *net, void __user *user,
87858 info.size = private->size;
87859 strcpy(info.name, name);
87860
87861 - if (copy_to_user(user, &info, *len) != 0)
87862 + if (copy_to_user(user, &info, len) != 0)
87863 ret = -EFAULT;
87864 else
87865 ret = 0;
87866 @@ -1974,7 +1974,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87867
87868 switch (cmd) {
87869 case IP6T_SO_GET_INFO:
87870 - ret = get_info(sock_net(sk), user, len, 1);
87871 + ret = get_info(sock_net(sk), user, *len, 1);
87872 break;
87873 case IP6T_SO_GET_ENTRIES:
87874 ret = compat_get_entries(sock_net(sk), user, len);
87875 @@ -2021,7 +2021,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87876
87877 switch (cmd) {
87878 case IP6T_SO_GET_INFO:
87879 - ret = get_info(sock_net(sk), user, len, 0);
87880 + ret = get_info(sock_net(sk), user, *len, 0);
87881 break;
87882
87883 case IP6T_SO_GET_ENTRIES:
87884 diff --git a/net/ipv6/netfilter/ip6t_NPT.c b/net/ipv6/netfilter/ip6t_NPT.c
87885 index 83acc14..0ea43c7 100644
87886 --- a/net/ipv6/netfilter/ip6t_NPT.c
87887 +++ b/net/ipv6/netfilter/ip6t_NPT.c
87888 @@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
87889 if (pfx_len - i >= 32)
87890 mask = 0;
87891 else
87892 - mask = htonl(~((1 << (pfx_len - i)) - 1));
87893 + mask = htonl((1 << (i - pfx_len + 32)) - 1);
87894
87895 idx = i / 32;
87896 addr->s6_addr32[idx] &= mask;
87897 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
87898 index 2f3a018..8bca195 100644
87899 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
87900 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
87901 @@ -89,12 +89,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
87902
87903 static int nf_ct_frag6_sysctl_register(struct net *net)
87904 {
87905 - struct ctl_table *table;
87906 + ctl_table_no_const *table = NULL;
87907 struct ctl_table_header *hdr;
87908
87909 - table = nf_ct_frag6_sysctl_table;
87910 if (!net_eq(net, &init_net)) {
87911 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
87912 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
87913 GFP_KERNEL);
87914 if (table == NULL)
87915 goto err_alloc;
87916 @@ -102,9 +101,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87917 table[0].data = &net->ipv6.frags.high_thresh;
87918 table[1].data = &net->ipv6.frags.low_thresh;
87919 table[2].data = &net->ipv6.frags.timeout;
87920 - }
87921 -
87922 - hdr = register_net_sysctl(net, "net/netfilter", table);
87923 + hdr = register_net_sysctl(net, "net/netfilter", table);
87924 + } else
87925 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
87926 if (hdr == NULL)
87927 goto err_reg;
87928
87929 @@ -112,8 +111,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
87930 return 0;
87931
87932 err_reg:
87933 - if (!net_eq(net, &init_net))
87934 - kfree(table);
87935 + kfree(table);
87936 err_alloc:
87937 return -ENOMEM;
87938 }
87939 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
87940 index 70fa814..d70c28c 100644
87941 --- a/net/ipv6/raw.c
87942 +++ b/net/ipv6/raw.c
87943 @@ -379,7 +379,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
87944 {
87945 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
87946 skb_checksum_complete(skb)) {
87947 - atomic_inc(&sk->sk_drops);
87948 + atomic_inc_unchecked(&sk->sk_drops);
87949 kfree_skb(skb);
87950 return NET_RX_DROP;
87951 }
87952 @@ -407,7 +407,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87953 struct raw6_sock *rp = raw6_sk(sk);
87954
87955 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
87956 - atomic_inc(&sk->sk_drops);
87957 + atomic_inc_unchecked(&sk->sk_drops);
87958 kfree_skb(skb);
87959 return NET_RX_DROP;
87960 }
87961 @@ -431,7 +431,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
87962
87963 if (inet->hdrincl) {
87964 if (skb_checksum_complete(skb)) {
87965 - atomic_inc(&sk->sk_drops);
87966 + atomic_inc_unchecked(&sk->sk_drops);
87967 kfree_skb(skb);
87968 return NET_RX_DROP;
87969 }
87970 @@ -604,7 +604,7 @@ out:
87971 return err;
87972 }
87973
87974 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
87975 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
87976 struct flowi6 *fl6, struct dst_entry **dstp,
87977 unsigned int flags)
87978 {
87979 @@ -916,12 +916,15 @@ do_confirm:
87980 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
87981 char __user *optval, int optlen)
87982 {
87983 + struct icmp6_filter filter;
87984 +
87985 switch (optname) {
87986 case ICMPV6_FILTER:
87987 if (optlen > sizeof(struct icmp6_filter))
87988 optlen = sizeof(struct icmp6_filter);
87989 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
87990 + if (copy_from_user(&filter, optval, optlen))
87991 return -EFAULT;
87992 + raw6_sk(sk)->filter = filter;
87993 return 0;
87994 default:
87995 return -ENOPROTOOPT;
87996 @@ -934,6 +937,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
87997 char __user *optval, int __user *optlen)
87998 {
87999 int len;
88000 + struct icmp6_filter filter;
88001
88002 switch (optname) {
88003 case ICMPV6_FILTER:
88004 @@ -945,7 +949,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88005 len = sizeof(struct icmp6_filter);
88006 if (put_user(len, optlen))
88007 return -EFAULT;
88008 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88009 + filter = raw6_sk(sk)->filter;
88010 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88011 return -EFAULT;
88012 return 0;
88013 default:
88014 @@ -1253,7 +1258,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88015 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88016 0,
88017 sock_i_ino(sp),
88018 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88019 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88020 }
88021
88022 static int raw6_seq_show(struct seq_file *seq, void *v)
88023 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88024 index d9ba8a2..f3f9e14 100644
88025 --- a/net/ipv6/reassembly.c
88026 +++ b/net/ipv6/reassembly.c
88027 @@ -608,12 +608,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88028
88029 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88030 {
88031 - struct ctl_table *table;
88032 + ctl_table_no_const *table = NULL;
88033 struct ctl_table_header *hdr;
88034
88035 - table = ip6_frags_ns_ctl_table;
88036 if (!net_eq(net, &init_net)) {
88037 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88038 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88039 if (table == NULL)
88040 goto err_alloc;
88041
88042 @@ -624,9 +623,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88043 /* Don't export sysctls to unprivileged users */
88044 if (net->user_ns != &init_user_ns)
88045 table[0].procname = NULL;
88046 - }
88047 + hdr = register_net_sysctl(net, "net/ipv6", table);
88048 + } else
88049 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88050
88051 - hdr = register_net_sysctl(net, "net/ipv6", table);
88052 if (hdr == NULL)
88053 goto err_reg;
88054
88055 @@ -634,8 +634,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88056 return 0;
88057
88058 err_reg:
88059 - if (!net_eq(net, &init_net))
88060 - kfree(table);
88061 + kfree(table);
88062 err_alloc:
88063 return -ENOMEM;
88064 }
88065 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88066 index 5845613..3af8fc7 100644
88067 --- a/net/ipv6/route.c
88068 +++ b/net/ipv6/route.c
88069 @@ -2966,7 +2966,7 @@ ctl_table ipv6_route_table_template[] = {
88070
88071 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88072 {
88073 - struct ctl_table *table;
88074 + ctl_table_no_const *table;
88075
88076 table = kmemdup(ipv6_route_table_template,
88077 sizeof(ipv6_route_table_template),
88078 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88079 index cfba99b..20ca511 100644
88080 --- a/net/ipv6/sit.c
88081 +++ b/net/ipv6/sit.c
88082 @@ -72,7 +72,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
88083 static int ipip6_tunnel_init(struct net_device *dev);
88084 static void ipip6_tunnel_setup(struct net_device *dev);
88085 static void ipip6_dev_free(struct net_device *dev);
88086 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88087 +static struct rtnl_link_ops sit_link_ops;
88088
88089 static int sit_net_id __read_mostly;
88090 struct sit_net {
88091 @@ -1463,7 +1463,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88092 #endif
88093 };
88094
88095 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88096 +static struct rtnl_link_ops sit_link_ops = {
88097 .kind = "sit",
88098 .maxtype = IFLA_IPTUN_MAX,
88099 .policy = ipip6_policy,
88100 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88101 index e85c48b..b8268d3 100644
88102 --- a/net/ipv6/sysctl_net_ipv6.c
88103 +++ b/net/ipv6/sysctl_net_ipv6.c
88104 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88105
88106 static int __net_init ipv6_sysctl_net_init(struct net *net)
88107 {
88108 - struct ctl_table *ipv6_table;
88109 + ctl_table_no_const *ipv6_table;
88110 struct ctl_table *ipv6_route_table;
88111 struct ctl_table *ipv6_icmp_table;
88112 int err;
88113 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88114 index 8d19346..f122ba5 100644
88115 --- a/net/ipv6/tcp_ipv6.c
88116 +++ b/net/ipv6/tcp_ipv6.c
88117 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88118 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88119 }
88120
88121 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88122 +extern int grsec_enable_blackhole;
88123 +#endif
88124 +
88125 static void tcp_v6_hash(struct sock *sk)
88126 {
88127 if (sk->sk_state != TCP_CLOSE) {
88128 @@ -386,6 +390,7 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
88129
88130 if (dst)
88131 dst->ops->redirect(dst, sk, skb);
88132 + goto out;
88133 }
88134
88135 if (type == ICMPV6_PKT_TOOBIG) {
88136 @@ -1440,6 +1445,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88137 return 0;
88138
88139 reset:
88140 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88141 + if (!grsec_enable_blackhole)
88142 +#endif
88143 tcp_v6_send_reset(sk, skb);
88144 discard:
88145 if (opt_skb)
88146 @@ -1521,12 +1529,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88147 TCP_SKB_CB(skb)->sacked = 0;
88148
88149 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88150 - if (!sk)
88151 + if (!sk) {
88152 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88153 + ret = 1;
88154 +#endif
88155 goto no_tcp_socket;
88156 + }
88157
88158 process:
88159 - if (sk->sk_state == TCP_TIME_WAIT)
88160 + if (sk->sk_state == TCP_TIME_WAIT) {
88161 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88162 + ret = 2;
88163 +#endif
88164 goto do_time_wait;
88165 + }
88166
88167 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88168 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88169 @@ -1575,6 +1591,10 @@ no_tcp_socket:
88170 bad_packet:
88171 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88172 } else {
88173 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88174 + if (!grsec_enable_blackhole || (ret == 1 &&
88175 + (skb->dev->flags & IFF_LOOPBACK)))
88176 +#endif
88177 tcp_v6_send_reset(NULL, skb);
88178 }
88179
88180 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88181 index fb08329..2d6919e 100644
88182 --- a/net/ipv6/udp.c
88183 +++ b/net/ipv6/udp.c
88184 @@ -51,6 +51,10 @@
88185 #include <trace/events/skb.h>
88186 #include "udp_impl.h"
88187
88188 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88189 +extern int grsec_enable_blackhole;
88190 +#endif
88191 +
88192 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88193 {
88194 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88195 @@ -395,7 +399,7 @@ try_again:
88196 if (unlikely(err)) {
88197 trace_kfree_skb(skb, udpv6_recvmsg);
88198 if (!peeked) {
88199 - atomic_inc(&sk->sk_drops);
88200 + atomic_inc_unchecked(&sk->sk_drops);
88201 if (is_udp4)
88202 UDP_INC_STATS_USER(sock_net(sk),
88203 UDP_MIB_INERRORS,
88204 @@ -633,7 +637,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
88205 return rc;
88206 drop:
88207 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88208 - atomic_inc(&sk->sk_drops);
88209 + atomic_inc_unchecked(&sk->sk_drops);
88210 kfree_skb(skb);
88211 return -1;
88212 }
88213 @@ -691,7 +695,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88214 if (likely(skb1 == NULL))
88215 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88216 if (!skb1) {
88217 - atomic_inc(&sk->sk_drops);
88218 + atomic_inc_unchecked(&sk->sk_drops);
88219 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88220 IS_UDPLITE(sk));
88221 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88222 @@ -862,6 +866,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88223 goto discard;
88224
88225 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88226 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88227 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88228 +#endif
88229 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88230
88231 kfree_skb(skb);
88232 @@ -1379,7 +1386,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88233 0,
88234 sock_i_ino(sp),
88235 atomic_read(&sp->sk_refcnt), sp,
88236 - atomic_read(&sp->sk_drops));
88237 + atomic_read_unchecked(&sp->sk_drops));
88238 }
88239
88240 int udp6_seq_show(struct seq_file *seq, void *v)
88241 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88242 index a68c88c..d55b0c5 100644
88243 --- a/net/irda/ircomm/ircomm_tty.c
88244 +++ b/net/irda/ircomm/ircomm_tty.c
88245 @@ -312,12 +312,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88246 add_wait_queue(&port->open_wait, &wait);
88247
88248 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88249 - __FILE__, __LINE__, tty->driver->name, port->count);
88250 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88251
88252 spin_lock_irqsave(&port->lock, flags);
88253 if (!tty_hung_up_p(filp)) {
88254 extra_count = 1;
88255 - port->count--;
88256 + atomic_dec(&port->count);
88257 }
88258 spin_unlock_irqrestore(&port->lock, flags);
88259 port->blocked_open++;
88260 @@ -353,7 +353,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88261 }
88262
88263 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88264 - __FILE__, __LINE__, tty->driver->name, port->count);
88265 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88266
88267 schedule();
88268 }
88269 @@ -364,13 +364,13 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88270 if (extra_count) {
88271 /* ++ is not atomic, so this should be protected - Jean II */
88272 spin_lock_irqsave(&port->lock, flags);
88273 - port->count++;
88274 + atomic_inc(&port->count);
88275 spin_unlock_irqrestore(&port->lock, flags);
88276 }
88277 port->blocked_open--;
88278
88279 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88280 - __FILE__, __LINE__, tty->driver->name, port->count);
88281 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88282
88283 if (!retval)
88284 port->flags |= ASYNC_NORMAL_ACTIVE;
88285 @@ -444,12 +444,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88286
88287 /* ++ is not atomic, so this should be protected - Jean II */
88288 spin_lock_irqsave(&self->port.lock, flags);
88289 - self->port.count++;
88290 + atomic_inc(&self->port.count);
88291 spin_unlock_irqrestore(&self->port.lock, flags);
88292 tty_port_tty_set(&self->port, tty);
88293
88294 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88295 - self->line, self->port.count);
88296 + self->line, atomic_read(&self->port.count));
88297
88298 /* Not really used by us, but lets do it anyway */
88299 tty->low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88300 @@ -986,7 +986,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88301 tty_kref_put(port->tty);
88302 }
88303 port->tty = NULL;
88304 - port->count = 0;
88305 + atomic_set(&port->count, 0);
88306 spin_unlock_irqrestore(&port->lock, flags);
88307
88308 wake_up_interruptible(&port->open_wait);
88309 @@ -1343,7 +1343,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88310 seq_putc(m, '\n');
88311
88312 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88313 - seq_printf(m, "Open count: %d\n", self->port.count);
88314 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88315 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88316 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88317
88318 diff --git a/net/irda/iriap.c b/net/irda/iriap.c
88319 index e71e85b..29340a9 100644
88320 --- a/net/irda/iriap.c
88321 +++ b/net/irda/iriap.c
88322 @@ -495,8 +495,11 @@ static void iriap_getvaluebyclass_confirm(struct iriap_cb *self,
88323 /* case CS_ISO_8859_9: */
88324 /* case CS_UNICODE: */
88325 default:
88326 - IRDA_DEBUG(0, "%s(), charset %s, not supported\n",
88327 - __func__, ias_charset_types[charset]);
88328 + IRDA_DEBUG(0, "%s(), charset [%d] %s, not supported\n",
88329 + __func__, charset,
88330 + charset < ARRAY_SIZE(ias_charset_types) ?
88331 + ias_charset_types[charset] :
88332 + "(unknown)");
88333
88334 /* Aborting, close connection! */
88335 iriap_disconnect_request(self);
88336 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88337 index cd6f7a9..e63fe89 100644
88338 --- a/net/iucv/af_iucv.c
88339 +++ b/net/iucv/af_iucv.c
88340 @@ -782,10 +782,10 @@ static int iucv_sock_autobind(struct sock *sk)
88341
88342 write_lock_bh(&iucv_sk_list.lock);
88343
88344 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88345 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88346 while (__iucv_get_sock_by_name(name)) {
88347 sprintf(name, "%08x",
88348 - atomic_inc_return(&iucv_sk_list.autobind_name));
88349 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88350 }
88351
88352 write_unlock_bh(&iucv_sk_list.lock);
88353 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88354 index df08250..02021fe 100644
88355 --- a/net/iucv/iucv.c
88356 +++ b/net/iucv/iucv.c
88357 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88358 return NOTIFY_OK;
88359 }
88360
88361 -static struct notifier_block __refdata iucv_cpu_notifier = {
88362 +static struct notifier_block iucv_cpu_notifier = {
88363 .notifier_call = iucv_cpu_notify,
88364 };
88365
88366 diff --git a/net/key/af_key.c b/net/key/af_key.c
88367 index 5b426a6..970032b 100644
88368 --- a/net/key/af_key.c
88369 +++ b/net/key/af_key.c
88370 @@ -3019,10 +3019,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88371 static u32 get_acqseq(void)
88372 {
88373 u32 res;
88374 - static atomic_t acqseq;
88375 + static atomic_unchecked_t acqseq;
88376
88377 do {
88378 - res = atomic_inc_return(&acqseq);
88379 + res = atomic_inc_return_unchecked(&acqseq);
88380 } while (!res);
88381 return res;
88382 }
88383 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88384 index 49c48c6..9e72ff4 100644
88385 --- a/net/mac80211/cfg.c
88386 +++ b/net/mac80211/cfg.c
88387 @@ -790,7 +790,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88388 ret = ieee80211_vif_use_channel(sdata, chandef,
88389 IEEE80211_CHANCTX_EXCLUSIVE);
88390 }
88391 - } else if (local->open_count == local->monitors) {
88392 + } else if (local_read(&local->open_count) == local->monitors) {
88393 local->_oper_channel = chandef->chan;
88394 local->_oper_channel_type = cfg80211_get_chandef_type(chandef);
88395 ieee80211_hw_config(local, 0);
88396 @@ -2718,7 +2718,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88397 else
88398 local->probe_req_reg--;
88399
88400 - if (!local->open_count)
88401 + if (!local_read(&local->open_count))
88402 break;
88403
88404 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88405 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88406 index 55d8f89..bec0c2b 100644
88407 --- a/net/mac80211/ieee80211_i.h
88408 +++ b/net/mac80211/ieee80211_i.h
88409 @@ -28,6 +28,7 @@
88410 #include <net/ieee80211_radiotap.h>
88411 #include <net/cfg80211.h>
88412 #include <net/mac80211.h>
88413 +#include <asm/local.h>
88414 #include "key.h"
88415 #include "sta_info.h"
88416 #include "debug.h"
88417 @@ -910,7 +911,7 @@ struct ieee80211_local {
88418 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88419 spinlock_t queue_stop_reason_lock;
88420
88421 - int open_count;
88422 + local_t open_count;
88423 int monitors, cooked_mntrs;
88424 /* number of interfaces with corresponding FIF_ flags */
88425 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88426 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88427 index 8be854e..ad72a69 100644
88428 --- a/net/mac80211/iface.c
88429 +++ b/net/mac80211/iface.c
88430 @@ -546,7 +546,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88431 break;
88432 }
88433
88434 - if (local->open_count == 0) {
88435 + if (local_read(&local->open_count) == 0) {
88436 res = drv_start(local);
88437 if (res)
88438 goto err_del_bss;
88439 @@ -591,7 +591,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88440 break;
88441 }
88442
88443 - if (local->monitors == 0 && local->open_count == 0) {
88444 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88445 res = ieee80211_add_virtual_monitor(local);
88446 if (res)
88447 goto err_stop;
88448 @@ -699,7 +699,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88449 mutex_unlock(&local->mtx);
88450
88451 if (coming_up)
88452 - local->open_count++;
88453 + local_inc(&local->open_count);
88454
88455 if (hw_reconf_flags)
88456 ieee80211_hw_config(local, hw_reconf_flags);
88457 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88458 err_del_interface:
88459 drv_remove_interface(local, sdata);
88460 err_stop:
88461 - if (!local->open_count)
88462 + if (!local_read(&local->open_count))
88463 drv_stop(local);
88464 err_del_bss:
88465 sdata->bss = NULL;
88466 @@ -827,7 +827,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88467 }
88468
88469 if (going_down)
88470 - local->open_count--;
88471 + local_dec(&local->open_count);
88472
88473 switch (sdata->vif.type) {
88474 case NL80211_IFTYPE_AP_VLAN:
88475 @@ -884,7 +884,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88476
88477 ieee80211_recalc_ps(local, -1);
88478
88479 - if (local->open_count == 0) {
88480 + if (local_read(&local->open_count) == 0) {
88481 if (local->ops->napi_poll)
88482 napi_disable(&local->napi);
88483 ieee80211_clear_tx_pending(local);
88484 @@ -910,7 +910,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88485 }
88486 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88487
88488 - if (local->monitors == local->open_count && local->monitors > 0)
88489 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88490 ieee80211_add_virtual_monitor(local);
88491 }
88492
88493 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88494 index 1b087ff..bf600e9 100644
88495 --- a/net/mac80211/main.c
88496 +++ b/net/mac80211/main.c
88497 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88498 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88499 IEEE80211_CONF_CHANGE_POWER);
88500
88501 - if (changed && local->open_count) {
88502 + if (changed && local_read(&local->open_count)) {
88503 ret = drv_config(local, changed);
88504 /*
88505 * Goal:
88506 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88507 index 79a48f3..5e185c9 100644
88508 --- a/net/mac80211/pm.c
88509 +++ b/net/mac80211/pm.c
88510 @@ -35,7 +35,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88511 struct sta_info *sta;
88512 struct ieee80211_chanctx *ctx;
88513
88514 - if (!local->open_count)
88515 + if (!local_read(&local->open_count))
88516 goto suspend;
88517
88518 ieee80211_scan_cancel(local);
88519 @@ -73,7 +73,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88520 cancel_work_sync(&local->dynamic_ps_enable_work);
88521 del_timer_sync(&local->dynamic_ps_timer);
88522
88523 - local->wowlan = wowlan && local->open_count;
88524 + local->wowlan = wowlan && local_read(&local->open_count);
88525 if (local->wowlan) {
88526 int err = drv_suspend(local, wowlan);
88527 if (err < 0) {
88528 @@ -187,7 +187,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88529 mutex_unlock(&local->chanctx_mtx);
88530
88531 /* stop hardware - this must stop RX */
88532 - if (local->open_count)
88533 + if (local_read(&local->open_count))
88534 ieee80211_stop_device(local);
88535
88536 suspend:
88537 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88538 index dd88381..eef4dd6 100644
88539 --- a/net/mac80211/rate.c
88540 +++ b/net/mac80211/rate.c
88541 @@ -493,7 +493,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88542
88543 ASSERT_RTNL();
88544
88545 - if (local->open_count)
88546 + if (local_read(&local->open_count))
88547 return -EBUSY;
88548
88549 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88550 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88551 index c97a065..ff61928 100644
88552 --- a/net/mac80211/rc80211_pid_debugfs.c
88553 +++ b/net/mac80211/rc80211_pid_debugfs.c
88554 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88555
88556 spin_unlock_irqrestore(&events->lock, status);
88557
88558 - if (copy_to_user(buf, pb, p))
88559 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88560 return -EFAULT;
88561
88562 return p;
88563 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88564 index f11e8c5..08d0013 100644
88565 --- a/net/mac80211/util.c
88566 +++ b/net/mac80211/util.c
88567 @@ -1380,7 +1380,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88568 }
88569 #endif
88570 /* everything else happens only if HW was up & running */
88571 - if (!local->open_count)
88572 + if (!local_read(&local->open_count))
88573 goto wake_up;
88574
88575 /*
88576 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88577 index 49e96df..63a51c3 100644
88578 --- a/net/netfilter/Kconfig
88579 +++ b/net/netfilter/Kconfig
88580 @@ -936,6 +936,16 @@ config NETFILTER_XT_MATCH_ESP
88581
88582 To compile it as a module, choose M here. If unsure, say N.
88583
88584 +config NETFILTER_XT_MATCH_GRADM
88585 + tristate '"gradm" match support'
88586 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
88587 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
88588 + ---help---
88589 + The gradm match allows to match on grsecurity RBAC being enabled.
88590 + It is useful when iptables rules are applied early on bootup to
88591 + prevent connections to the machine (except from a trusted host)
88592 + while the RBAC system is disabled.
88593 +
88594 config NETFILTER_XT_MATCH_HASHLIMIT
88595 tristate '"hashlimit" match support'
88596 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
88597 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
88598 index 3259697..54d5393 100644
88599 --- a/net/netfilter/Makefile
88600 +++ b/net/netfilter/Makefile
88601 @@ -109,6 +109,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
88602 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
88603 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
88604 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
88605 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
88606 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
88607 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
88608 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
88609 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
88610 index 6d6d8f2..a676749 100644
88611 --- a/net/netfilter/ipset/ip_set_core.c
88612 +++ b/net/netfilter/ipset/ip_set_core.c
88613 @@ -1800,7 +1800,7 @@ done:
88614 return ret;
88615 }
88616
88617 -static struct nf_sockopt_ops so_set __read_mostly = {
88618 +static struct nf_sockopt_ops so_set = {
88619 .pf = PF_INET,
88620 .get_optmin = SO_IP_SET,
88621 .get_optmax = SO_IP_SET + 1,
88622 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
88623 index 30e764a..c3b6a9d 100644
88624 --- a/net/netfilter/ipvs/ip_vs_conn.c
88625 +++ b/net/netfilter/ipvs/ip_vs_conn.c
88626 @@ -554,7 +554,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
88627 /* Increase the refcnt counter of the dest */
88628 atomic_inc(&dest->refcnt);
88629
88630 - conn_flags = atomic_read(&dest->conn_flags);
88631 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
88632 if (cp->protocol != IPPROTO_UDP)
88633 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
88634 flags = cp->flags;
88635 @@ -899,7 +899,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
88636 atomic_set(&cp->refcnt, 1);
88637
88638 atomic_set(&cp->n_control, 0);
88639 - atomic_set(&cp->in_pkts, 0);
88640 + atomic_set_unchecked(&cp->in_pkts, 0);
88641
88642 atomic_inc(&ipvs->conn_count);
88643 if (flags & IP_VS_CONN_F_NO_CPORT)
88644 @@ -1180,7 +1180,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
88645
88646 /* Don't drop the entry if its number of incoming packets is not
88647 located in [0, 8] */
88648 - i = atomic_read(&cp->in_pkts);
88649 + i = atomic_read_unchecked(&cp->in_pkts);
88650 if (i > 8 || i < 0) return 0;
88651
88652 if (!todrop_rate[i]) return 0;
88653 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
88654 index 47edf5a..235b07d 100644
88655 --- a/net/netfilter/ipvs/ip_vs_core.c
88656 +++ b/net/netfilter/ipvs/ip_vs_core.c
88657 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
88658 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
88659 /* do not touch skb anymore */
88660
88661 - atomic_inc(&cp->in_pkts);
88662 + atomic_inc_unchecked(&cp->in_pkts);
88663 ip_vs_conn_put(cp);
88664 return ret;
88665 }
88666 @@ -1691,7 +1691,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
88667 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
88668 pkts = sysctl_sync_threshold(ipvs);
88669 else
88670 - pkts = atomic_add_return(1, &cp->in_pkts);
88671 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88672
88673 if (ipvs->sync_state & IP_VS_STATE_MASTER)
88674 ip_vs_sync_conn(net, cp, pkts);
88675 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
88676 index ec664cb..7f34a77 100644
88677 --- a/net/netfilter/ipvs/ip_vs_ctl.c
88678 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
88679 @@ -787,7 +787,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
88680 ip_vs_rs_hash(ipvs, dest);
88681 write_unlock_bh(&ipvs->rs_lock);
88682 }
88683 - atomic_set(&dest->conn_flags, conn_flags);
88684 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
88685
88686 /* bind the service */
88687 if (!dest->svc) {
88688 @@ -1688,7 +1688,7 @@ proc_do_sync_ports(ctl_table *table, int write,
88689 * align with netns init in ip_vs_control_net_init()
88690 */
88691
88692 -static struct ctl_table vs_vars[] = {
88693 +static ctl_table_no_const vs_vars[] __read_only = {
88694 {
88695 .procname = "amemthresh",
88696 .maxlen = sizeof(int),
88697 @@ -2081,7 +2081,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88698 " %-7s %-6d %-10d %-10d\n",
88699 &dest->addr.in6,
88700 ntohs(dest->port),
88701 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88702 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88703 atomic_read(&dest->weight),
88704 atomic_read(&dest->activeconns),
88705 atomic_read(&dest->inactconns));
88706 @@ -2092,7 +2092,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
88707 "%-7s %-6d %-10d %-10d\n",
88708 ntohl(dest->addr.ip),
88709 ntohs(dest->port),
88710 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
88711 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
88712 atomic_read(&dest->weight),
88713 atomic_read(&dest->activeconns),
88714 atomic_read(&dest->inactconns));
88715 @@ -2562,7 +2562,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
88716
88717 entry.addr = dest->addr.ip;
88718 entry.port = dest->port;
88719 - entry.conn_flags = atomic_read(&dest->conn_flags);
88720 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
88721 entry.weight = atomic_read(&dest->weight);
88722 entry.u_threshold = dest->u_threshold;
88723 entry.l_threshold = dest->l_threshold;
88724 @@ -3098,7 +3098,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
88725 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
88726 nla_put_u16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
88727 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
88728 - (atomic_read(&dest->conn_flags) &
88729 + (atomic_read_unchecked(&dest->conn_flags) &
88730 IP_VS_CONN_F_FWD_MASK)) ||
88731 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
88732 atomic_read(&dest->weight)) ||
88733 @@ -3688,7 +3688,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
88734 {
88735 int idx;
88736 struct netns_ipvs *ipvs = net_ipvs(net);
88737 - struct ctl_table *tbl;
88738 + ctl_table_no_const *tbl;
88739
88740 atomic_set(&ipvs->dropentry, 0);
88741 spin_lock_init(&ipvs->dropentry_lock);
88742 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
88743 index fdd89b9..bd96aa9 100644
88744 --- a/net/netfilter/ipvs/ip_vs_lblc.c
88745 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
88746 @@ -115,7 +115,7 @@ struct ip_vs_lblc_table {
88747 * IPVS LBLC sysctl table
88748 */
88749 #ifdef CONFIG_SYSCTL
88750 -static ctl_table vs_vars_table[] = {
88751 +static ctl_table_no_const vs_vars_table[] __read_only = {
88752 {
88753 .procname = "lblc_expiration",
88754 .data = NULL,
88755 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
88756 index c03b6a3..8ce3681 100644
88757 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
88758 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
88759 @@ -288,7 +288,7 @@ struct ip_vs_lblcr_table {
88760 * IPVS LBLCR sysctl table
88761 */
88762
88763 -static ctl_table vs_vars_table[] = {
88764 +static ctl_table_no_const vs_vars_table[] __read_only = {
88765 {
88766 .procname = "lblcr_expiration",
88767 .data = NULL,
88768 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
88769 index 44fd10c..2a163b3 100644
88770 --- a/net/netfilter/ipvs/ip_vs_sync.c
88771 +++ b/net/netfilter/ipvs/ip_vs_sync.c
88772 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
88773 cp = cp->control;
88774 if (cp) {
88775 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88776 - pkts = atomic_add_return(1, &cp->in_pkts);
88777 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88778 else
88779 pkts = sysctl_sync_threshold(ipvs);
88780 ip_vs_sync_conn(net, cp->control, pkts);
88781 @@ -758,7 +758,7 @@ control:
88782 if (!cp)
88783 return;
88784 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
88785 - pkts = atomic_add_return(1, &cp->in_pkts);
88786 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
88787 else
88788 pkts = sysctl_sync_threshold(ipvs);
88789 goto sloop;
88790 @@ -885,7 +885,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
88791
88792 if (opt)
88793 memcpy(&cp->in_seq, opt, sizeof(*opt));
88794 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88795 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
88796 cp->state = state;
88797 cp->old_state = cp->state;
88798 /*
88799 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
88800 index ee6b7a9..f9a89f6 100644
88801 --- a/net/netfilter/ipvs/ip_vs_xmit.c
88802 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
88803 @@ -1210,7 +1210,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
88804 else
88805 rc = NF_ACCEPT;
88806 /* do not touch skb anymore */
88807 - atomic_inc(&cp->in_pkts);
88808 + atomic_inc_unchecked(&cp->in_pkts);
88809 goto out;
88810 }
88811
88812 @@ -1332,7 +1332,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
88813 else
88814 rc = NF_ACCEPT;
88815 /* do not touch skb anymore */
88816 - atomic_inc(&cp->in_pkts);
88817 + atomic_inc_unchecked(&cp->in_pkts);
88818 goto out;
88819 }
88820
88821 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
88822 index 7df424e..a527b02 100644
88823 --- a/net/netfilter/nf_conntrack_acct.c
88824 +++ b/net/netfilter/nf_conntrack_acct.c
88825 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
88826 #ifdef CONFIG_SYSCTL
88827 static int nf_conntrack_acct_init_sysctl(struct net *net)
88828 {
88829 - struct ctl_table *table;
88830 + ctl_table_no_const *table;
88831
88832 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
88833 GFP_KERNEL);
88834 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
88835 index e4a0c4f..c263f28 100644
88836 --- a/net/netfilter/nf_conntrack_core.c
88837 +++ b/net/netfilter/nf_conntrack_core.c
88838 @@ -1529,6 +1529,10 @@ err_extend:
88839 #define DYING_NULLS_VAL ((1<<30)+1)
88840 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
88841
88842 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88843 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
88844 +#endif
88845 +
88846 static int nf_conntrack_init_net(struct net *net)
88847 {
88848 int ret;
88849 @@ -1543,7 +1547,11 @@ static int nf_conntrack_init_net(struct net *net)
88850 goto err_stat;
88851 }
88852
88853 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88854 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
88855 +#else
88856 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
88857 +#endif
88858 if (!net->ct.slabname) {
88859 ret = -ENOMEM;
88860 goto err_slabname;
88861 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
88862 index faa978f..1afb18f 100644
88863 --- a/net/netfilter/nf_conntrack_ecache.c
88864 +++ b/net/netfilter/nf_conntrack_ecache.c
88865 @@ -186,7 +186,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
88866 #ifdef CONFIG_SYSCTL
88867 static int nf_conntrack_event_init_sysctl(struct net *net)
88868 {
88869 - struct ctl_table *table;
88870 + ctl_table_no_const *table;
88871
88872 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
88873 GFP_KERNEL);
88874 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
88875 index 884f2b3..d53b33a 100644
88876 --- a/net/netfilter/nf_conntrack_helper.c
88877 +++ b/net/netfilter/nf_conntrack_helper.c
88878 @@ -55,7 +55,7 @@ static struct ctl_table helper_sysctl_table[] = {
88879
88880 static int nf_conntrack_helper_init_sysctl(struct net *net)
88881 {
88882 - struct ctl_table *table;
88883 + ctl_table_no_const *table;
88884
88885 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
88886 GFP_KERNEL);
88887 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
88888 index 51e928d..72a413a 100644
88889 --- a/net/netfilter/nf_conntrack_proto.c
88890 +++ b/net/netfilter/nf_conntrack_proto.c
88891 @@ -51,7 +51,7 @@ nf_ct_register_sysctl(struct net *net,
88892
88893 static void
88894 nf_ct_unregister_sysctl(struct ctl_table_header **header,
88895 - struct ctl_table **table,
88896 + ctl_table_no_const **table,
88897 unsigned int users)
88898 {
88899 if (users > 0)
88900 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
88901 index e7185c6..4ad6c9c 100644
88902 --- a/net/netfilter/nf_conntrack_standalone.c
88903 +++ b/net/netfilter/nf_conntrack_standalone.c
88904 @@ -470,7 +470,7 @@ static ctl_table nf_ct_netfilter_table[] = {
88905
88906 static int nf_conntrack_standalone_init_sysctl(struct net *net)
88907 {
88908 - struct ctl_table *table;
88909 + ctl_table_no_const *table;
88910
88911 if (net_eq(net, &init_net)) {
88912 nf_ct_netfilter_header =
88913 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
88914 index 7ea8026..bc9512d 100644
88915 --- a/net/netfilter/nf_conntrack_timestamp.c
88916 +++ b/net/netfilter/nf_conntrack_timestamp.c
88917 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
88918 #ifdef CONFIG_SYSCTL
88919 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
88920 {
88921 - struct ctl_table *table;
88922 + ctl_table_no_const *table;
88923
88924 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
88925 GFP_KERNEL);
88926 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
88927 index 9e31269..bc4c1b7 100644
88928 --- a/net/netfilter/nf_log.c
88929 +++ b/net/netfilter/nf_log.c
88930 @@ -215,7 +215,7 @@ static const struct file_operations nflog_file_ops = {
88931
88932 #ifdef CONFIG_SYSCTL
88933 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
88934 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
88935 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
88936 static struct ctl_table_header *nf_log_dir_header;
88937
88938 static int nf_log_proc_dostring(ctl_table *table, int write,
88939 @@ -246,14 +246,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
88940 rcu_assign_pointer(nf_loggers[tindex], logger);
88941 mutex_unlock(&nf_log_mutex);
88942 } else {
88943 + ctl_table_no_const nf_log_table = *table;
88944 +
88945 mutex_lock(&nf_log_mutex);
88946 logger = rcu_dereference_protected(nf_loggers[tindex],
88947 lockdep_is_held(&nf_log_mutex));
88948 if (!logger)
88949 - table->data = "NONE";
88950 + nf_log_table.data = "NONE";
88951 else
88952 - table->data = logger->name;
88953 - r = proc_dostring(table, write, buffer, lenp, ppos);
88954 + nf_log_table.data = logger->name;
88955 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
88956 mutex_unlock(&nf_log_mutex);
88957 }
88958
88959 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
88960 index f042ae5..30ea486 100644
88961 --- a/net/netfilter/nf_sockopt.c
88962 +++ b/net/netfilter/nf_sockopt.c
88963 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
88964 }
88965 }
88966
88967 - list_add(&reg->list, &nf_sockopts);
88968 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
88969 out:
88970 mutex_unlock(&nf_sockopt_mutex);
88971 return ret;
88972 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
88973 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
88974 {
88975 mutex_lock(&nf_sockopt_mutex);
88976 - list_del(&reg->list);
88977 + pax_list_del((struct list_head *)&reg->list);
88978 mutex_unlock(&nf_sockopt_mutex);
88979 }
88980 EXPORT_SYMBOL(nf_unregister_sockopt);
88981 diff --git a/net/netfilter/nfnetlink_acct.c b/net/netfilter/nfnetlink_acct.c
88982 index 589d686..dc3fd5d 100644
88983 --- a/net/netfilter/nfnetlink_acct.c
88984 +++ b/net/netfilter/nfnetlink_acct.c
88985 @@ -49,6 +49,8 @@ nfnl_acct_new(struct sock *nfnl, struct sk_buff *skb,
88986 return -EINVAL;
88987
88988 acct_name = nla_data(tb[NFACCT_NAME]);
88989 + if (strlen(acct_name) == 0)
88990 + return -EINVAL;
88991
88992 list_for_each_entry(nfacct, &nfnl_acct_list, head) {
88993 if (strncmp(nfacct->name, acct_name, NFACCT_NAME_MAX) != 0)
88994 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
88995 index 92fd8ec..3f6ea4b 100644
88996 --- a/net/netfilter/nfnetlink_log.c
88997 +++ b/net/netfilter/nfnetlink_log.c
88998 @@ -72,7 +72,7 @@ struct nfulnl_instance {
88999 };
89000
89001 static DEFINE_SPINLOCK(instances_lock);
89002 -static atomic_t global_seq;
89003 +static atomic_unchecked_t global_seq;
89004
89005 #define INSTANCE_BUCKETS 16
89006 static struct hlist_head instance_table[INSTANCE_BUCKETS];
89007 @@ -537,7 +537,7 @@ __build_packet_message(struct nfulnl_instance *inst,
89008 /* global sequence number */
89009 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89010 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89011 - htonl(atomic_inc_return(&global_seq))))
89012 + htonl(atomic_inc_return_unchecked(&global_seq))))
89013 goto nla_put_failure;
89014
89015 if (data_len) {
89016 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
89017 index 3158d87..39006c9 100644
89018 --- a/net/netfilter/nfnetlink_queue_core.c
89019 +++ b/net/netfilter/nfnetlink_queue_core.c
89020 @@ -1064,8 +1064,10 @@ static int __init nfnetlink_queue_init(void)
89021
89022 #ifdef CONFIG_PROC_FS
89023 if (!proc_create("nfnetlink_queue", 0440,
89024 - proc_net_netfilter, &nfqnl_file_ops))
89025 + proc_net_netfilter, &nfqnl_file_ops)) {
89026 + status = -ENOMEM;
89027 goto cleanup_subsys;
89028 + }
89029 #endif
89030
89031 register_netdevice_notifier(&nfqnl_dev_notifier);
89032 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89033 new file mode 100644
89034 index 0000000..c566332
89035 --- /dev/null
89036 +++ b/net/netfilter/xt_gradm.c
89037 @@ -0,0 +1,51 @@
89038 +/*
89039 + * gradm match for netfilter
89040 + * Copyright © Zbigniew Krzystolik, 2010
89041 + *
89042 + * This program is free software; you can redistribute it and/or modify
89043 + * it under the terms of the GNU General Public License; either version
89044 + * 2 or 3 as published by the Free Software Foundation.
89045 + */
89046 +#include <linux/module.h>
89047 +#include <linux/moduleparam.h>
89048 +#include <linux/skbuff.h>
89049 +#include <linux/netfilter/x_tables.h>
89050 +#include <linux/grsecurity.h>
89051 +#include <linux/netfilter/xt_gradm.h>
89052 +
89053 +static bool
89054 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89055 +{
89056 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89057 + bool retval = false;
89058 + if (gr_acl_is_enabled())
89059 + retval = true;
89060 + return retval ^ info->invflags;
89061 +}
89062 +
89063 +static struct xt_match gradm_mt_reg __read_mostly = {
89064 + .name = "gradm",
89065 + .revision = 0,
89066 + .family = NFPROTO_UNSPEC,
89067 + .match = gradm_mt,
89068 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89069 + .me = THIS_MODULE,
89070 +};
89071 +
89072 +static int __init gradm_mt_init(void)
89073 +{
89074 + return xt_register_match(&gradm_mt_reg);
89075 +}
89076 +
89077 +static void __exit gradm_mt_exit(void)
89078 +{
89079 + xt_unregister_match(&gradm_mt_reg);
89080 +}
89081 +
89082 +module_init(gradm_mt_init);
89083 +module_exit(gradm_mt_exit);
89084 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89085 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89086 +MODULE_LICENSE("GPL");
89087 +MODULE_ALIAS("ipt_gradm");
89088 +MODULE_ALIAS("ip6t_gradm");
89089 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89090 index 4fe4fb4..87a89e5 100644
89091 --- a/net/netfilter/xt_statistic.c
89092 +++ b/net/netfilter/xt_statistic.c
89093 @@ -19,7 +19,7 @@
89094 #include <linux/module.h>
89095
89096 struct xt_statistic_priv {
89097 - atomic_t count;
89098 + atomic_unchecked_t count;
89099 } ____cacheline_aligned_in_smp;
89100
89101 MODULE_LICENSE("GPL");
89102 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89103 break;
89104 case XT_STATISTIC_MODE_NTH:
89105 do {
89106 - oval = atomic_read(&info->master->count);
89107 + oval = atomic_read_unchecked(&info->master->count);
89108 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89109 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89110 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89111 if (nval == 0)
89112 ret = !ret;
89113 break;
89114 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89115 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89116 if (info->master == NULL)
89117 return -ENOMEM;
89118 - atomic_set(&info->master->count, info->u.nth.count);
89119 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89120
89121 return 0;
89122 }
89123 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89124 index c0353d5..fcb0270 100644
89125 --- a/net/netlink/af_netlink.c
89126 +++ b/net/netlink/af_netlink.c
89127 @@ -785,7 +785,7 @@ static void netlink_overrun(struct sock *sk)
89128 sk->sk_error_report(sk);
89129 }
89130 }
89131 - atomic_inc(&sk->sk_drops);
89132 + atomic_inc_unchecked(&sk->sk_drops);
89133 }
89134
89135 static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
89136 @@ -2071,7 +2071,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89137 sk_wmem_alloc_get(s),
89138 nlk->cb,
89139 atomic_read(&s->sk_refcnt),
89140 - atomic_read(&s->sk_drops),
89141 + atomic_read_unchecked(&s->sk_drops),
89142 sock_i_ino(s)
89143 );
89144
89145 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89146 index 5a55be3..7630745 100644
89147 --- a/net/netlink/genetlink.c
89148 +++ b/net/netlink/genetlink.c
89149 @@ -296,18 +296,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89150 goto errout;
89151 }
89152
89153 + pax_open_kernel();
89154 if (ops->dumpit)
89155 - ops->flags |= GENL_CMD_CAP_DUMP;
89156 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89157 if (ops->doit)
89158 - ops->flags |= GENL_CMD_CAP_DO;
89159 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89160 if (ops->policy)
89161 - ops->flags |= GENL_CMD_CAP_HASPOL;
89162 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89163 + pax_close_kernel();
89164
89165 genl_lock();
89166 - list_add_tail(&ops->ops_list, &family->ops_list);
89167 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89168 genl_unlock();
89169
89170 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89171 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89172 err = 0;
89173 errout:
89174 return err;
89175 @@ -337,9 +339,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89176 genl_lock();
89177 list_for_each_entry(rc, &family->ops_list, ops_list) {
89178 if (rc == ops) {
89179 - list_del(&ops->ops_list);
89180 + pax_list_del((struct list_head *)&ops->ops_list);
89181 genl_unlock();
89182 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89183 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89184 return 0;
89185 }
89186 }
89187 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89188 index 7261eb8..44e8ac6 100644
89189 --- a/net/netrom/af_netrom.c
89190 +++ b/net/netrom/af_netrom.c
89191 @@ -838,6 +838,7 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89192 struct sock *sk = sock->sk;
89193 struct nr_sock *nr = nr_sk(sk);
89194
89195 + memset(sax, 0, sizeof(*sax));
89196 lock_sock(sk);
89197 if (peer != 0) {
89198 if (sk->sk_state != TCP_ESTABLISHED) {
89199 @@ -852,7 +853,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89200 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89201 } else {
89202 sax->fsa_ax25.sax25_family = AF_NETROM;
89203 - sax->fsa_ax25.sax25_ndigis = 0;
89204 sax->fsa_ax25.sax25_call = nr->source_addr;
89205 *uaddr_len = sizeof(struct sockaddr_ax25);
89206 }
89207 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89208 index c111bd0..7788ff7 100644
89209 --- a/net/packet/af_packet.c
89210 +++ b/net/packet/af_packet.c
89211 @@ -1578,7 +1578,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89212
89213 spin_lock(&sk->sk_receive_queue.lock);
89214 po->stats.tp_packets++;
89215 - skb->dropcount = atomic_read(&sk->sk_drops);
89216 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89217 __skb_queue_tail(&sk->sk_receive_queue, skb);
89218 spin_unlock(&sk->sk_receive_queue.lock);
89219 sk->sk_data_ready(sk, skb->len);
89220 @@ -1587,7 +1587,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89221 drop_n_acct:
89222 spin_lock(&sk->sk_receive_queue.lock);
89223 po->stats.tp_drops++;
89224 - atomic_inc(&sk->sk_drops);
89225 + atomic_inc_unchecked(&sk->sk_drops);
89226 spin_unlock(&sk->sk_receive_queue.lock);
89227
89228 drop_n_restore:
89229 @@ -2565,6 +2565,7 @@ out:
89230
89231 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89232 {
89233 + struct sock_extended_err ee;
89234 struct sock_exterr_skb *serr;
89235 struct sk_buff *skb, *skb2;
89236 int copied, err;
89237 @@ -2586,8 +2587,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89238 sock_recv_timestamp(msg, sk, skb);
89239
89240 serr = SKB_EXT_ERR(skb);
89241 + ee = serr->ee;
89242 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89243 - sizeof(serr->ee), &serr->ee);
89244 + sizeof ee, &ee);
89245
89246 msg->msg_flags |= MSG_ERRQUEUE;
89247 err = copied;
89248 @@ -3212,7 +3214,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89249 case PACKET_HDRLEN:
89250 if (len > sizeof(int))
89251 len = sizeof(int);
89252 - if (copy_from_user(&val, optval, len))
89253 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89254 return -EFAULT;
89255 switch (val) {
89256 case TPACKET_V1:
89257 @@ -3254,7 +3256,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89258 len = lv;
89259 if (put_user(len, optlen))
89260 return -EFAULT;
89261 - if (copy_to_user(optval, data, len))
89262 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89263 return -EFAULT;
89264 return 0;
89265 }
89266 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89267 index 5a940db..f0b9c12 100644
89268 --- a/net/phonet/af_phonet.c
89269 +++ b/net/phonet/af_phonet.c
89270 @@ -41,7 +41,7 @@ static struct phonet_protocol *phonet_proto_get(unsigned int protocol)
89271 {
89272 struct phonet_protocol *pp;
89273
89274 - if (protocol >= PHONET_NPROTO)
89275 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89276 return NULL;
89277
89278 rcu_read_lock();
89279 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89280 {
89281 int err = 0;
89282
89283 - if (protocol >= PHONET_NPROTO)
89284 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89285 return -EINVAL;
89286
89287 err = proto_register(pp->prot, 1);
89288 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89289 index 576f22c..bc7a71b 100644
89290 --- a/net/phonet/pep.c
89291 +++ b/net/phonet/pep.c
89292 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89293
89294 case PNS_PEP_CTRL_REQ:
89295 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89296 - atomic_inc(&sk->sk_drops);
89297 + atomic_inc_unchecked(&sk->sk_drops);
89298 break;
89299 }
89300 __skb_pull(skb, 4);
89301 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89302 }
89303
89304 if (pn->rx_credits == 0) {
89305 - atomic_inc(&sk->sk_drops);
89306 + atomic_inc_unchecked(&sk->sk_drops);
89307 err = -ENOBUFS;
89308 break;
89309 }
89310 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89311 }
89312
89313 if (pn->rx_credits == 0) {
89314 - atomic_inc(&sk->sk_drops);
89315 + atomic_inc_unchecked(&sk->sk_drops);
89316 err = NET_RX_DROP;
89317 break;
89318 }
89319 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89320 index b7e9827..c264c85 100644
89321 --- a/net/phonet/socket.c
89322 +++ b/net/phonet/socket.c
89323 @@ -615,7 +615,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89324 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89325 sock_i_ino(sk),
89326 atomic_read(&sk->sk_refcnt), sk,
89327 - atomic_read(&sk->sk_drops), &len);
89328 + atomic_read_unchecked(&sk->sk_drops), &len);
89329 }
89330 seq_printf(seq, "%*s\n", 127 - len, "");
89331 return 0;
89332 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89333 index d6bbbbd..61561e4 100644
89334 --- a/net/phonet/sysctl.c
89335 +++ b/net/phonet/sysctl.c
89336 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89337 {
89338 int ret;
89339 int range[2] = {local_port_range[0], local_port_range[1]};
89340 - ctl_table tmp = {
89341 + ctl_table_no_const tmp = {
89342 .data = &range,
89343 .maxlen = sizeof(range),
89344 .mode = table->mode,
89345 diff --git a/net/rds/cong.c b/net/rds/cong.c
89346 index e5b65ac..f3b6fb7 100644
89347 --- a/net/rds/cong.c
89348 +++ b/net/rds/cong.c
89349 @@ -78,7 +78,7 @@
89350 * finds that the saved generation number is smaller than the global generation
89351 * number, it wakes up the process.
89352 */
89353 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89354 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89355
89356 /*
89357 * Congestion monitoring
89358 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89359 rdsdebug("waking map %p for %pI4\n",
89360 map, &map->m_addr);
89361 rds_stats_inc(s_cong_update_received);
89362 - atomic_inc(&rds_cong_generation);
89363 + atomic_inc_unchecked(&rds_cong_generation);
89364 if (waitqueue_active(&map->m_waitq))
89365 wake_up(&map->m_waitq);
89366 if (waitqueue_active(&rds_poll_waitq))
89367 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89368
89369 int rds_cong_updated_since(unsigned long *recent)
89370 {
89371 - unsigned long gen = atomic_read(&rds_cong_generation);
89372 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89373
89374 if (likely(*recent == gen))
89375 return 0;
89376 diff --git a/net/rds/ib.h b/net/rds/ib.h
89377 index 7280ab8..e04f4ea 100644
89378 --- a/net/rds/ib.h
89379 +++ b/net/rds/ib.h
89380 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89381 /* sending acks */
89382 unsigned long i_ack_flags;
89383 #ifdef KERNEL_HAS_ATOMIC64
89384 - atomic64_t i_ack_next; /* next ACK to send */
89385 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89386 #else
89387 spinlock_t i_ack_lock; /* protect i_ack_next */
89388 u64 i_ack_next; /* next ACK to send */
89389 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89390 index 31b74f5..dc1fbfa 100644
89391 --- a/net/rds/ib_cm.c
89392 +++ b/net/rds/ib_cm.c
89393 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89394 /* Clear the ACK state */
89395 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89396 #ifdef KERNEL_HAS_ATOMIC64
89397 - atomic64_set(&ic->i_ack_next, 0);
89398 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89399 #else
89400 ic->i_ack_next = 0;
89401 #endif
89402 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89403 index 8eb9501..0c386ff 100644
89404 --- a/net/rds/ib_recv.c
89405 +++ b/net/rds/ib_recv.c
89406 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89407 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89408 int ack_required)
89409 {
89410 - atomic64_set(&ic->i_ack_next, seq);
89411 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89412 if (ack_required) {
89413 smp_mb__before_clear_bit();
89414 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89415 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89416 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89417 smp_mb__after_clear_bit();
89418
89419 - return atomic64_read(&ic->i_ack_next);
89420 + return atomic64_read_unchecked(&ic->i_ack_next);
89421 }
89422 #endif
89423
89424 diff --git a/net/rds/iw.h b/net/rds/iw.h
89425 index 04ce3b1..48119a6 100644
89426 --- a/net/rds/iw.h
89427 +++ b/net/rds/iw.h
89428 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89429 /* sending acks */
89430 unsigned long i_ack_flags;
89431 #ifdef KERNEL_HAS_ATOMIC64
89432 - atomic64_t i_ack_next; /* next ACK to send */
89433 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89434 #else
89435 spinlock_t i_ack_lock; /* protect i_ack_next */
89436 u64 i_ack_next; /* next ACK to send */
89437 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89438 index a91e1db..cf3053f 100644
89439 --- a/net/rds/iw_cm.c
89440 +++ b/net/rds/iw_cm.c
89441 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89442 /* Clear the ACK state */
89443 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89444 #ifdef KERNEL_HAS_ATOMIC64
89445 - atomic64_set(&ic->i_ack_next, 0);
89446 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89447 #else
89448 ic->i_ack_next = 0;
89449 #endif
89450 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89451 index 4503335..db566b4 100644
89452 --- a/net/rds/iw_recv.c
89453 +++ b/net/rds/iw_recv.c
89454 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89455 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89456 int ack_required)
89457 {
89458 - atomic64_set(&ic->i_ack_next, seq);
89459 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89460 if (ack_required) {
89461 smp_mb__before_clear_bit();
89462 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89463 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89464 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89465 smp_mb__after_clear_bit();
89466
89467 - return atomic64_read(&ic->i_ack_next);
89468 + return atomic64_read_unchecked(&ic->i_ack_next);
89469 }
89470 #endif
89471
89472 diff --git a/net/rds/rds.h b/net/rds/rds.h
89473 index ec1d731..90a3a8d 100644
89474 --- a/net/rds/rds.h
89475 +++ b/net/rds/rds.h
89476 @@ -449,7 +449,7 @@ struct rds_transport {
89477 void (*sync_mr)(void *trans_private, int direction);
89478 void (*free_mr)(void *trans_private, int invalidate);
89479 void (*flush_mrs)(void);
89480 -};
89481 +} __do_const;
89482
89483 struct rds_sock {
89484 struct sock rs_sk;
89485 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89486 index edac9ef..16bcb98 100644
89487 --- a/net/rds/tcp.c
89488 +++ b/net/rds/tcp.c
89489 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89490 int val = 1;
89491
89492 set_fs(KERNEL_DS);
89493 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89494 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89495 sizeof(val));
89496 set_fs(oldfs);
89497 }
89498 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89499 index 81cf5a4..b5826ff 100644
89500 --- a/net/rds/tcp_send.c
89501 +++ b/net/rds/tcp_send.c
89502 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89503
89504 oldfs = get_fs();
89505 set_fs(KERNEL_DS);
89506 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89507 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89508 sizeof(val));
89509 set_fs(oldfs);
89510 }
89511 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89512 index 05996d0..5a1dfe0 100644
89513 --- a/net/rxrpc/af_rxrpc.c
89514 +++ b/net/rxrpc/af_rxrpc.c
89515 @@ -39,7 +39,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89516 __be32 rxrpc_epoch;
89517
89518 /* current debugging ID */
89519 -atomic_t rxrpc_debug_id;
89520 +atomic_unchecked_t rxrpc_debug_id;
89521
89522 /* count of skbs currently in use */
89523 atomic_t rxrpc_n_skbs;
89524 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89525 index e4d9cbc..b229649 100644
89526 --- a/net/rxrpc/ar-ack.c
89527 +++ b/net/rxrpc/ar-ack.c
89528 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89529
89530 _enter("{%d,%d,%d,%d},",
89531 call->acks_hard, call->acks_unacked,
89532 - atomic_read(&call->sequence),
89533 + atomic_read_unchecked(&call->sequence),
89534 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89535
89536 stop = 0;
89537 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89538
89539 /* each Tx packet has a new serial number */
89540 sp->hdr.serial =
89541 - htonl(atomic_inc_return(&call->conn->serial));
89542 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89543
89544 hdr = (struct rxrpc_header *) txb->head;
89545 hdr->serial = sp->hdr.serial;
89546 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89547 */
89548 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89549 {
89550 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89551 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89552 }
89553
89554 /*
89555 @@ -629,7 +629,7 @@ process_further:
89556
89557 latest = ntohl(sp->hdr.serial);
89558 hard = ntohl(ack.firstPacket);
89559 - tx = atomic_read(&call->sequence);
89560 + tx = atomic_read_unchecked(&call->sequence);
89561
89562 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89563 latest,
89564 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89565 goto maybe_reschedule;
89566
89567 send_ACK_with_skew:
89568 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89569 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89570 ntohl(ack.serial));
89571 send_ACK:
89572 mtu = call->conn->trans->peer->if_mtu;
89573 @@ -1173,7 +1173,7 @@ send_ACK:
89574 ackinfo.rxMTU = htonl(5692);
89575 ackinfo.jumbo_max = htonl(4);
89576
89577 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89578 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89579 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89580 ntohl(hdr.serial),
89581 ntohs(ack.maxSkew),
89582 @@ -1191,7 +1191,7 @@ send_ACK:
89583 send_message:
89584 _debug("send message");
89585
89586 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89587 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89588 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89589 send_message_2:
89590
89591 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89592 index a3bbb36..3341fb9 100644
89593 --- a/net/rxrpc/ar-call.c
89594 +++ b/net/rxrpc/ar-call.c
89595 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89596 spin_lock_init(&call->lock);
89597 rwlock_init(&call->state_lock);
89598 atomic_set(&call->usage, 1);
89599 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89600 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89601 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89602
89603 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89604 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
89605 index 4106ca9..a338d7a 100644
89606 --- a/net/rxrpc/ar-connection.c
89607 +++ b/net/rxrpc/ar-connection.c
89608 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
89609 rwlock_init(&conn->lock);
89610 spin_lock_init(&conn->state_lock);
89611 atomic_set(&conn->usage, 1);
89612 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
89613 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89614 conn->avail_calls = RXRPC_MAXCALLS;
89615 conn->size_align = 4;
89616 conn->header_size = sizeof(struct rxrpc_header);
89617 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
89618 index e7ed43a..6afa140 100644
89619 --- a/net/rxrpc/ar-connevent.c
89620 +++ b/net/rxrpc/ar-connevent.c
89621 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
89622
89623 len = iov[0].iov_len + iov[1].iov_len;
89624
89625 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89626 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89627 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
89628
89629 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89630 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
89631 index 529572f..c758ca7 100644
89632 --- a/net/rxrpc/ar-input.c
89633 +++ b/net/rxrpc/ar-input.c
89634 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
89635 /* track the latest serial number on this connection for ACK packet
89636 * information */
89637 serial = ntohl(sp->hdr.serial);
89638 - hi_serial = atomic_read(&call->conn->hi_serial);
89639 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
89640 while (serial > hi_serial)
89641 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
89642 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
89643 serial);
89644
89645 /* request ACK generation for any ACK or DATA packet that requests
89646 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
89647 index a693aca..81e7293 100644
89648 --- a/net/rxrpc/ar-internal.h
89649 +++ b/net/rxrpc/ar-internal.h
89650 @@ -272,8 +272,8 @@ struct rxrpc_connection {
89651 int error; /* error code for local abort */
89652 int debug_id; /* debug ID for printks */
89653 unsigned int call_counter; /* call ID counter */
89654 - atomic_t serial; /* packet serial number counter */
89655 - atomic_t hi_serial; /* highest serial number received */
89656 + atomic_unchecked_t serial; /* packet serial number counter */
89657 + atomic_unchecked_t hi_serial; /* highest serial number received */
89658 u8 avail_calls; /* number of calls available */
89659 u8 size_align; /* data size alignment (for security) */
89660 u8 header_size; /* rxrpc + security header size */
89661 @@ -346,7 +346,7 @@ struct rxrpc_call {
89662 spinlock_t lock;
89663 rwlock_t state_lock; /* lock for state transition */
89664 atomic_t usage;
89665 - atomic_t sequence; /* Tx data packet sequence counter */
89666 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
89667 u32 abort_code; /* local/remote abort code */
89668 enum { /* current state of call */
89669 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
89670 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
89671 */
89672 extern atomic_t rxrpc_n_skbs;
89673 extern __be32 rxrpc_epoch;
89674 -extern atomic_t rxrpc_debug_id;
89675 +extern atomic_unchecked_t rxrpc_debug_id;
89676 extern struct workqueue_struct *rxrpc_workqueue;
89677
89678 /*
89679 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
89680 index 87f7135..74d3703 100644
89681 --- a/net/rxrpc/ar-local.c
89682 +++ b/net/rxrpc/ar-local.c
89683 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
89684 spin_lock_init(&local->lock);
89685 rwlock_init(&local->services_lock);
89686 atomic_set(&local->usage, 1);
89687 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
89688 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89689 memcpy(&local->srx, srx, sizeof(*srx));
89690 }
89691
89692 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
89693 index e1ac183..b43e10e 100644
89694 --- a/net/rxrpc/ar-output.c
89695 +++ b/net/rxrpc/ar-output.c
89696 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
89697 sp->hdr.cid = call->cid;
89698 sp->hdr.callNumber = call->call_id;
89699 sp->hdr.seq =
89700 - htonl(atomic_inc_return(&call->sequence));
89701 + htonl(atomic_inc_return_unchecked(&call->sequence));
89702 sp->hdr.serial =
89703 - htonl(atomic_inc_return(&conn->serial));
89704 + htonl(atomic_inc_return_unchecked(&conn->serial));
89705 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
89706 sp->hdr.userStatus = 0;
89707 sp->hdr.securityIndex = conn->security_ix;
89708 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
89709 index bebaa43..2644591 100644
89710 --- a/net/rxrpc/ar-peer.c
89711 +++ b/net/rxrpc/ar-peer.c
89712 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
89713 INIT_LIST_HEAD(&peer->error_targets);
89714 spin_lock_init(&peer->lock);
89715 atomic_set(&peer->usage, 1);
89716 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
89717 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89718 memcpy(&peer->srx, srx, sizeof(*srx));
89719
89720 rxrpc_assess_MTU_size(peer);
89721 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
89722 index 38047f7..9f48511 100644
89723 --- a/net/rxrpc/ar-proc.c
89724 +++ b/net/rxrpc/ar-proc.c
89725 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
89726 atomic_read(&conn->usage),
89727 rxrpc_conn_states[conn->state],
89728 key_serial(conn->key),
89729 - atomic_read(&conn->serial),
89730 - atomic_read(&conn->hi_serial));
89731 + atomic_read_unchecked(&conn->serial),
89732 + atomic_read_unchecked(&conn->hi_serial));
89733
89734 return 0;
89735 }
89736 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
89737 index 92df566..87ec1bf 100644
89738 --- a/net/rxrpc/ar-transport.c
89739 +++ b/net/rxrpc/ar-transport.c
89740 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
89741 spin_lock_init(&trans->client_lock);
89742 rwlock_init(&trans->conn_lock);
89743 atomic_set(&trans->usage, 1);
89744 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
89745 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89746
89747 if (peer->srx.transport.family == AF_INET) {
89748 switch (peer->srx.transport_type) {
89749 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
89750 index f226709..0e735a8 100644
89751 --- a/net/rxrpc/rxkad.c
89752 +++ b/net/rxrpc/rxkad.c
89753 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
89754
89755 len = iov[0].iov_len + iov[1].iov_len;
89756
89757 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
89758 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89759 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
89760
89761 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
89762 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
89763
89764 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
89765
89766 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
89767 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
89768 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
89769
89770 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
89771 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
89772 index 391a245..296b3d7 100644
89773 --- a/net/sctp/ipv6.c
89774 +++ b/net/sctp/ipv6.c
89775 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
89776 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
89777 };
89778
89779 -static struct sctp_af sctp_af_inet6 = {
89780 +static struct sctp_af sctp_af_inet6 __read_only = {
89781 .sa_family = AF_INET6,
89782 .sctp_xmit = sctp_v6_xmit,
89783 .setsockopt = ipv6_setsockopt,
89784 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
89785 #endif
89786 };
89787
89788 -static struct sctp_pf sctp_pf_inet6 = {
89789 +static struct sctp_pf sctp_pf_inet6 __read_only = {
89790 .event_msgname = sctp_inet6_event_msgname,
89791 .skb_msgname = sctp_inet6_skb_msgname,
89792 .af_supported = sctp_inet6_af_supported,
89793 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
89794
89795 void sctp_v6_pf_exit(void)
89796 {
89797 - list_del(&sctp_af_inet6.list);
89798 + pax_list_del(&sctp_af_inet6.list);
89799 }
89800
89801 /* Initialize IPv6 support and register with socket layer. */
89802 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
89803 index 8c19e97..16264b8 100644
89804 --- a/net/sctp/proc.c
89805 +++ b/net/sctp/proc.c
89806 @@ -338,7 +338,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
89807 seq_printf(seq,
89808 "%8pK %8pK %-3d %-3d %-2d %-4d "
89809 "%4d %8d %8d %7d %5lu %-5d %5d ",
89810 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
89811 + assoc, sk,
89812 + sctp_sk(sk)->type, sk->sk_state,
89813 assoc->state, hash,
89814 assoc->assoc_id,
89815 assoc->sndbuf_used,
89816 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
89817 index f898b1c..a2d0fe8 100644
89818 --- a/net/sctp/protocol.c
89819 +++ b/net/sctp/protocol.c
89820 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
89821 return 0;
89822 }
89823
89824 + pax_open_kernel();
89825 INIT_LIST_HEAD(&af->list);
89826 - list_add_tail(&af->list, &sctp_address_families);
89827 + pax_close_kernel();
89828 + pax_list_add_tail(&af->list, &sctp_address_families);
89829 return 1;
89830 }
89831
89832 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
89833
89834 static struct sctp_af sctp_af_inet;
89835
89836 -static struct sctp_pf sctp_pf_inet = {
89837 +static struct sctp_pf sctp_pf_inet __read_only = {
89838 .event_msgname = sctp_inet_event_msgname,
89839 .skb_msgname = sctp_inet_skb_msgname,
89840 .af_supported = sctp_inet_af_supported,
89841 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
89842 };
89843
89844 /* IPv4 address related functions. */
89845 -static struct sctp_af sctp_af_inet = {
89846 +static struct sctp_af sctp_af_inet __read_only = {
89847 .sa_family = AF_INET,
89848 .sctp_xmit = sctp_v4_xmit,
89849 .setsockopt = ip_setsockopt,
89850 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
89851
89852 static void sctp_v4_pf_exit(void)
89853 {
89854 - list_del(&sctp_af_inet.list);
89855 + pax_list_del(&sctp_af_inet.list);
89856 }
89857
89858 static int sctp_v4_protosw_init(void)
89859 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
89860 index c957775..6d4593a 100644
89861 --- a/net/sctp/sm_sideeffect.c
89862 +++ b/net/sctp/sm_sideeffect.c
89863 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
89864 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
89865 }
89866
89867 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89868 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
89869 NULL,
89870 sctp_generate_t1_cookie_event,
89871 sctp_generate_t1_init_event,
89872 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
89873 index 9ef5c73..1e9a9a9 100644
89874 --- a/net/sctp/socket.c
89875 +++ b/net/sctp/socket.c
89876 @@ -2166,11 +2166,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
89877 {
89878 struct sctp_association *asoc;
89879 struct sctp_ulpevent *event;
89880 + struct sctp_event_subscribe subscribe;
89881
89882 if (optlen > sizeof(struct sctp_event_subscribe))
89883 return -EINVAL;
89884 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
89885 + if (copy_from_user(&subscribe, optval, optlen))
89886 return -EFAULT;
89887 + sctp_sk(sk)->subscribe = subscribe;
89888
89889 /*
89890 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
89891 @@ -4215,13 +4217,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
89892 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89893 int __user *optlen)
89894 {
89895 + struct sctp_event_subscribe subscribe;
89896 +
89897 if (len <= 0)
89898 return -EINVAL;
89899 if (len > sizeof(struct sctp_event_subscribe))
89900 len = sizeof(struct sctp_event_subscribe);
89901 if (put_user(len, optlen))
89902 return -EFAULT;
89903 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
89904 + subscribe = sctp_sk(sk)->subscribe;
89905 + if (copy_to_user(optval, &subscribe, len))
89906 return -EFAULT;
89907 return 0;
89908 }
89909 @@ -4239,6 +4244,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
89910 */
89911 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
89912 {
89913 + __u32 autoclose;
89914 +
89915 /* Applicable to UDP-style socket only */
89916 if (sctp_style(sk, TCP))
89917 return -EOPNOTSUPP;
89918 @@ -4247,7 +4254,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
89919 len = sizeof(int);
89920 if (put_user(len, optlen))
89921 return -EFAULT;
89922 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
89923 + autoclose = sctp_sk(sk)->autoclose;
89924 + if (copy_to_user(optval, &autoclose, sizeof(int)))
89925 return -EFAULT;
89926 return 0;
89927 }
89928 @@ -4619,12 +4627,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
89929 */
89930 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
89931 {
89932 + struct sctp_initmsg initmsg;
89933 +
89934 if (len < sizeof(struct sctp_initmsg))
89935 return -EINVAL;
89936 len = sizeof(struct sctp_initmsg);
89937 if (put_user(len, optlen))
89938 return -EFAULT;
89939 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
89940 + initmsg = sctp_sk(sk)->initmsg;
89941 + if (copy_to_user(optval, &initmsg, len))
89942 return -EFAULT;
89943 return 0;
89944 }
89945 @@ -4665,6 +4676,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
89946 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
89947 if (space_left < addrlen)
89948 return -ENOMEM;
89949 + if (addrlen > sizeof(temp) || addrlen < 0)
89950 + return -EFAULT;
89951 if (copy_to_user(to, &temp, addrlen))
89952 return -EFAULT;
89953 to += addrlen;
89954 diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c
89955 index 442ad4e..825ea94 100644
89956 --- a/net/sctp/ssnmap.c
89957 +++ b/net/sctp/ssnmap.c
89958 @@ -41,8 +41,6 @@
89959 #include <net/sctp/sctp.h>
89960 #include <net/sctp/sm.h>
89961
89962 -#define MAX_KMALLOC_SIZE 131072
89963 -
89964 static struct sctp_ssnmap *sctp_ssnmap_init(struct sctp_ssnmap *map, __u16 in,
89965 __u16 out);
89966
89967 @@ -65,7 +63,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89968 int size;
89969
89970 size = sctp_ssnmap_size(in, out);
89971 - if (size <= MAX_KMALLOC_SIZE)
89972 + if (size <= KMALLOC_MAX_SIZE)
89973 retval = kmalloc(size, gfp);
89974 else
89975 retval = (struct sctp_ssnmap *)
89976 @@ -82,7 +80,7 @@ struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out,
89977 return retval;
89978
89979 fail_map:
89980 - if (size <= MAX_KMALLOC_SIZE)
89981 + if (size <= KMALLOC_MAX_SIZE)
89982 kfree(retval);
89983 else
89984 free_pages((unsigned long)retval, get_order(size));
89985 @@ -124,7 +122,7 @@ void sctp_ssnmap_free(struct sctp_ssnmap *map)
89986 int size;
89987
89988 size = sctp_ssnmap_size(map->in.len, map->out.len);
89989 - if (size <= MAX_KMALLOC_SIZE)
89990 + if (size <= KMALLOC_MAX_SIZE)
89991 kfree(map);
89992 else
89993 free_pages((unsigned long)map, get_order(size));
89994 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
89995 index bf3c6e8..376d8d0 100644
89996 --- a/net/sctp/sysctl.c
89997 +++ b/net/sctp/sysctl.c
89998 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
89999 {
90000 struct net *net = current->nsproxy->net_ns;
90001 char tmp[8];
90002 - ctl_table tbl;
90003 + ctl_table_no_const tbl;
90004 int ret;
90005 int changed = 0;
90006 char *none = "none";
90007 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90008
90009 int sctp_sysctl_net_register(struct net *net)
90010 {
90011 - struct ctl_table *table;
90012 + ctl_table_no_const *table;
90013 int i;
90014
90015 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90016 diff --git a/net/socket.c b/net/socket.c
90017 index 2ca51c7..ee5feb5 100644
90018 --- a/net/socket.c
90019 +++ b/net/socket.c
90020 @@ -89,6 +89,7 @@
90021 #include <linux/magic.h>
90022 #include <linux/slab.h>
90023 #include <linux/xattr.h>
90024 +#include <linux/in.h>
90025
90026 #include <asm/uaccess.h>
90027 #include <asm/unistd.h>
90028 @@ -106,6 +107,8 @@
90029 #include <linux/sockios.h>
90030 #include <linux/atalk.h>
90031
90032 +#include <linux/grsock.h>
90033 +
90034 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90035 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90036 unsigned long nr_segs, loff_t pos);
90037 @@ -322,7 +325,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90038 &sockfs_dentry_operations, SOCKFS_MAGIC);
90039 }
90040
90041 -static struct vfsmount *sock_mnt __read_mostly;
90042 +struct vfsmount *sock_mnt __read_mostly;
90043
90044 static struct file_system_type sock_fs_type = {
90045 .name = "sockfs",
90046 @@ -1270,6 +1273,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90047 return -EAFNOSUPPORT;
90048 if (type < 0 || type >= SOCK_MAX)
90049 return -EINVAL;
90050 + if (protocol < 0)
90051 + return -EINVAL;
90052
90053 /* Compatibility.
90054
90055 @@ -1401,6 +1406,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90056 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90057 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90058
90059 + if(!gr_search_socket(family, type, protocol)) {
90060 + retval = -EACCES;
90061 + goto out;
90062 + }
90063 +
90064 + if (gr_handle_sock_all(family, type, protocol)) {
90065 + retval = -EACCES;
90066 + goto out;
90067 + }
90068 +
90069 retval = sock_create(family, type, protocol, &sock);
90070 if (retval < 0)
90071 goto out;
90072 @@ -1528,6 +1543,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90073 if (sock) {
90074 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90075 if (err >= 0) {
90076 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90077 + err = -EACCES;
90078 + goto error;
90079 + }
90080 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90081 + if (err)
90082 + goto error;
90083 +
90084 err = security_socket_bind(sock,
90085 (struct sockaddr *)&address,
90086 addrlen);
90087 @@ -1536,6 +1559,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90088 (struct sockaddr *)
90089 &address, addrlen);
90090 }
90091 +error:
90092 fput_light(sock->file, fput_needed);
90093 }
90094 return err;
90095 @@ -1559,10 +1583,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90096 if ((unsigned int)backlog > somaxconn)
90097 backlog = somaxconn;
90098
90099 + if (gr_handle_sock_server_other(sock->sk)) {
90100 + err = -EPERM;
90101 + goto error;
90102 + }
90103 +
90104 + err = gr_search_listen(sock);
90105 + if (err)
90106 + goto error;
90107 +
90108 err = security_socket_listen(sock, backlog);
90109 if (!err)
90110 err = sock->ops->listen(sock, backlog);
90111
90112 +error:
90113 fput_light(sock->file, fput_needed);
90114 }
90115 return err;
90116 @@ -1606,6 +1640,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90117 newsock->type = sock->type;
90118 newsock->ops = sock->ops;
90119
90120 + if (gr_handle_sock_server_other(sock->sk)) {
90121 + err = -EPERM;
90122 + sock_release(newsock);
90123 + goto out_put;
90124 + }
90125 +
90126 + err = gr_search_accept(sock);
90127 + if (err) {
90128 + sock_release(newsock);
90129 + goto out_put;
90130 + }
90131 +
90132 /*
90133 * We don't need try_module_get here, as the listening socket (sock)
90134 * has the protocol module (sock->ops->owner) held.
90135 @@ -1651,6 +1697,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90136 fd_install(newfd, newfile);
90137 err = newfd;
90138
90139 + gr_attach_curr_ip(newsock->sk);
90140 +
90141 out_put:
90142 fput_light(sock->file, fput_needed);
90143 out:
90144 @@ -1683,6 +1731,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90145 int, addrlen)
90146 {
90147 struct socket *sock;
90148 + struct sockaddr *sck;
90149 struct sockaddr_storage address;
90150 int err, fput_needed;
90151
90152 @@ -1693,6 +1742,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90153 if (err < 0)
90154 goto out_put;
90155
90156 + sck = (struct sockaddr *)&address;
90157 +
90158 + if (gr_handle_sock_client(sck)) {
90159 + err = -EACCES;
90160 + goto out_put;
90161 + }
90162 +
90163 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90164 + if (err)
90165 + goto out_put;
90166 +
90167 err =
90168 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90169 if (err)
90170 @@ -1774,6 +1834,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90171 * the protocol.
90172 */
90173
90174 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90175 +
90176 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90177 unsigned int, flags, struct sockaddr __user *, addr,
90178 int, addr_len)
90179 @@ -1840,7 +1902,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90180 struct socket *sock;
90181 struct iovec iov;
90182 struct msghdr msg;
90183 - struct sockaddr_storage address;
90184 + struct sockaddr_storage address = { };
90185 int err, err2;
90186 int fput_needed;
90187
90188 @@ -2047,7 +2109,7 @@ static int __sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90189 * checking falls down on this.
90190 */
90191 if (copy_from_user(ctl_buf,
90192 - (void __user __force *)msg_sys->msg_control,
90193 + (void __force_user *)msg_sys->msg_control,
90194 ctl_len))
90195 goto out_freectl;
90196 msg_sys->msg_control = ctl_buf;
90197 @@ -2187,7 +2249,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90198 int err, total_len, len;
90199
90200 /* kernel mode address */
90201 - struct sockaddr_storage addr;
90202 + struct sockaddr_storage addr = { };
90203
90204 /* user mode address pointers */
90205 struct sockaddr __user *uaddr;
90206 @@ -2215,7 +2277,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90207 * kernel msghdr to use the kernel address space)
90208 */
90209
90210 - uaddr = (__force void __user *)msg_sys->msg_name;
90211 + uaddr = (void __force_user *)msg_sys->msg_name;
90212 uaddr_len = COMPAT_NAMELEN(msg);
90213 if (MSG_CMSG_COMPAT & flags) {
90214 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90215 @@ -2838,7 +2900,7 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90216 }
90217
90218 ifr = compat_alloc_user_space(buf_size);
90219 - rxnfc = (void *)ifr + ALIGN(sizeof(struct ifreq), 8);
90220 + rxnfc = (void __user *)ifr + ALIGN(sizeof(struct ifreq), 8);
90221
90222 if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ))
90223 return -EFAULT;
90224 @@ -2862,12 +2924,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90225 offsetof(struct ethtool_rxnfc, fs.ring_cookie));
90226
90227 if (copy_in_user(rxnfc, compat_rxnfc,
90228 - (void *)(&rxnfc->fs.m_ext + 1) -
90229 - (void *)rxnfc) ||
90230 + (void __user *)(&rxnfc->fs.m_ext + 1) -
90231 + (void __user *)rxnfc) ||
90232 copy_in_user(&rxnfc->fs.ring_cookie,
90233 &compat_rxnfc->fs.ring_cookie,
90234 - (void *)(&rxnfc->fs.location + 1) -
90235 - (void *)&rxnfc->fs.ring_cookie) ||
90236 + (void __user *)(&rxnfc->fs.location + 1) -
90237 + (void __user *)&rxnfc->fs.ring_cookie) ||
90238 copy_in_user(&rxnfc->rule_cnt, &compat_rxnfc->rule_cnt,
90239 sizeof(rxnfc->rule_cnt)))
90240 return -EFAULT;
90241 @@ -2879,12 +2941,12 @@ static int ethtool_ioctl(struct net *net, struct compat_ifreq __user *ifr32)
90242
90243 if (convert_out) {
90244 if (copy_in_user(compat_rxnfc, rxnfc,
90245 - (const void *)(&rxnfc->fs.m_ext + 1) -
90246 - (const void *)rxnfc) ||
90247 + (const void __user *)(&rxnfc->fs.m_ext + 1) -
90248 + (const void __user *)rxnfc) ||
90249 copy_in_user(&compat_rxnfc->fs.ring_cookie,
90250 &rxnfc->fs.ring_cookie,
90251 - (const void *)(&rxnfc->fs.location + 1) -
90252 - (const void *)&rxnfc->fs.ring_cookie) ||
90253 + (const void __user *)(&rxnfc->fs.location + 1) -
90254 + (const void __user *)&rxnfc->fs.ring_cookie) ||
90255 copy_in_user(&compat_rxnfc->rule_cnt, &rxnfc->rule_cnt,
90256 sizeof(rxnfc->rule_cnt)))
90257 return -EFAULT;
90258 @@ -2954,7 +3016,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90259 old_fs = get_fs();
90260 set_fs(KERNEL_DS);
90261 err = dev_ioctl(net, cmd,
90262 - (struct ifreq __user __force *) &kifr);
90263 + (struct ifreq __force_user *) &kifr);
90264 set_fs(old_fs);
90265
90266 return err;
90267 @@ -3063,7 +3125,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90268
90269 old_fs = get_fs();
90270 set_fs(KERNEL_DS);
90271 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90272 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90273 set_fs(old_fs);
90274
90275 if (cmd == SIOCGIFMAP && !err) {
90276 @@ -3168,7 +3230,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90277 ret |= __get_user(rtdev, &(ur4->rt_dev));
90278 if (rtdev) {
90279 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90280 - r4.rt_dev = (char __user __force *)devname;
90281 + r4.rt_dev = (char __force_user *)devname;
90282 devname[15] = 0;
90283 } else
90284 r4.rt_dev = NULL;
90285 @@ -3394,8 +3456,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90286 int __user *uoptlen;
90287 int err;
90288
90289 - uoptval = (char __user __force *) optval;
90290 - uoptlen = (int __user __force *) optlen;
90291 + uoptval = (char __force_user *) optval;
90292 + uoptlen = (int __force_user *) optlen;
90293
90294 set_fs(KERNEL_DS);
90295 if (level == SOL_SOCKET)
90296 @@ -3415,7 +3477,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90297 char __user *uoptval;
90298 int err;
90299
90300 - uoptval = (char __user __force *) optval;
90301 + uoptval = (char __force_user *) optval;
90302
90303 set_fs(KERNEL_DS);
90304 if (level == SOL_SOCKET)
90305 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90306 index 716aa41..75e88ea 100644
90307 --- a/net/sunrpc/clnt.c
90308 +++ b/net/sunrpc/clnt.c
90309 @@ -303,10 +303,8 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
90310 err = rpciod_up();
90311 if (err)
90312 goto out_no_rpciod;
90313 +
90314 err = -EINVAL;
90315 - if (!xprt)
90316 - goto out_no_xprt;
90317 -
90318 if (args->version >= program->nrvers)
90319 goto out_err;
90320 version = program->version[args->version];
90321 @@ -381,10 +379,9 @@ out_no_principal:
90322 out_no_stats:
90323 kfree(clnt);
90324 out_err:
90325 - xprt_put(xprt);
90326 -out_no_xprt:
90327 rpciod_down();
90328 out_no_rpciod:
90329 + xprt_put(xprt);
90330 return ERR_PTR(err);
90331 }
90332
90333 @@ -1270,7 +1267,9 @@ call_start(struct rpc_task *task)
90334 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90335
90336 /* Increment call count */
90337 - task->tk_msg.rpc_proc->p_count++;
90338 + pax_open_kernel();
90339 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90340 + pax_close_kernel();
90341 clnt->cl_stats->rpccnt++;
90342 task->tk_action = call_reserve;
90343 }
90344 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90345 index f8529fc..ce8c643 100644
90346 --- a/net/sunrpc/sched.c
90347 +++ b/net/sunrpc/sched.c
90348 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90349 #ifdef RPC_DEBUG
90350 static void rpc_task_set_debuginfo(struct rpc_task *task)
90351 {
90352 - static atomic_t rpc_pid;
90353 + static atomic_unchecked_t rpc_pid;
90354
90355 - task->tk_pid = atomic_inc_return(&rpc_pid);
90356 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90357 }
90358 #else
90359 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90360 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90361 index 2d34b6b..e2d584d 100644
90362 --- a/net/sunrpc/svc.c
90363 +++ b/net/sunrpc/svc.c
90364 @@ -1156,7 +1156,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90365 svc_putnl(resv, RPC_SUCCESS);
90366
90367 /* Bump per-procedure stats counter */
90368 - procp->pc_count++;
90369 + pax_open_kernel();
90370 + (*(unsigned int *)&procp->pc_count)++;
90371 + pax_close_kernel();
90372
90373 /* Initialize storage for argp and resp */
90374 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90375 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90376 index 8343737..677025e 100644
90377 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90378 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90379 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90380 static unsigned int min_max_inline = 4096;
90381 static unsigned int max_max_inline = 65536;
90382
90383 -atomic_t rdma_stat_recv;
90384 -atomic_t rdma_stat_read;
90385 -atomic_t rdma_stat_write;
90386 -atomic_t rdma_stat_sq_starve;
90387 -atomic_t rdma_stat_rq_starve;
90388 -atomic_t rdma_stat_rq_poll;
90389 -atomic_t rdma_stat_rq_prod;
90390 -atomic_t rdma_stat_sq_poll;
90391 -atomic_t rdma_stat_sq_prod;
90392 +atomic_unchecked_t rdma_stat_recv;
90393 +atomic_unchecked_t rdma_stat_read;
90394 +atomic_unchecked_t rdma_stat_write;
90395 +atomic_unchecked_t rdma_stat_sq_starve;
90396 +atomic_unchecked_t rdma_stat_rq_starve;
90397 +atomic_unchecked_t rdma_stat_rq_poll;
90398 +atomic_unchecked_t rdma_stat_rq_prod;
90399 +atomic_unchecked_t rdma_stat_sq_poll;
90400 +atomic_unchecked_t rdma_stat_sq_prod;
90401
90402 /* Temporary NFS request map and context caches */
90403 struct kmem_cache *svc_rdma_map_cachep;
90404 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90405 len -= *ppos;
90406 if (len > *lenp)
90407 len = *lenp;
90408 - if (len && copy_to_user(buffer, str_buf, len))
90409 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90410 return -EFAULT;
90411 *lenp = len;
90412 *ppos += len;
90413 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90414 {
90415 .procname = "rdma_stat_read",
90416 .data = &rdma_stat_read,
90417 - .maxlen = sizeof(atomic_t),
90418 + .maxlen = sizeof(atomic_unchecked_t),
90419 .mode = 0644,
90420 .proc_handler = read_reset_stat,
90421 },
90422 {
90423 .procname = "rdma_stat_recv",
90424 .data = &rdma_stat_recv,
90425 - .maxlen = sizeof(atomic_t),
90426 + .maxlen = sizeof(atomic_unchecked_t),
90427 .mode = 0644,
90428 .proc_handler = read_reset_stat,
90429 },
90430 {
90431 .procname = "rdma_stat_write",
90432 .data = &rdma_stat_write,
90433 - .maxlen = sizeof(atomic_t),
90434 + .maxlen = sizeof(atomic_unchecked_t),
90435 .mode = 0644,
90436 .proc_handler = read_reset_stat,
90437 },
90438 {
90439 .procname = "rdma_stat_sq_starve",
90440 .data = &rdma_stat_sq_starve,
90441 - .maxlen = sizeof(atomic_t),
90442 + .maxlen = sizeof(atomic_unchecked_t),
90443 .mode = 0644,
90444 .proc_handler = read_reset_stat,
90445 },
90446 {
90447 .procname = "rdma_stat_rq_starve",
90448 .data = &rdma_stat_rq_starve,
90449 - .maxlen = sizeof(atomic_t),
90450 + .maxlen = sizeof(atomic_unchecked_t),
90451 .mode = 0644,
90452 .proc_handler = read_reset_stat,
90453 },
90454 {
90455 .procname = "rdma_stat_rq_poll",
90456 .data = &rdma_stat_rq_poll,
90457 - .maxlen = sizeof(atomic_t),
90458 + .maxlen = sizeof(atomic_unchecked_t),
90459 .mode = 0644,
90460 .proc_handler = read_reset_stat,
90461 },
90462 {
90463 .procname = "rdma_stat_rq_prod",
90464 .data = &rdma_stat_rq_prod,
90465 - .maxlen = sizeof(atomic_t),
90466 + .maxlen = sizeof(atomic_unchecked_t),
90467 .mode = 0644,
90468 .proc_handler = read_reset_stat,
90469 },
90470 {
90471 .procname = "rdma_stat_sq_poll",
90472 .data = &rdma_stat_sq_poll,
90473 - .maxlen = sizeof(atomic_t),
90474 + .maxlen = sizeof(atomic_unchecked_t),
90475 .mode = 0644,
90476 .proc_handler = read_reset_stat,
90477 },
90478 {
90479 .procname = "rdma_stat_sq_prod",
90480 .data = &rdma_stat_sq_prod,
90481 - .maxlen = sizeof(atomic_t),
90482 + .maxlen = sizeof(atomic_unchecked_t),
90483 .mode = 0644,
90484 .proc_handler = read_reset_stat,
90485 },
90486 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90487 index 0ce7552..d074459 100644
90488 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90489 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90490 @@ -501,7 +501,7 @@ next_sge:
90491 svc_rdma_put_context(ctxt, 0);
90492 goto out;
90493 }
90494 - atomic_inc(&rdma_stat_read);
90495 + atomic_inc_unchecked(&rdma_stat_read);
90496
90497 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90498 chl_map->ch[ch_no].count -= read_wr.num_sge;
90499 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90500 dto_q);
90501 list_del_init(&ctxt->dto_q);
90502 } else {
90503 - atomic_inc(&rdma_stat_rq_starve);
90504 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90505 clear_bit(XPT_DATA, &xprt->xpt_flags);
90506 ctxt = NULL;
90507 }
90508 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90509 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90510 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90511 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90512 - atomic_inc(&rdma_stat_recv);
90513 + atomic_inc_unchecked(&rdma_stat_recv);
90514
90515 /* Build up the XDR from the receive buffers. */
90516 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90517 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90518 index c1d124d..acfc59e 100644
90519 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90520 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90521 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90522 write_wr.wr.rdma.remote_addr = to;
90523
90524 /* Post It */
90525 - atomic_inc(&rdma_stat_write);
90526 + atomic_inc_unchecked(&rdma_stat_write);
90527 if (svc_rdma_send(xprt, &write_wr))
90528 goto err;
90529 return 0;
90530 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90531 index 62e4f9b..dd3f2d7 100644
90532 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90533 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90534 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90535 return;
90536
90537 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90538 - atomic_inc(&rdma_stat_rq_poll);
90539 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90540
90541 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90542 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90543 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90544 }
90545
90546 if (ctxt)
90547 - atomic_inc(&rdma_stat_rq_prod);
90548 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90549
90550 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90551 /*
90552 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90553 return;
90554
90555 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90556 - atomic_inc(&rdma_stat_sq_poll);
90557 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90558 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90559 if (wc.status != IB_WC_SUCCESS)
90560 /* Close the transport */
90561 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90562 }
90563
90564 if (ctxt)
90565 - atomic_inc(&rdma_stat_sq_prod);
90566 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90567 }
90568
90569 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90570 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90571 spin_lock_bh(&xprt->sc_lock);
90572 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90573 spin_unlock_bh(&xprt->sc_lock);
90574 - atomic_inc(&rdma_stat_sq_starve);
90575 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90576
90577 /* See if we can opportunistically reap SQ WR to make room */
90578 sq_cq_reap(xprt);
90579 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90580 index 9bc6db0..47ac8c0 100644
90581 --- a/net/sysctl_net.c
90582 +++ b/net/sysctl_net.c
90583 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90584 kgid_t root_gid = make_kgid(net->user_ns, 0);
90585
90586 /* Allow network administrator to have same access as root. */
90587 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90588 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90589 uid_eq(root_uid, current_uid())) {
90590 int mode = (table->mode >> 6) & 7;
90591 return (mode << 6) | (mode << 3) | mode;
90592 diff --git a/net/tipc/link.c b/net/tipc/link.c
90593 index daa6080..02d357f 100644
90594 --- a/net/tipc/link.c
90595 +++ b/net/tipc/link.c
90596 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90597 struct tipc_msg fragm_hdr;
90598 struct sk_buff *buf, *buf_chain, *prev;
90599 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90600 - const unchar *sect_crs;
90601 + const unchar __user *sect_crs;
90602 int curr_sect;
90603 u32 fragm_no;
90604
90605 @@ -1242,7 +1242,7 @@ again:
90606
90607 if (!sect_rest) {
90608 sect_rest = msg_sect[++curr_sect].iov_len;
90609 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90610 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90611 }
90612
90613 if (sect_rest < fragm_rest)
90614 @@ -1261,7 +1261,7 @@ error:
90615 }
90616 } else
90617 skb_copy_to_linear_data_offset(buf, fragm_crs,
90618 - sect_crs, sz);
90619 + (const void __force_kernel *)sect_crs, sz);
90620 sect_crs += sz;
90621 sect_rest -= sz;
90622 fragm_crs += sz;
90623 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90624 index f2db8a8..9245aa4 100644
90625 --- a/net/tipc/msg.c
90626 +++ b/net/tipc/msg.c
90627 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90628 msg_sect[cnt].iov_len);
90629 else
90630 skb_copy_to_linear_data_offset(*buf, pos,
90631 - msg_sect[cnt].iov_base,
90632 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90633 msg_sect[cnt].iov_len);
90634 pos += msg_sect[cnt].iov_len;
90635 }
90636 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90637 index 6b42d47..2ac24d5 100644
90638 --- a/net/tipc/subscr.c
90639 +++ b/net/tipc/subscr.c
90640 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90641 {
90642 struct iovec msg_sect;
90643
90644 - msg_sect.iov_base = (void *)&sub->evt;
90645 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90646 msg_sect.iov_len = sizeof(struct tipc_event);
90647
90648 sub->evt.event = htohl(event, sub->swap);
90649 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90650 index b45eb65..bb4b223 100644
90651 --- a/net/unix/af_unix.c
90652 +++ b/net/unix/af_unix.c
90653 @@ -785,6 +785,12 @@ static struct sock *unix_find_other(struct net *net,
90654 err = -ECONNREFUSED;
90655 if (!S_ISSOCK(inode->i_mode))
90656 goto put_fail;
90657 +
90658 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90659 + err = -EACCES;
90660 + goto put_fail;
90661 + }
90662 +
90663 u = unix_find_socket_byinode(inode);
90664 if (!u)
90665 goto put_fail;
90666 @@ -805,6 +811,13 @@ static struct sock *unix_find_other(struct net *net,
90667 if (u) {
90668 struct dentry *dentry;
90669 dentry = unix_sk(u)->path.dentry;
90670 +
90671 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90672 + err = -EPERM;
90673 + sock_put(u);
90674 + goto fail;
90675 + }
90676 +
90677 if (dentry)
90678 touch_atime(&unix_sk(u)->path);
90679 } else
90680 @@ -838,12 +851,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90681 */
90682 err = security_path_mknod(&path, dentry, mode, 0);
90683 if (!err) {
90684 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90685 + err = -EACCES;
90686 + goto out;
90687 + }
90688 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90689 if (!err) {
90690 res->mnt = mntget(path.mnt);
90691 res->dentry = dget(dentry);
90692 + gr_handle_create(dentry, path.mnt);
90693 }
90694 }
90695 +out:
90696 done_path_create(&path, dentry);
90697 return err;
90698 }
90699 @@ -1995,7 +2014,7 @@ again:
90700 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
90701 (UNIXCB(skb).cred != siocb->scm->cred))
90702 break;
90703 - } else {
90704 + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
90705 /* Copy credentials */
90706 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
90707 check_creds = 1;
90708 @@ -2325,9 +2344,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90709 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90710 "Inode Path\n");
90711 else {
90712 - struct sock *s = v;
90713 + struct sock *s = v, *peer;
90714 struct unix_sock *u = unix_sk(s);
90715 unix_state_lock(s);
90716 + peer = unix_peer(s);
90717 + unix_state_unlock(s);
90718 +
90719 + unix_state_double_lock(s, peer);
90720
90721 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
90722 s,
90723 @@ -2354,8 +2377,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90724 }
90725 for ( ; i < len; i++)
90726 seq_putc(seq, u->addr->name->sun_path[i]);
90727 - }
90728 - unix_state_unlock(s);
90729 + } else if (peer)
90730 + seq_printf(seq, " P%lu", sock_i_ino(peer));
90731 +
90732 + unix_state_double_unlock(s, peer);
90733 seq_putc(seq, '\n');
90734 }
90735
90736 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
90737 index 8800604..0526440 100644
90738 --- a/net/unix/sysctl_net_unix.c
90739 +++ b/net/unix/sysctl_net_unix.c
90740 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
90741
90742 int __net_init unix_sysctl_register(struct net *net)
90743 {
90744 - struct ctl_table *table;
90745 + ctl_table_no_const *table;
90746
90747 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
90748 if (table == NULL)
90749 diff --git a/net/wireless/trace.h b/net/wireless/trace.h
90750 index 2134576..5d71a5a 100644
90751 --- a/net/wireless/trace.h
90752 +++ b/net/wireless/trace.h
90753 @@ -27,7 +27,8 @@
90754 #define WIPHY_PR_ARG __entry->wiphy_name
90755
90756 #define WDEV_ENTRY __field(u32, id)
90757 -#define WDEV_ASSIGN (__entry->id) = (wdev ? wdev->identifier : 0)
90758 +#define WDEV_ASSIGN (__entry->id) = (!IS_ERR_OR_NULL(wdev) \
90759 + ? wdev->identifier : 0)
90760 #define WDEV_PR_FMT "wdev(%u)"
90761 #define WDEV_PR_ARG (__entry->id)
90762
90763 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
90764 index c8717c1..08539f5 100644
90765 --- a/net/wireless/wext-core.c
90766 +++ b/net/wireless/wext-core.c
90767 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90768 */
90769
90770 /* Support for very large requests */
90771 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
90772 - (user_length > descr->max_tokens)) {
90773 + if (user_length > descr->max_tokens) {
90774 /* Allow userspace to GET more than max so
90775 * we can support any size GET requests.
90776 * There is still a limit : -ENOMEM.
90777 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
90778 }
90779 }
90780
90781 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
90782 - /*
90783 - * If this is a GET, but not NOMAX, it means that the extra
90784 - * data is not bounded by userspace, but by max_tokens. Thus
90785 - * set the length to max_tokens. This matches the extra data
90786 - * allocation.
90787 - * The driver should fill it with the number of tokens it
90788 - * provided, and it may check iwp->length rather than having
90789 - * knowledge of max_tokens. If the driver doesn't change the
90790 - * iwp->length, this ioctl just copies back max_token tokens
90791 - * filled with zeroes. Hopefully the driver isn't claiming
90792 - * them to be valid data.
90793 - */
90794 - iwp->length = descr->max_tokens;
90795 - }
90796 -
90797 err = handler(dev, info, (union iwreq_data *) iwp, extra);
90798
90799 iwp->length += essid_compat;
90800 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
90801 index 07c5857..fde4018 100644
90802 --- a/net/xfrm/xfrm_policy.c
90803 +++ b/net/xfrm/xfrm_policy.c
90804 @@ -317,7 +317,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
90805 {
90806 policy->walk.dead = 1;
90807
90808 - atomic_inc(&policy->genid);
90809 + atomic_inc_unchecked(&policy->genid);
90810
90811 if (del_timer(&policy->timer))
90812 xfrm_pol_put(policy);
90813 @@ -601,7 +601,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
90814 hlist_add_head(&policy->bydst, chain);
90815 xfrm_pol_hold(policy);
90816 net->xfrm.policy_count[dir]++;
90817 - atomic_inc(&flow_cache_genid);
90818 + atomic_inc_unchecked(&flow_cache_genid);
90819 rt_genid_bump(net);
90820 if (delpol)
90821 __xfrm_policy_unlink(delpol, dir);
90822 @@ -1550,7 +1550,7 @@ free_dst:
90823 goto out;
90824 }
90825
90826 -static int inline
90827 +static inline int
90828 xfrm_dst_alloc_copy(void **target, const void *src, int size)
90829 {
90830 if (!*target) {
90831 @@ -1562,7 +1562,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
90832 return 0;
90833 }
90834
90835 -static int inline
90836 +static inline int
90837 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90838 {
90839 #ifdef CONFIG_XFRM_SUB_POLICY
90840 @@ -1574,7 +1574,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
90841 #endif
90842 }
90843
90844 -static int inline
90845 +static inline int
90846 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
90847 {
90848 #ifdef CONFIG_XFRM_SUB_POLICY
90849 @@ -1668,7 +1668,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
90850
90851 xdst->num_pols = num_pols;
90852 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
90853 - xdst->policy_genid = atomic_read(&pols[0]->genid);
90854 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
90855
90856 return xdst;
90857 }
90858 @@ -2369,7 +2369,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
90859 if (xdst->xfrm_genid != dst->xfrm->genid)
90860 return 0;
90861 if (xdst->num_pols > 0 &&
90862 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
90863 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
90864 return 0;
90865
90866 mtu = dst_mtu(dst->child);
90867 @@ -2457,8 +2457,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
90868 dst_ops->link_failure = xfrm_link_failure;
90869 if (likely(dst_ops->neigh_lookup == NULL))
90870 dst_ops->neigh_lookup = xfrm_neigh_lookup;
90871 - if (likely(afinfo->garbage_collect == NULL))
90872 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90873 + if (likely(afinfo->garbage_collect == NULL)) {
90874 + pax_open_kernel();
90875 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
90876 + pax_close_kernel();
90877 + }
90878 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
90879 }
90880 spin_unlock(&xfrm_policy_afinfo_lock);
90881 @@ -2512,7 +2515,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
90882 dst_ops->check = NULL;
90883 dst_ops->negative_advice = NULL;
90884 dst_ops->link_failure = NULL;
90885 - afinfo->garbage_collect = NULL;
90886 + pax_open_kernel();
90887 + *(void **)&afinfo->garbage_collect = NULL;
90888 + pax_close_kernel();
90889 }
90890 return err;
90891 }
90892 @@ -2896,7 +2901,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
90893 sizeof(pol->xfrm_vec[i].saddr));
90894 pol->xfrm_vec[i].encap_family = mp->new_family;
90895 /* flush bundles */
90896 - atomic_inc(&pol->genid);
90897 + atomic_inc_unchecked(&pol->genid);
90898 }
90899 }
90900
90901 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
90902 index 3459692..e7cdb1a 100644
90903 --- a/net/xfrm/xfrm_state.c
90904 +++ b/net/xfrm/xfrm_state.c
90905 @@ -194,11 +194,13 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
90906
90907 if (unlikely(afinfo == NULL))
90908 return -EAFNOSUPPORT;
90909 - typemap = afinfo->type_map;
90910 + typemap = (const struct xfrm_type **)afinfo->type_map;
90911
90912 - if (likely(typemap[type->proto] == NULL))
90913 + if (likely(typemap[type->proto] == NULL)) {
90914 + pax_open_kernel();
90915 typemap[type->proto] = type;
90916 - else
90917 + pax_close_kernel();
90918 + } else
90919 err = -EEXIST;
90920 xfrm_state_unlock_afinfo(afinfo);
90921 return err;
90922 @@ -213,12 +215,15 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
90923
90924 if (unlikely(afinfo == NULL))
90925 return -EAFNOSUPPORT;
90926 - typemap = afinfo->type_map;
90927 + typemap = (const struct xfrm_type **)afinfo->type_map;
90928
90929 if (unlikely(typemap[type->proto] != type))
90930 err = -ENOENT;
90931 - else
90932 + else {
90933 + pax_open_kernel();
90934 typemap[type->proto] = NULL;
90935 + pax_close_kernel();
90936 + }
90937 xfrm_state_unlock_afinfo(afinfo);
90938 return err;
90939 }
90940 @@ -227,7 +232,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
90941 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
90942 {
90943 struct xfrm_state_afinfo *afinfo;
90944 - const struct xfrm_type **typemap;
90945 const struct xfrm_type *type;
90946 int modload_attempted = 0;
90947
90948 @@ -235,9 +239,8 @@ retry:
90949 afinfo = xfrm_state_get_afinfo(family);
90950 if (unlikely(afinfo == NULL))
90951 return NULL;
90952 - typemap = afinfo->type_map;
90953
90954 - type = typemap[proto];
90955 + type = afinfo->type_map[proto];
90956 if (unlikely(type && !try_module_get(type->owner)))
90957 type = NULL;
90958 if (!type && !modload_attempted) {
90959 @@ -270,7 +273,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90960 return -EAFNOSUPPORT;
90961
90962 err = -EEXIST;
90963 - modemap = afinfo->mode_map;
90964 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90965 if (modemap[mode->encap])
90966 goto out;
90967
90968 @@ -278,8 +281,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
90969 if (!try_module_get(afinfo->owner))
90970 goto out;
90971
90972 - mode->afinfo = afinfo;
90973 + pax_open_kernel();
90974 + *(const void **)&mode->afinfo = afinfo;
90975 modemap[mode->encap] = mode;
90976 + pax_close_kernel();
90977 err = 0;
90978
90979 out:
90980 @@ -302,9 +307,11 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
90981 return -EAFNOSUPPORT;
90982
90983 err = -ENOENT;
90984 - modemap = afinfo->mode_map;
90985 + modemap = (struct xfrm_mode **)afinfo->mode_map;
90986 if (likely(modemap[mode->encap] == mode)) {
90987 + pax_open_kernel();
90988 modemap[mode->encap] = NULL;
90989 + pax_close_kernel();
90990 module_put(mode->afinfo->owner);
90991 err = 0;
90992 }
90993 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
90994 index 05a6e3d..6716ec9 100644
90995 --- a/net/xfrm/xfrm_sysctl.c
90996 +++ b/net/xfrm/xfrm_sysctl.c
90997 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
90998
90999 int __net_init xfrm_sysctl_init(struct net *net)
91000 {
91001 - struct ctl_table *table;
91002 + ctl_table_no_const *table;
91003
91004 __xfrm_sysctl_init(net);
91005
91006 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91007 index 0e801c3..5c8ad3b 100644
91008 --- a/scripts/Makefile.build
91009 +++ b/scripts/Makefile.build
91010 @@ -111,7 +111,7 @@ endif
91011 endif
91012
91013 # Do not include host rules unless needed
91014 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91015 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91016 include scripts/Makefile.host
91017 endif
91018
91019 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91020 index 686cb0d..9d653bf 100644
91021 --- a/scripts/Makefile.clean
91022 +++ b/scripts/Makefile.clean
91023 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91024 __clean-files := $(extra-y) $(always) \
91025 $(targets) $(clean-files) \
91026 $(host-progs) \
91027 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91028 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91029 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91030
91031 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91032
91033 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91034 index 1ac414f..38575f7 100644
91035 --- a/scripts/Makefile.host
91036 +++ b/scripts/Makefile.host
91037 @@ -31,6 +31,8 @@
91038 # Note: Shared libraries consisting of C++ files are not supported
91039
91040 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91041 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91042 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91043
91044 # C code
91045 # Executables compiled from a single .c file
91046 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91047 # Shared libaries (only .c supported)
91048 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91049 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91050 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91051 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91052 # Remove .so files from "xxx-objs"
91053 host-cobjs := $(filter-out %.so,$(host-cobjs))
91054 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91055
91056 -#Object (.o) files used by the shared libaries
91057 +# Object (.o) files used by the shared libaries
91058 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91059 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91060
91061 # output directory for programs/.o files
91062 # hostprogs-y := tools/build may have been specified. Retrieve directory
91063 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91064 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91065 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91066 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91067 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91068 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91069 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91070 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91071
91072 obj-dirs += $(host-objdirs)
91073 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91074 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91075 $(call if_changed_dep,host-cshobjs)
91076
91077 +# Compile .c file, create position independent .o file
91078 +# host-cxxshobjs -> .o
91079 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91080 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91081 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91082 + $(call if_changed_dep,host-cxxshobjs)
91083 +
91084 # Link a shared library, based on position independent .o files
91085 # *.o -> .so shared library (host-cshlib)
91086 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91087 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91088 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91089 $(call if_changed,host-cshlib)
91090
91091 +# Link a shared library, based on position independent .o files
91092 +# *.o -> .so shared library (host-cxxshlib)
91093 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91094 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91095 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91096 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91097 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91098 + $(call if_changed,host-cxxshlib)
91099 +
91100 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91101 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91102 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91103
91104 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91105 index cb1f50c..cef2a7c 100644
91106 --- a/scripts/basic/fixdep.c
91107 +++ b/scripts/basic/fixdep.c
91108 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91109 /*
91110 * Lookup a value in the configuration string.
91111 */
91112 -static int is_defined_config(const char *name, int len, unsigned int hash)
91113 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91114 {
91115 struct item *aux;
91116
91117 @@ -211,10 +211,10 @@ static void clear_config(void)
91118 /*
91119 * Record the use of a CONFIG_* word.
91120 */
91121 -static void use_config(const char *m, int slen)
91122 +static void use_config(const char *m, unsigned int slen)
91123 {
91124 unsigned int hash = strhash(m, slen);
91125 - int c, i;
91126 + unsigned int c, i;
91127
91128 if (is_defined_config(m, slen, hash))
91129 return;
91130 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91131
91132 static void parse_config_file(const char *map, size_t len)
91133 {
91134 - const int *end = (const int *) (map + len);
91135 + const unsigned int *end = (const unsigned int *) (map + len);
91136 /* start at +1, so that p can never be < map */
91137 - const int *m = (const int *) map + 1;
91138 + const unsigned int *m = (const unsigned int *) map + 1;
91139 const char *p, *q;
91140
91141 for (; m < end; m++) {
91142 @@ -406,7 +406,7 @@ static void print_deps(void)
91143 static void traps(void)
91144 {
91145 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91146 - int *p = (int *)test;
91147 + unsigned int *p = (unsigned int *)test;
91148
91149 if (*p != INT_CONF) {
91150 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianess? %#x\n",
91151 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91152 new file mode 100644
91153 index 0000000..5e0222d
91154 --- /dev/null
91155 +++ b/scripts/gcc-plugin.sh
91156 @@ -0,0 +1,17 @@
91157 +#!/bin/bash
91158 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91159 +#include "gcc-plugin.h"
91160 +#include "tree.h"
91161 +#include "tm.h"
91162 +#include "rtl.h"
91163 +#ifdef ENABLE_BUILD_WITH_CXX
91164 +#warning $2
91165 +#else
91166 +#warning $1
91167 +#endif
91168 +EOF`
91169 +if [ $? -eq 0 ]
91170 +then
91171 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91172 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91173 +fi
91174 diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
91175 index 581ca99..a6ff02e 100644
91176 --- a/scripts/headers_install.pl
91177 +++ b/scripts/headers_install.pl
91178 @@ -35,6 +35,7 @@ foreach my $filename (@files) {
91179 $line =~ s/([\s(])__user\s/$1/g;
91180 $line =~ s/([\s(])__force\s/$1/g;
91181 $line =~ s/([\s(])__iomem\s/$1/g;
91182 + $line =~ s/(\s?)__intentional_overflow\([-\d\s,]*\)\s?/$1/g;
91183 $line =~ s/\s__attribute_const__\s/ /g;
91184 $line =~ s/\s__attribute_const__$//g;
91185 $line =~ s/\b__packed\b/__attribute__((packed))/g;
91186 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91187 index b3d907e..a4782ab 100644
91188 --- a/scripts/link-vmlinux.sh
91189 +++ b/scripts/link-vmlinux.sh
91190 @@ -152,7 +152,7 @@ else
91191 fi;
91192
91193 # final build of init/
91194 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91195 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91196
91197 kallsymso=""
91198 kallsyms_vmlinux=""
91199 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91200 index df4fc23..0ea719d 100644
91201 --- a/scripts/mod/file2alias.c
91202 +++ b/scripts/mod/file2alias.c
91203 @@ -128,7 +128,7 @@ static void device_id_check(const char *modname, const char *device_id,
91204 unsigned long size, unsigned long id_size,
91205 void *symval)
91206 {
91207 - int i;
91208 + unsigned int i;
91209
91210 if (size % id_size || size < id_size) {
91211 if (cross_build != 0)
91212 @@ -158,7 +158,7 @@ static void device_id_check(const char *modname, const char *device_id,
91213 /* USB is special because the bcdDevice can be matched against a numeric range */
91214 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91215 static void do_usb_entry(struct usb_device_id *id,
91216 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91217 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91218 unsigned char range_lo, unsigned char range_hi,
91219 unsigned char max, struct module *mod)
91220 {
91221 @@ -262,7 +262,7 @@ static void do_usb_entry_multi(struct usb_device_id *id, struct module *mod)
91222 {
91223 unsigned int devlo, devhi;
91224 unsigned char chi, clo, max;
91225 - int ndigits;
91226 + unsigned int ndigits;
91227
91228 id->match_flags = TO_NATIVE(id->match_flags);
91229 id->idVendor = TO_NATIVE(id->idVendor);
91230 @@ -507,7 +507,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91231 for (i = 0; i < count; i++) {
91232 const char *id = (char *)devs[i].id;
91233 char acpi_id[sizeof(devs[0].id)];
91234 - int j;
91235 + unsigned int j;
91236
91237 buf_printf(&mod->dev_table_buf,
91238 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91239 @@ -537,7 +537,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91240
91241 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91242 const char *id = (char *)card->devs[j].id;
91243 - int i2, j2;
91244 + unsigned int i2, j2;
91245 int dup = 0;
91246
91247 if (!id[0])
91248 @@ -563,7 +563,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91249 /* add an individual alias for every device entry */
91250 if (!dup) {
91251 char acpi_id[sizeof(card->devs[0].id)];
91252 - int k;
91253 + unsigned int k;
91254
91255 buf_printf(&mod->dev_table_buf,
91256 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91257 @@ -888,7 +888,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91258 static int do_dmi_entry(const char *filename, struct dmi_system_id *id,
91259 char *alias)
91260 {
91261 - int i, j;
91262 + unsigned int i, j;
91263
91264 sprintf(alias, "dmi*");
91265
91266 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91267 index ff36c50..7ab4fa9 100644
91268 --- a/scripts/mod/modpost.c
91269 +++ b/scripts/mod/modpost.c
91270 @@ -929,6 +929,7 @@ enum mismatch {
91271 ANY_INIT_TO_ANY_EXIT,
91272 ANY_EXIT_TO_ANY_INIT,
91273 EXPORT_TO_INIT_EXIT,
91274 + DATA_TO_TEXT
91275 };
91276
91277 struct sectioncheck {
91278 @@ -1043,6 +1044,12 @@ const struct sectioncheck sectioncheck[] = {
91279 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91280 .mismatch = EXPORT_TO_INIT_EXIT,
91281 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91282 +},
91283 +/* Do not reference code from writable data */
91284 +{
91285 + .fromsec = { DATA_SECTIONS, NULL },
91286 + .tosec = { TEXT_SECTIONS, NULL },
91287 + .mismatch = DATA_TO_TEXT
91288 }
91289 };
91290
91291 @@ -1165,10 +1172,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91292 continue;
91293 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91294 continue;
91295 - if (sym->st_value == addr)
91296 - return sym;
91297 /* Find a symbol nearby - addr are maybe negative */
91298 d = sym->st_value - addr;
91299 + if (d == 0)
91300 + return sym;
91301 if (d < 0)
91302 d = addr - sym->st_value;
91303 if (d < distance) {
91304 @@ -1447,6 +1454,14 @@ static void report_sec_mismatch(const char *modname,
91305 tosym, prl_to, prl_to, tosym);
91306 free(prl_to);
91307 break;
91308 + case DATA_TO_TEXT:
91309 +#if 0
91310 + fprintf(stderr,
91311 + "The %s %s:%s references\n"
91312 + "the %s %s:%s%s\n",
91313 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91314 +#endif
91315 + break;
91316 }
91317 fprintf(stderr, "\n");
91318 }
91319 @@ -1681,7 +1696,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91320 static void check_sec_ref(struct module *mod, const char *modname,
91321 struct elf_info *elf)
91322 {
91323 - int i;
91324 + unsigned int i;
91325 Elf_Shdr *sechdrs = elf->sechdrs;
91326
91327 /* Walk through all sections */
91328 @@ -1779,7 +1794,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91329 va_end(ap);
91330 }
91331
91332 -void buf_write(struct buffer *buf, const char *s, int len)
91333 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91334 {
91335 if (buf->size - buf->pos < len) {
91336 buf->size += len + SZ;
91337 @@ -1997,7 +2012,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91338 if (fstat(fileno(file), &st) < 0)
91339 goto close_write;
91340
91341 - if (st.st_size != b->pos)
91342 + if (st.st_size != (off_t)b->pos)
91343 goto close_write;
91344
91345 tmp = NOFAIL(malloc(b->pos));
91346 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91347 index 51207e4..f7d603d 100644
91348 --- a/scripts/mod/modpost.h
91349 +++ b/scripts/mod/modpost.h
91350 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91351
91352 struct buffer {
91353 char *p;
91354 - int pos;
91355 - int size;
91356 + unsigned int pos;
91357 + unsigned int size;
91358 };
91359
91360 void __attribute__((format(printf, 2, 3)))
91361 buf_printf(struct buffer *buf, const char *fmt, ...);
91362
91363 void
91364 -buf_write(struct buffer *buf, const char *s, int len);
91365 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91366
91367 struct module {
91368 struct module *next;
91369 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91370 index 9dfcd6d..099068e 100644
91371 --- a/scripts/mod/sumversion.c
91372 +++ b/scripts/mod/sumversion.c
91373 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91374 goto out;
91375 }
91376
91377 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91378 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91379 warn("writing sum in %s failed: %s\n",
91380 filename, strerror(errno));
91381 goto out;
91382 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91383 index acb8650..b8c5f02 100644
91384 --- a/scripts/package/builddeb
91385 +++ b/scripts/package/builddeb
91386 @@ -246,6 +246,7 @@ fi
91387 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91388 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91389 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91390 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91391 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91392 mkdir -p "$destdir"
91393 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91394 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91395 index 68bb4ef..2f419e1 100644
91396 --- a/scripts/pnmtologo.c
91397 +++ b/scripts/pnmtologo.c
91398 @@ -244,14 +244,14 @@ static void write_header(void)
91399 fprintf(out, " * Linux logo %s\n", logoname);
91400 fputs(" */\n\n", out);
91401 fputs("#include <linux/linux_logo.h>\n\n", out);
91402 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91403 + fprintf(out, "static unsigned char %s_data[] = {\n",
91404 logoname);
91405 }
91406
91407 static void write_footer(void)
91408 {
91409 fputs("\n};\n\n", out);
91410 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91411 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91412 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91413 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91414 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91415 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91416 fputs("\n};\n\n", out);
91417
91418 /* write logo clut */
91419 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91420 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91421 logoname);
91422 write_hex_cnt = 0;
91423 for (i = 0; i < logo_clutsize; i++) {
91424 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91425 index e4fd45b..2eeb5c4 100644
91426 --- a/scripts/sortextable.h
91427 +++ b/scripts/sortextable.h
91428 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91429 const char *secstrtab;
91430 const char *strtab;
91431 char *extab_image;
91432 - int extab_index = 0;
91433 - int i;
91434 - int idx;
91435 + unsigned int extab_index = 0;
91436 + unsigned int i;
91437 + unsigned int idx;
91438
91439 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91440 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91441 diff --git a/security/Kconfig b/security/Kconfig
91442 index e9c6ac7..4cb4ecc 100644
91443 --- a/security/Kconfig
91444 +++ b/security/Kconfig
91445 @@ -4,6 +4,943 @@
91446
91447 menu "Security options"
91448
91449 +menu "Grsecurity"
91450 +
91451 + config ARCH_TRACK_EXEC_LIMIT
91452 + bool
91453 +
91454 + config PAX_KERNEXEC_PLUGIN
91455 + bool
91456 +
91457 + config PAX_PER_CPU_PGD
91458 + bool
91459 +
91460 + config TASK_SIZE_MAX_SHIFT
91461 + int
91462 + depends on X86_64
91463 + default 47 if !PAX_PER_CPU_PGD
91464 + default 42 if PAX_PER_CPU_PGD
91465 +
91466 + config PAX_ENABLE_PAE
91467 + bool
91468 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91469 +
91470 + config PAX_USERCOPY_SLABS
91471 + bool
91472 +
91473 +config GRKERNSEC
91474 + bool "Grsecurity"
91475 + select CRYPTO
91476 + select CRYPTO_SHA256
91477 + select PROC_FS
91478 + select STOP_MACHINE
91479 + help
91480 + If you say Y here, you will be able to configure many features
91481 + that will enhance the security of your system. It is highly
91482 + recommended that you say Y here and read through the help
91483 + for each option so that you fully understand the features and
91484 + can evaluate their usefulness for your machine.
91485 +
91486 +choice
91487 + prompt "Configuration Method"
91488 + depends on GRKERNSEC
91489 + default GRKERNSEC_CONFIG_CUSTOM
91490 + help
91491 +
91492 +config GRKERNSEC_CONFIG_AUTO
91493 + bool "Automatic"
91494 + help
91495 + If you choose this configuration method, you'll be able to answer a small
91496 + number of simple questions about how you plan to use this kernel.
91497 + The settings of grsecurity and PaX will be automatically configured for
91498 + the highest commonly-used settings within the provided constraints.
91499 +
91500 + If you require additional configuration, custom changes can still be made
91501 + from the "custom configuration" menu.
91502 +
91503 +config GRKERNSEC_CONFIG_CUSTOM
91504 + bool "Custom"
91505 + help
91506 + If you choose this configuration method, you'll be able to configure all
91507 + grsecurity and PaX settings manually. Via this method, no options are
91508 + automatically enabled.
91509 +
91510 +endchoice
91511 +
91512 +choice
91513 + prompt "Usage Type"
91514 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91515 + default GRKERNSEC_CONFIG_SERVER
91516 + help
91517 +
91518 +config GRKERNSEC_CONFIG_SERVER
91519 + bool "Server"
91520 + help
91521 + Choose this option if you plan to use this kernel on a server.
91522 +
91523 +config GRKERNSEC_CONFIG_DESKTOP
91524 + bool "Desktop"
91525 + help
91526 + Choose this option if you plan to use this kernel on a desktop.
91527 +
91528 +endchoice
91529 +
91530 +choice
91531 + prompt "Virtualization Type"
91532 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91533 + default GRKERNSEC_CONFIG_VIRT_NONE
91534 + help
91535 +
91536 +config GRKERNSEC_CONFIG_VIRT_NONE
91537 + bool "None"
91538 + help
91539 + Choose this option if this kernel will be run on bare metal.
91540 +
91541 +config GRKERNSEC_CONFIG_VIRT_GUEST
91542 + bool "Guest"
91543 + help
91544 + Choose this option if this kernel will be run as a VM guest.
91545 +
91546 +config GRKERNSEC_CONFIG_VIRT_HOST
91547 + bool "Host"
91548 + help
91549 + Choose this option if this kernel will be run as a VM host.
91550 +
91551 +endchoice
91552 +
91553 +choice
91554 + prompt "Virtualization Hardware"
91555 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91556 + help
91557 +
91558 +config GRKERNSEC_CONFIG_VIRT_EPT
91559 + bool "EPT/RVI Processor Support"
91560 + depends on X86
91561 + help
91562 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91563 + hardware virtualization. This allows for additional kernel hardening protections
91564 + to operate without additional performance impact.
91565 +
91566 + To see if your Intel processor supports EPT, see:
91567 + http://ark.intel.com/Products/VirtualizationTechnology
91568 + (Most Core i3/5/7 support EPT)
91569 +
91570 + To see if your AMD processor supports RVI, see:
91571 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91572 +
91573 +config GRKERNSEC_CONFIG_VIRT_SOFT
91574 + bool "First-gen/No Hardware Virtualization"
91575 + help
91576 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91577 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91578 +
91579 +endchoice
91580 +
91581 +choice
91582 + prompt "Virtualization Software"
91583 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91584 + help
91585 +
91586 +config GRKERNSEC_CONFIG_VIRT_XEN
91587 + bool "Xen"
91588 + help
91589 + Choose this option if this kernel is running as a Xen guest or host.
91590 +
91591 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91592 + bool "VMWare"
91593 + help
91594 + Choose this option if this kernel is running as a VMWare guest or host.
91595 +
91596 +config GRKERNSEC_CONFIG_VIRT_KVM
91597 + bool "KVM"
91598 + help
91599 + Choose this option if this kernel is running as a KVM guest or host.
91600 +
91601 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91602 + bool "VirtualBox"
91603 + help
91604 + Choose this option if this kernel is running as a VirtualBox guest or host.
91605 +
91606 +endchoice
91607 +
91608 +choice
91609 + prompt "Required Priorities"
91610 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91611 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91612 + help
91613 +
91614 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91615 + bool "Performance"
91616 + help
91617 + Choose this option if performance is of highest priority for this deployment
91618 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91619 + clearing of structures intended for userland, and freed memory sanitizing will
91620 + be disabled.
91621 +
91622 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91623 + bool "Security"
91624 + help
91625 + Choose this option if security is of highest priority for this deployment of
91626 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91627 + for userland, and freed memory sanitizing will be enabled for this kernel.
91628 + In a worst-case scenario, these features can introduce a 20% performance hit
91629 + (UDEREF on x64 contributing half of this hit).
91630 +
91631 +endchoice
91632 +
91633 +menu "Default Special Groups"
91634 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91635 +
91636 +config GRKERNSEC_PROC_GID
91637 + int "GID exempted from /proc restrictions"
91638 + default 1001
91639 + help
91640 + Setting this GID determines which group will be exempted from
91641 + grsecurity's /proc restrictions, allowing users of the specified
91642 + group to view network statistics and the existence of other users'
91643 + processes on the system. This GID may also be chosen at boot time
91644 + via "grsec_proc_gid=" on the kernel commandline.
91645 +
91646 +config GRKERNSEC_TPE_UNTRUSTED_GID
91647 + int "GID for TPE-untrusted users"
91648 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91649 + default 1005
91650 + help
91651 + Setting this GID determines which group untrusted users should
91652 + be added to. These users will be placed under grsecurity's Trusted Path
91653 + Execution mechanism, preventing them from executing their own binaries.
91654 + The users will only be able to execute binaries in directories owned and
91655 + writable only by the root user. If the sysctl option is enabled, a sysctl
91656 + option with name "tpe_gid" is created.
91657 +
91658 +config GRKERNSEC_TPE_TRUSTED_GID
91659 + int "GID for TPE-trusted users"
91660 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91661 + default 1005
91662 + help
91663 + Setting this GID determines what group TPE restrictions will be
91664 + *disabled* for. If the sysctl option is enabled, a sysctl option
91665 + with name "tpe_gid" is created.
91666 +
91667 +config GRKERNSEC_SYMLINKOWN_GID
91668 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91669 + depends on GRKERNSEC_CONFIG_SERVER
91670 + default 1006
91671 + help
91672 + Setting this GID determines what group kernel-enforced
91673 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91674 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91675 +
91676 +
91677 +endmenu
91678 +
91679 +menu "Customize Configuration"
91680 +depends on GRKERNSEC
91681 +
91682 +menu "PaX"
91683 +
91684 +config PAX
91685 + bool "Enable various PaX features"
91686 + default y if GRKERNSEC_CONFIG_AUTO
91687 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91688 + help
91689 + This allows you to enable various PaX features. PaX adds
91690 + intrusion prevention mechanisms to the kernel that reduce
91691 + the risks posed by exploitable memory corruption bugs.
91692 +
91693 +menu "PaX Control"
91694 + depends on PAX
91695 +
91696 +config PAX_SOFTMODE
91697 + bool 'Support soft mode'
91698 + help
91699 + Enabling this option will allow you to run PaX in soft mode, that
91700 + is, PaX features will not be enforced by default, only on executables
91701 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91702 + support as they are the only way to mark executables for soft mode use.
91703 +
91704 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91705 + line option on boot. Furthermore you can control various PaX features
91706 + at runtime via the entries in /proc/sys/kernel/pax.
91707 +
91708 +config PAX_EI_PAX
91709 + bool 'Use legacy ELF header marking'
91710 + default y if GRKERNSEC_CONFIG_AUTO
91711 + help
91712 + Enabling this option will allow you to control PaX features on
91713 + a per executable basis via the 'chpax' utility available at
91714 + http://pax.grsecurity.net/. The control flags will be read from
91715 + an otherwise reserved part of the ELF header. This marking has
91716 + numerous drawbacks (no support for soft-mode, toolchain does not
91717 + know about the non-standard use of the ELF header) therefore it
91718 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91719 + support.
91720 +
91721 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
91722 + support as well, they will override the legacy EI_PAX marks.
91723 +
91724 + If you enable none of the marking options then all applications
91725 + will run with PaX enabled on them by default.
91726 +
91727 +config PAX_PT_PAX_FLAGS
91728 + bool 'Use ELF program header marking'
91729 + default y if GRKERNSEC_CONFIG_AUTO
91730 + help
91731 + Enabling this option will allow you to control PaX features on
91732 + a per executable basis via the 'paxctl' utility available at
91733 + http://pax.grsecurity.net/. The control flags will be read from
91734 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
91735 + has the benefits of supporting both soft mode and being fully
91736 + integrated into the toolchain (the binutils patch is available
91737 + from http://pax.grsecurity.net).
91738 +
91739 + Note that if you enable the legacy EI_PAX marking support as well,
91740 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
91741 +
91742 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91743 + must make sure that the marks are the same if a binary has both marks.
91744 +
91745 + If you enable none of the marking options then all applications
91746 + will run with PaX enabled on them by default.
91747 +
91748 +config PAX_XATTR_PAX_FLAGS
91749 + bool 'Use filesystem extended attributes marking'
91750 + default y if GRKERNSEC_CONFIG_AUTO
91751 + select CIFS_XATTR if CIFS
91752 + select EXT2_FS_XATTR if EXT2_FS
91753 + select EXT3_FS_XATTR if EXT3_FS
91754 + select EXT4_FS_XATTR if EXT4_FS
91755 + select JFFS2_FS_XATTR if JFFS2_FS
91756 + select REISERFS_FS_XATTR if REISERFS_FS
91757 + select SQUASHFS_XATTR if SQUASHFS
91758 + select TMPFS_XATTR if TMPFS
91759 + select UBIFS_FS_XATTR if UBIFS_FS
91760 + help
91761 + Enabling this option will allow you to control PaX features on
91762 + a per executable basis via the 'setfattr' utility. The control
91763 + flags will be read from the user.pax.flags extended attribute of
91764 + the file. This marking has the benefit of supporting binary-only
91765 + applications that self-check themselves (e.g., skype) and would
91766 + not tolerate chpax/paxctl changes. The main drawback is that
91767 + extended attributes are not supported by some filesystems (e.g.,
91768 + isofs, udf, vfat) so copying files through such filesystems will
91769 + lose the extended attributes and these PaX markings.
91770 +
91771 + Note that if you enable the legacy EI_PAX marking support as well,
91772 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
91773 +
91774 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
91775 + must make sure that the marks are the same if a binary has both marks.
91776 +
91777 + If you enable none of the marking options then all applications
91778 + will run with PaX enabled on them by default.
91779 +
91780 +choice
91781 + prompt 'MAC system integration'
91782 + default PAX_HAVE_ACL_FLAGS
91783 + help
91784 + Mandatory Access Control systems have the option of controlling
91785 + PaX flags on a per executable basis, choose the method supported
91786 + by your particular system.
91787 +
91788 + - "none": if your MAC system does not interact with PaX,
91789 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
91790 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
91791 +
91792 + NOTE: this option is for developers/integrators only.
91793 +
91794 + config PAX_NO_ACL_FLAGS
91795 + bool 'none'
91796 +
91797 + config PAX_HAVE_ACL_FLAGS
91798 + bool 'direct'
91799 +
91800 + config PAX_HOOK_ACL_FLAGS
91801 + bool 'hook'
91802 +endchoice
91803 +
91804 +endmenu
91805 +
91806 +menu "Non-executable pages"
91807 + depends on PAX
91808 +
91809 +config PAX_NOEXEC
91810 + bool "Enforce non-executable pages"
91811 + default y if GRKERNSEC_CONFIG_AUTO
91812 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
91813 + help
91814 + By design some architectures do not allow for protecting memory
91815 + pages against execution or even if they do, Linux does not make
91816 + use of this feature. In practice this means that if a page is
91817 + readable (such as the stack or heap) it is also executable.
91818 +
91819 + There is a well known exploit technique that makes use of this
91820 + fact and a common programming mistake where an attacker can
91821 + introduce code of his choice somewhere in the attacked program's
91822 + memory (typically the stack or the heap) and then execute it.
91823 +
91824 + If the attacked program was running with different (typically
91825 + higher) privileges than that of the attacker, then he can elevate
91826 + his own privilege level (e.g. get a root shell, write to files for
91827 + which he does not have write access to, etc).
91828 +
91829 + Enabling this option will let you choose from various features
91830 + that prevent the injection and execution of 'foreign' code in
91831 + a program.
91832 +
91833 + This will also break programs that rely on the old behaviour and
91834 + expect that dynamically allocated memory via the malloc() family
91835 + of functions is executable (which it is not). Notable examples
91836 + are the XFree86 4.x server, the java runtime and wine.
91837 +
91838 +config PAX_PAGEEXEC
91839 + bool "Paging based non-executable pages"
91840 + default y if GRKERNSEC_CONFIG_AUTO
91841 + 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)
91842 + select S390_SWITCH_AMODE if S390
91843 + select S390_EXEC_PROTECT if S390
91844 + select ARCH_TRACK_EXEC_LIMIT if X86_32
91845 + help
91846 + This implementation is based on the paging feature of the CPU.
91847 + On i386 without hardware non-executable bit support there is a
91848 + variable but usually low performance impact, however on Intel's
91849 + P4 core based CPUs it is very high so you should not enable this
91850 + for kernels meant to be used on such CPUs.
91851 +
91852 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
91853 + with hardware non-executable bit support there is no performance
91854 + impact, on ppc the impact is negligible.
91855 +
91856 + Note that several architectures require various emulations due to
91857 + badly designed userland ABIs, this will cause a performance impact
91858 + but will disappear as soon as userland is fixed. For example, ppc
91859 + userland MUST have been built with secure-plt by a recent toolchain.
91860 +
91861 +config PAX_SEGMEXEC
91862 + bool "Segmentation based non-executable pages"
91863 + default y if GRKERNSEC_CONFIG_AUTO
91864 + depends on PAX_NOEXEC && X86_32
91865 + help
91866 + This implementation is based on the segmentation feature of the
91867 + CPU and has a very small performance impact, however applications
91868 + will be limited to a 1.5 GB address space instead of the normal
91869 + 3 GB.
91870 +
91871 +config PAX_EMUTRAMP
91872 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
91873 + default y if PARISC
91874 + help
91875 + There are some programs and libraries that for one reason or
91876 + another attempt to execute special small code snippets from
91877 + non-executable memory pages. Most notable examples are the
91878 + signal handler return code generated by the kernel itself and
91879 + the GCC trampolines.
91880 +
91881 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
91882 + such programs will no longer work under your kernel.
91883 +
91884 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
91885 + utilities to enable trampoline emulation for the affected programs
91886 + yet still have the protection provided by the non-executable pages.
91887 +
91888 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
91889 + your system will not even boot.
91890 +
91891 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
91892 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
91893 + for the affected files.
91894 +
91895 + NOTE: enabling this feature *may* open up a loophole in the
91896 + protection provided by non-executable pages that an attacker
91897 + could abuse. Therefore the best solution is to not have any
91898 + files on your system that would require this option. This can
91899 + be achieved by not using libc5 (which relies on the kernel
91900 + signal handler return code) and not using or rewriting programs
91901 + that make use of the nested function implementation of GCC.
91902 + Skilled users can just fix GCC itself so that it implements
91903 + nested function calls in a way that does not interfere with PaX.
91904 +
91905 +config PAX_EMUSIGRT
91906 + bool "Automatically emulate sigreturn trampolines"
91907 + depends on PAX_EMUTRAMP && PARISC
91908 + default y
91909 + help
91910 + Enabling this option will have the kernel automatically detect
91911 + and emulate signal return trampolines executing on the stack
91912 + that would otherwise lead to task termination.
91913 +
91914 + This solution is intended as a temporary one for users with
91915 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
91916 + Modula-3 runtime, etc) or executables linked to such, basically
91917 + everything that does not specify its own SA_RESTORER function in
91918 + normal executable memory like glibc 2.1+ does.
91919 +
91920 + On parisc you MUST enable this option, otherwise your system will
91921 + not even boot.
91922 +
91923 + NOTE: this feature cannot be disabled on a per executable basis
91924 + and since it *does* open up a loophole in the protection provided
91925 + by non-executable pages, the best solution is to not have any
91926 + files on your system that would require this option.
91927 +
91928 +config PAX_MPROTECT
91929 + bool "Restrict mprotect()"
91930 + default y if GRKERNSEC_CONFIG_AUTO
91931 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
91932 + help
91933 + Enabling this option will prevent programs from
91934 + - changing the executable status of memory pages that were
91935 + not originally created as executable,
91936 + - making read-only executable pages writable again,
91937 + - creating executable pages from anonymous memory,
91938 + - making read-only-after-relocations (RELRO) data pages writable again.
91939 +
91940 + You should say Y here to complete the protection provided by
91941 + the enforcement of non-executable pages.
91942 +
91943 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
91944 + this feature on a per file basis.
91945 +
91946 +config PAX_MPROTECT_COMPAT
91947 + bool "Use legacy/compat protection demoting (read help)"
91948 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
91949 + depends on PAX_MPROTECT
91950 + help
91951 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
91952 + by sending the proper error code to the application. For some broken
91953 + userland, this can cause problems with Python or other applications. The
91954 + current implementation however allows for applications like clamav to
91955 + detect if JIT compilation/execution is allowed and to fall back gracefully
91956 + to an interpreter-based mode if it does not. While we encourage everyone
91957 + to use the current implementation as-is and push upstream to fix broken
91958 + userland (note that the RWX logging option can assist with this), in some
91959 + environments this may not be possible. Having to disable MPROTECT
91960 + completely on certain binaries reduces the security benefit of PaX,
91961 + so this option is provided for those environments to revert to the old
91962 + behavior.
91963 +
91964 +config PAX_ELFRELOCS
91965 + bool "Allow ELF text relocations (read help)"
91966 + depends on PAX_MPROTECT
91967 + default n
91968 + help
91969 + Non-executable pages and mprotect() restrictions are effective
91970 + in preventing the introduction of new executable code into an
91971 + attacked task's address space. There remain only two venues
91972 + for this kind of attack: if the attacker can execute already
91973 + existing code in the attacked task then he can either have it
91974 + create and mmap() a file containing his code or have it mmap()
91975 + an already existing ELF library that does not have position
91976 + independent code in it and use mprotect() on it to make it
91977 + writable and copy his code there. While protecting against
91978 + the former approach is beyond PaX, the latter can be prevented
91979 + by having only PIC ELF libraries on one's system (which do not
91980 + need to relocate their code). If you are sure this is your case,
91981 + as is the case with all modern Linux distributions, then leave
91982 + this option disabled. You should say 'n' here.
91983 +
91984 +config PAX_ETEXECRELOCS
91985 + bool "Allow ELF ET_EXEC text relocations"
91986 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
91987 + select PAX_ELFRELOCS
91988 + default y
91989 + help
91990 + On some architectures there are incorrectly created applications
91991 + that require text relocations and would not work without enabling
91992 + this option. If you are an alpha, ia64 or parisc user, you should
91993 + enable this option and disable it once you have made sure that
91994 + none of your applications need it.
91995 +
91996 +config PAX_EMUPLT
91997 + bool "Automatically emulate ELF PLT"
91998 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
91999 + default y
92000 + help
92001 + Enabling this option will have the kernel automatically detect
92002 + and emulate the Procedure Linkage Table entries in ELF files.
92003 + On some architectures such entries are in writable memory, and
92004 + become non-executable leading to task termination. Therefore
92005 + it is mandatory that you enable this option on alpha, parisc,
92006 + sparc and sparc64, otherwise your system would not even boot.
92007 +
92008 + NOTE: this feature *does* open up a loophole in the protection
92009 + provided by the non-executable pages, therefore the proper
92010 + solution is to modify the toolchain to produce a PLT that does
92011 + not need to be writable.
92012 +
92013 +config PAX_DLRESOLVE
92014 + bool 'Emulate old glibc resolver stub'
92015 + depends on PAX_EMUPLT && SPARC
92016 + default n
92017 + help
92018 + This option is needed if userland has an old glibc (before 2.4)
92019 + that puts a 'save' instruction into the runtime generated resolver
92020 + stub that needs special emulation.
92021 +
92022 +config PAX_KERNEXEC
92023 + bool "Enforce non-executable kernel pages"
92024 + 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))
92025 + depends on ((X86 && (!X86_32 || X86_WP_WORKS_OK)) || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92026 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92027 + select PAX_KERNEXEC_PLUGIN if X86_64
92028 + help
92029 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92030 + that is, enabling this option will make it harder to inject
92031 + and execute 'foreign' code in kernel memory itself.
92032 +
92033 +choice
92034 + prompt "Return Address Instrumentation Method"
92035 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92036 + depends on PAX_KERNEXEC_PLUGIN
92037 + help
92038 + Select the method used to instrument function pointer dereferences.
92039 + Note that binary modules cannot be instrumented by this approach.
92040 +
92041 + Note that the implementation requires a gcc with plugin support,
92042 + i.e., gcc 4.5 or newer. You may need to install the supporting
92043 + headers explicitly in addition to the normal gcc package.
92044 +
92045 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92046 + bool "bts"
92047 + help
92048 + This method is compatible with binary only modules but has
92049 + a higher runtime overhead.
92050 +
92051 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92052 + bool "or"
92053 + depends on !PARAVIRT
92054 + help
92055 + This method is incompatible with binary only modules but has
92056 + a lower runtime overhead.
92057 +endchoice
92058 +
92059 +config PAX_KERNEXEC_PLUGIN_METHOD
92060 + string
92061 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92062 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92063 + default ""
92064 +
92065 +config PAX_KERNEXEC_MODULE_TEXT
92066 + int "Minimum amount of memory reserved for module code"
92067 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92068 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92069 + depends on PAX_KERNEXEC && X86_32 && MODULES
92070 + help
92071 + Due to implementation details the kernel must reserve a fixed
92072 + amount of memory for module code at compile time that cannot be
92073 + changed at runtime. Here you can specify the minimum amount
92074 + in MB that will be reserved. Due to the same implementation
92075 + details this size will always be rounded up to the next 2/4 MB
92076 + boundary (depends on PAE) so the actually available memory for
92077 + module code will usually be more than this minimum.
92078 +
92079 + The default 4 MB should be enough for most users but if you have
92080 + an excessive number of modules (e.g., most distribution configs
92081 + compile many drivers as modules) or use huge modules such as
92082 + nvidia's kernel driver, you will need to adjust this amount.
92083 + A good rule of thumb is to look at your currently loaded kernel
92084 + modules and add up their sizes.
92085 +
92086 +endmenu
92087 +
92088 +menu "Address Space Layout Randomization"
92089 + depends on PAX
92090 +
92091 +config PAX_ASLR
92092 + bool "Address Space Layout Randomization"
92093 + default y if GRKERNSEC_CONFIG_AUTO
92094 + help
92095 + Many if not most exploit techniques rely on the knowledge of
92096 + certain addresses in the attacked program. The following options
92097 + will allow the kernel to apply a certain amount of randomization
92098 + to specific parts of the program thereby forcing an attacker to
92099 + guess them in most cases. Any failed guess will most likely crash
92100 + the attacked program which allows the kernel to detect such attempts
92101 + and react on them. PaX itself provides no reaction mechanisms,
92102 + instead it is strongly encouraged that you make use of Nergal's
92103 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92104 + (http://www.grsecurity.net/) built-in crash detection features or
92105 + develop one yourself.
92106 +
92107 + By saying Y here you can choose to randomize the following areas:
92108 + - top of the task's kernel stack
92109 + - top of the task's userland stack
92110 + - base address for mmap() requests that do not specify one
92111 + (this includes all libraries)
92112 + - base address of the main executable
92113 +
92114 + It is strongly recommended to say Y here as address space layout
92115 + randomization has negligible impact on performance yet it provides
92116 + a very effective protection.
92117 +
92118 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92119 + this feature on a per file basis.
92120 +
92121 +config PAX_RANDKSTACK
92122 + bool "Randomize kernel stack base"
92123 + default y if GRKERNSEC_CONFIG_AUTO
92124 + depends on X86_TSC && X86
92125 + help
92126 + By saying Y here the kernel will randomize every task's kernel
92127 + stack on every system call. This will not only force an attacker
92128 + to guess it but also prevent him from making use of possible
92129 + leaked information about it.
92130 +
92131 + Since the kernel stack is a rather scarce resource, randomization
92132 + may cause unexpected stack overflows, therefore you should very
92133 + carefully test your system. Note that once enabled in the kernel
92134 + configuration, this feature cannot be disabled on a per file basis.
92135 +
92136 +config PAX_RANDUSTACK
92137 + bool "Randomize user stack base"
92138 + default y if GRKERNSEC_CONFIG_AUTO
92139 + depends on PAX_ASLR
92140 + help
92141 + By saying Y here the kernel will randomize every task's userland
92142 + stack. The randomization is done in two steps where the second
92143 + one may apply a big amount of shift to the top of the stack and
92144 + cause problems for programs that want to use lots of memory (more
92145 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92146 + For this reason the second step can be controlled by 'chpax' or
92147 + 'paxctl' on a per file basis.
92148 +
92149 +config PAX_RANDMMAP
92150 + bool "Randomize mmap() base"
92151 + default y if GRKERNSEC_CONFIG_AUTO
92152 + depends on PAX_ASLR
92153 + help
92154 + By saying Y here the kernel will use a randomized base address for
92155 + mmap() requests that do not specify one themselves. As a result
92156 + all dynamically loaded libraries will appear at random addresses
92157 + and therefore be harder to exploit by a technique where an attacker
92158 + attempts to execute library code for his purposes (e.g. spawn a
92159 + shell from an exploited program that is running at an elevated
92160 + privilege level).
92161 +
92162 + Furthermore, if a program is relinked as a dynamic ELF file, its
92163 + base address will be randomized as well, completing the full
92164 + randomization of the address space layout. Attacking such programs
92165 + becomes a guess game. You can find an example of doing this at
92166 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92167 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92168 +
92169 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92170 + feature on a per file basis.
92171 +
92172 +endmenu
92173 +
92174 +menu "Miscellaneous hardening features"
92175 +
92176 +config PAX_MEMORY_SANITIZE
92177 + bool "Sanitize all freed memory"
92178 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92179 + depends on !HIBERNATION
92180 + help
92181 + By saying Y here the kernel will erase memory pages as soon as they
92182 + are freed. This in turn reduces the lifetime of data stored in the
92183 + pages, making it less likely that sensitive information such as
92184 + passwords, cryptographic secrets, etc stay in memory for too long.
92185 +
92186 + This is especially useful for programs whose runtime is short, long
92187 + lived processes and the kernel itself benefit from this as long as
92188 + they operate on whole memory pages and ensure timely freeing of pages
92189 + that may hold sensitive information.
92190 +
92191 + The tradeoff is performance impact, on a single CPU system kernel
92192 + compilation sees a 3% slowdown, other systems and workloads may vary
92193 + and you are advised to test this feature on your expected workload
92194 + before deploying it.
92195 +
92196 + Note that this feature does not protect data stored in live pages,
92197 + e.g., process memory swapped to disk may stay there for a long time.
92198 +
92199 +config PAX_MEMORY_STACKLEAK
92200 + bool "Sanitize kernel stack"
92201 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92202 + depends on X86
92203 + help
92204 + By saying Y here the kernel will erase the kernel stack before it
92205 + returns from a system call. This in turn reduces the information
92206 + that a kernel stack leak bug can reveal.
92207 +
92208 + Note that such a bug can still leak information that was put on
92209 + the stack by the current system call (the one eventually triggering
92210 + the bug) but traces of earlier system calls on the kernel stack
92211 + cannot leak anymore.
92212 +
92213 + The tradeoff is performance impact: on a single CPU system kernel
92214 + compilation sees a 1% slowdown, other systems and workloads may vary
92215 + and you are advised to test this feature on your expected workload
92216 + before deploying it.
92217 +
92218 + Note that the full feature requires a gcc with plugin support,
92219 + i.e., gcc 4.5 or newer. You may need to install the supporting
92220 + headers explicitly in addition to the normal gcc package. Using
92221 + older gcc versions means that functions with large enough stack
92222 + frames may leave uninitialized memory behind that may be exposed
92223 + to a later syscall leaking the stack.
92224 +
92225 +config PAX_MEMORY_STRUCTLEAK
92226 + bool "Forcibly initialize local variables copied to userland"
92227 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92228 + help
92229 + By saying Y here the kernel will zero initialize some local
92230 + variables that are going to be copied to userland. This in
92231 + turn prevents unintended information leakage from the kernel
92232 + stack should later code forget to explicitly set all parts of
92233 + the copied variable.
92234 +
92235 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92236 + at a much smaller coverage.
92237 +
92238 + Note that the implementation requires a gcc with plugin support,
92239 + i.e., gcc 4.5 or newer. You may need to install the supporting
92240 + headers explicitly in addition to the normal gcc package.
92241 +
92242 +config PAX_MEMORY_UDEREF
92243 + bool "Prevent invalid userland pointer dereference"
92244 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92245 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92246 + select PAX_PER_CPU_PGD if X86_64
92247 + help
92248 + By saying Y here the kernel will be prevented from dereferencing
92249 + userland pointers in contexts where the kernel expects only kernel
92250 + pointers. This is both a useful runtime debugging feature and a
92251 + security measure that prevents exploiting a class of kernel bugs.
92252 +
92253 + The tradeoff is that some virtualization solutions may experience
92254 + a huge slowdown and therefore you should not enable this feature
92255 + for kernels meant to run in such environments. Whether a given VM
92256 + solution is affected or not is best determined by simply trying it
92257 + out, the performance impact will be obvious right on boot as this
92258 + mechanism engages from very early on. A good rule of thumb is that
92259 + VMs running on CPUs without hardware virtualization support (i.e.,
92260 + the majority of IA-32 CPUs) will likely experience the slowdown.
92261 +
92262 +config PAX_REFCOUNT
92263 + bool "Prevent various kernel object reference counter overflows"
92264 + default y if GRKERNSEC_CONFIG_AUTO
92265 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92266 + help
92267 + By saying Y here the kernel will detect and prevent overflowing
92268 + various (but not all) kinds of object reference counters. Such
92269 + overflows can normally occur due to bugs only and are often, if
92270 + not always, exploitable.
92271 +
92272 + The tradeoff is that data structures protected by an overflowed
92273 + refcount will never be freed and therefore will leak memory. Note
92274 + that this leak also happens even without this protection but in
92275 + that case the overflow can eventually trigger the freeing of the
92276 + data structure while it is still being used elsewhere, resulting
92277 + in the exploitable situation that this feature prevents.
92278 +
92279 + Since this has a negligible performance impact, you should enable
92280 + this feature.
92281 +
92282 +config PAX_CONSTIFY_PLUGIN
92283 + bool "Automatically constify eligible structures"
92284 + default y
92285 + depends on !UML && PAX_KERNEXEC
92286 + help
92287 + By saying Y here the compiler will automatically constify a class
92288 + of types that contain only function pointers. This reduces the
92289 + kernel's attack surface and also produces a better memory layout.
92290 +
92291 + Note that the implementation requires a gcc with plugin support,
92292 + i.e., gcc 4.5 or newer. You may need to install the supporting
92293 + headers explicitly in addition to the normal gcc package.
92294 +
92295 + Note that if some code really has to modify constified variables
92296 + then the source code will have to be patched to allow it. Examples
92297 + can be found in PaX itself (the no_const attribute) and for some
92298 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92299 +
92300 +config PAX_USERCOPY
92301 + bool "Harden heap object copies between kernel and userland"
92302 + default y if GRKERNSEC_CONFIG_AUTO
92303 + depends on ARM || IA64 || PPC || SPARC || X86
92304 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92305 + select PAX_USERCOPY_SLABS
92306 + help
92307 + By saying Y here the kernel will enforce the size of heap objects
92308 + when they are copied in either direction between the kernel and
92309 + userland, even if only a part of the heap object is copied.
92310 +
92311 + Specifically, this checking prevents information leaking from the
92312 + kernel heap during kernel to userland copies (if the kernel heap
92313 + object is otherwise fully initialized) and prevents kernel heap
92314 + overflows during userland to kernel copies.
92315 +
92316 + Note that the current implementation provides the strictest bounds
92317 + checks for the SLUB allocator.
92318 +
92319 + Enabling this option also enables per-slab cache protection against
92320 + data in a given cache being copied into/out of via userland
92321 + accessors. Though the whitelist of regions will be reduced over
92322 + time, it notably protects important data structures like task structs.
92323 +
92324 + If frame pointers are enabled on x86, this option will also restrict
92325 + copies into and out of the kernel stack to local variables within a
92326 + single frame.
92327 +
92328 + Since this has a negligible performance impact, you should enable
92329 + this feature.
92330 +
92331 +config PAX_USERCOPY_DEBUG
92332 + bool
92333 + depends on X86 && PAX_USERCOPY
92334 + default n
92335 +
92336 +config PAX_SIZE_OVERFLOW
92337 + bool "Prevent various integer overflows in function size parameters"
92338 + default y if GRKERNSEC_CONFIG_AUTO
92339 + depends on X86
92340 + help
92341 + By saying Y here the kernel recomputes expressions of function
92342 + arguments marked by a size_overflow attribute with double integer
92343 + precision (DImode/TImode for 32/64 bit integer types).
92344 +
92345 + The recomputed argument is checked against TYPE_MAX and an event
92346 + is logged on overflow and the triggering process is killed.
92347 +
92348 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92349 +
92350 + Note that the implementation requires a gcc with plugin support,
92351 + i.e., gcc 4.5 or newer. You may need to install the supporting
92352 + headers explicitly in addition to the normal gcc package.
92353 +
92354 +config PAX_LATENT_ENTROPY
92355 + bool "Generate some entropy during boot"
92356 + default y if GRKERNSEC_CONFIG_AUTO
92357 + help
92358 + By saying Y here the kernel will instrument early boot code to
92359 + extract some entropy from both original and artificially created
92360 + program state. This will help especially embedded systems where
92361 + there is little 'natural' source of entropy normally. The cost
92362 + is some slowdown of the boot process.
92363 +
92364 + When pax_extra_latent_entropy is passed on the kernel command line,
92365 + entropy will be extracted from up to the first 4GB of RAM while the
92366 + runtime memory allocator is being initialized. This costs even more
92367 + slowdown of the boot process.
92368 +
92369 + Note that the implementation requires a gcc with plugin support,
92370 + i.e., gcc 4.5 or newer. You may need to install the supporting
92371 + headers explicitly in addition to the normal gcc package.
92372 +
92373 + Note that entropy extracted this way is not cryptographically
92374 + secure!
92375 +
92376 +endmenu
92377 +
92378 +endmenu
92379 +
92380 +source grsecurity/Kconfig
92381 +
92382 +endmenu
92383 +
92384 +endmenu
92385 +
92386 source security/keys/Kconfig
92387
92388 config SECURITY_DMESG_RESTRICT
92389 @@ -103,7 +1040,7 @@ config INTEL_TXT
92390 config LSM_MMAP_MIN_ADDR
92391 int "Low address space for LSM to protect from user allocation"
92392 depends on SECURITY && SECURITY_SELINUX
92393 - default 32768 if ARM
92394 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92395 default 65536
92396 help
92397 This is the portion of low virtual memory which should be protected
92398 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92399 index 8c2a7f6..b133ac9 100644
92400 --- a/security/apparmor/lsm.c
92401 +++ b/security/apparmor/lsm.c
92402 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92403 return error;
92404 }
92405
92406 -static struct security_operations apparmor_ops = {
92407 +static struct security_operations apparmor_ops __read_only = {
92408 .name = "apparmor",
92409
92410 .ptrace_access_check = apparmor_ptrace_access_check,
92411 diff --git a/security/commoncap.c b/security/commoncap.c
92412 index 7ee08c7..8d1a9d6 100644
92413 --- a/security/commoncap.c
92414 +++ b/security/commoncap.c
92415 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92416 return 0;
92417 }
92418
92419 +/* returns:
92420 + 1 for suid privilege
92421 + 2 for sgid privilege
92422 + 3 for fscap privilege
92423 +*/
92424 +int is_privileged_binary(const struct dentry *dentry)
92425 +{
92426 + struct cpu_vfs_cap_data capdata;
92427 + struct inode *inode = dentry->d_inode;
92428 +
92429 + if (!inode || S_ISDIR(inode->i_mode))
92430 + return 0;
92431 +
92432 + if (inode->i_mode & S_ISUID)
92433 + return 1;
92434 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92435 + return 2;
92436 +
92437 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92438 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92439 + return 3;
92440 + }
92441 +
92442 + return 0;
92443 +}
92444 +
92445 /*
92446 * Attempt to get the on-exec apply capability sets for an executable file from
92447 * its xattrs and, if present, apply them to the proposed credentials being
92448 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92449 const struct cred *cred = current_cred();
92450 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92451
92452 + if (gr_acl_enable_at_secure())
92453 + return 1;
92454 +
92455 if (!uid_eq(cred->uid, root_uid)) {
92456 if (bprm->cap_effective)
92457 return 1;
92458 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
92459 index 079a85d..12e93f8 100644
92460 --- a/security/integrity/ima/ima.h
92461 +++ b/security/integrity/ima/ima.h
92462 @@ -96,8 +96,8 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92463 extern spinlock_t ima_queue_lock;
92464
92465 struct ima_h_table {
92466 - atomic_long_t len; /* number of stored measurements in the list */
92467 - atomic_long_t violations;
92468 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
92469 + atomic_long_unchecked_t violations;
92470 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
92471 };
92472 extern struct ima_h_table ima_htable;
92473 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
92474 index 0cea3db..2f0ef77 100644
92475 --- a/security/integrity/ima/ima_api.c
92476 +++ b/security/integrity/ima/ima_api.c
92477 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
92478 int result;
92479
92480 /* can overflow, only indicator */
92481 - atomic_long_inc(&ima_htable.violations);
92482 + atomic_long_inc_unchecked(&ima_htable.violations);
92483
92484 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
92485 if (!entry) {
92486 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
92487 index 38477c9..87a60c7 100644
92488 --- a/security/integrity/ima/ima_fs.c
92489 +++ b/security/integrity/ima/ima_fs.c
92490 @@ -28,12 +28,12 @@
92491 static int valid_policy = 1;
92492 #define TMPBUFLEN 12
92493 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
92494 - loff_t *ppos, atomic_long_t *val)
92495 + loff_t *ppos, atomic_long_unchecked_t *val)
92496 {
92497 char tmpbuf[TMPBUFLEN];
92498 ssize_t len;
92499
92500 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
92501 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
92502 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
92503 }
92504
92505 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
92506 index 55a6271..ad829c3 100644
92507 --- a/security/integrity/ima/ima_queue.c
92508 +++ b/security/integrity/ima/ima_queue.c
92509 @@ -81,7 +81,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
92510 INIT_LIST_HEAD(&qe->later);
92511 list_add_tail_rcu(&qe->later, &ima_measurements);
92512
92513 - atomic_long_inc(&ima_htable.len);
92514 + atomic_long_inc_unchecked(&ima_htable.len);
92515 key = ima_hash_key(entry->digest);
92516 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
92517 return 0;
92518 diff --git a/security/keys/compat.c b/security/keys/compat.c
92519 index d65fa7f..cbfe366 100644
92520 --- a/security/keys/compat.c
92521 +++ b/security/keys/compat.c
92522 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
92523 if (ret == 0)
92524 goto no_payload_free;
92525
92526 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92527 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92528 err:
92529 if (iov != iovstack)
92530 kfree(iov);
92531 diff --git a/security/keys/key.c b/security/keys/key.c
92532 index 8fb7c7b..ba3610d 100644
92533 --- a/security/keys/key.c
92534 +++ b/security/keys/key.c
92535 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
92536
92537 atomic_set(&key->usage, 1);
92538 init_rwsem(&key->sem);
92539 - lockdep_set_class(&key->sem, &type->lock_class);
92540 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
92541 key->type = type;
92542 key->user = user;
92543 key->quotalen = quotalen;
92544 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
92545 struct key_type *p;
92546 int ret;
92547
92548 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
92549 + pax_open_kernel();
92550 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
92551 + pax_close_kernel();
92552
92553 ret = -EEXIST;
92554 down_write(&key_types_sem);
92555 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
92556 }
92557
92558 /* store the type */
92559 - list_add(&ktype->link, &key_types_list);
92560 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
92561
92562 pr_notice("Key type %s registered\n", ktype->name);
92563 ret = 0;
92564 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
92565 void unregister_key_type(struct key_type *ktype)
92566 {
92567 down_write(&key_types_sem);
92568 - list_del_init(&ktype->link);
92569 + pax_list_del_init((struct list_head *)&ktype->link);
92570 downgrade_write(&key_types_sem);
92571 key_gc_keytype(ktype);
92572 pr_notice("Key type %s unregistered\n", ktype->name);
92573 @@ -1084,10 +1086,10 @@ void __init key_init(void)
92574 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
92575
92576 /* add the special key types */
92577 - list_add_tail(&key_type_keyring.link, &key_types_list);
92578 - list_add_tail(&key_type_dead.link, &key_types_list);
92579 - list_add_tail(&key_type_user.link, &key_types_list);
92580 - list_add_tail(&key_type_logon.link, &key_types_list);
92581 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
92582 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
92583 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
92584 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
92585
92586 /* record the root user tracking */
92587 rb_link_node(&root_key_user.node,
92588 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
92589 index 4b5c948..2054dc1 100644
92590 --- a/security/keys/keyctl.c
92591 +++ b/security/keys/keyctl.c
92592 @@ -986,7 +986,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
92593 /*
92594 * Copy the iovec data from userspace
92595 */
92596 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92597 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
92598 unsigned ioc)
92599 {
92600 for (; ioc > 0; ioc--) {
92601 @@ -1008,7 +1008,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
92602 * If successful, 0 will be returned.
92603 */
92604 long keyctl_instantiate_key_common(key_serial_t id,
92605 - const struct iovec *payload_iov,
92606 + const struct iovec __user *payload_iov,
92607 unsigned ioc,
92608 size_t plen,
92609 key_serial_t ringid)
92610 @@ -1103,7 +1103,7 @@ long keyctl_instantiate_key(key_serial_t id,
92611 [0].iov_len = plen
92612 };
92613
92614 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
92615 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
92616 }
92617
92618 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
92619 @@ -1136,7 +1136,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
92620 if (ret == 0)
92621 goto no_payload_free;
92622
92623 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
92624 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
92625 err:
92626 if (iov != iovstack)
92627 kfree(iov);
92628 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
92629 index 6ece7f2..ecdb55c 100644
92630 --- a/security/keys/keyring.c
92631 +++ b/security/keys/keyring.c
92632 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
92633 ret = -EFAULT;
92634
92635 for (loop = 0; loop < klist->nkeys; loop++) {
92636 + key_serial_t serial;
92637 key = rcu_deref_link_locked(klist, loop,
92638 keyring);
92639 + serial = key->serial;
92640
92641 tmp = sizeof(key_serial_t);
92642 if (tmp > buflen)
92643 tmp = buflen;
92644
92645 - if (copy_to_user(buffer,
92646 - &key->serial,
92647 - tmp) != 0)
92648 + if (copy_to_user(buffer, &serial, tmp))
92649 goto error;
92650
92651 buflen -= tmp;
92652 diff --git a/security/min_addr.c b/security/min_addr.c
92653 index f728728..6457a0c 100644
92654 --- a/security/min_addr.c
92655 +++ b/security/min_addr.c
92656 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
92657 */
92658 static void update_mmap_min_addr(void)
92659 {
92660 +#ifndef SPARC
92661 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
92662 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
92663 mmap_min_addr = dac_mmap_min_addr;
92664 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
92665 #else
92666 mmap_min_addr = dac_mmap_min_addr;
92667 #endif
92668 +#endif
92669 }
92670
92671 /*
92672 diff --git a/security/security.c b/security/security.c
92673 index 7b88c6a..1e3ea8f 100644
92674 --- a/security/security.c
92675 +++ b/security/security.c
92676 @@ -20,6 +20,7 @@
92677 #include <linux/ima.h>
92678 #include <linux/evm.h>
92679 #include <linux/fsnotify.h>
92680 +#include <linux/mm.h>
92681 #include <linux/mman.h>
92682 #include <linux/mount.h>
92683 #include <linux/personality.h>
92684 @@ -32,8 +33,8 @@
92685 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
92686 CONFIG_DEFAULT_SECURITY;
92687
92688 -static struct security_operations *security_ops;
92689 -static struct security_operations default_security_ops = {
92690 +static struct security_operations *security_ops __read_only;
92691 +static struct security_operations default_security_ops __read_only = {
92692 .name = "default",
92693 };
92694
92695 @@ -74,7 +75,9 @@ int __init security_init(void)
92696
92697 void reset_security_ops(void)
92698 {
92699 + pax_open_kernel();
92700 security_ops = &default_security_ops;
92701 + pax_close_kernel();
92702 }
92703
92704 /* Save user chosen LSM */
92705 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
92706 index ef26e96..642fb78 100644
92707 --- a/security/selinux/hooks.c
92708 +++ b/security/selinux/hooks.c
92709 @@ -95,8 +95,6 @@
92710
92711 #define NUM_SEL_MNT_OPTS 5
92712
92713 -extern struct security_operations *security_ops;
92714 -
92715 /* SECMARK reference count */
92716 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
92717
92718 @@ -5501,7 +5499,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
92719
92720 #endif
92721
92722 -static struct security_operations selinux_ops = {
92723 +static struct security_operations selinux_ops __read_only = {
92724 .name = "selinux",
92725
92726 .ptrace_access_check = selinux_ptrace_access_check,
92727 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
92728 index 65f67cb..3f141ef 100644
92729 --- a/security/selinux/include/xfrm.h
92730 +++ b/security/selinux/include/xfrm.h
92731 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
92732
92733 static inline void selinux_xfrm_notify_policyload(void)
92734 {
92735 - atomic_inc(&flow_cache_genid);
92736 + atomic_inc_unchecked(&flow_cache_genid);
92737 rt_genid_bump(&init_net);
92738 }
92739 #else
92740 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
92741 index 38be92c..21f49ee 100644
92742 --- a/security/smack/smack_lsm.c
92743 +++ b/security/smack/smack_lsm.c
92744 @@ -3398,7 +3398,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
92745 return 0;
92746 }
92747
92748 -struct security_operations smack_ops = {
92749 +struct security_operations smack_ops __read_only = {
92750 .name = "smack",
92751
92752 .ptrace_access_check = smack_ptrace_access_check,
92753 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
92754 index 390c646..f2f8db3 100644
92755 --- a/security/tomoyo/mount.c
92756 +++ b/security/tomoyo/mount.c
92757 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
92758 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
92759 need_dev = -1; /* dev_name is a directory */
92760 } else {
92761 + if (!capable(CAP_SYS_ADMIN)) {
92762 + error = -EPERM;
92763 + goto out;
92764 + }
92765 fstype = get_fs_type(type);
92766 if (!fstype) {
92767 error = -ENODEV;
92768 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
92769 index a2ee362..5754f34 100644
92770 --- a/security/tomoyo/tomoyo.c
92771 +++ b/security/tomoyo/tomoyo.c
92772 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
92773 * tomoyo_security_ops is a "struct security_operations" which is used for
92774 * registering TOMOYO.
92775 */
92776 -static struct security_operations tomoyo_security_ops = {
92777 +static struct security_operations tomoyo_security_ops __read_only = {
92778 .name = "tomoyo",
92779 .cred_alloc_blank = tomoyo_cred_alloc_blank,
92780 .cred_prepare = tomoyo_cred_prepare,
92781 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
92782 index 20ef514..4182bed 100644
92783 --- a/security/yama/Kconfig
92784 +++ b/security/yama/Kconfig
92785 @@ -1,6 +1,6 @@
92786 config SECURITY_YAMA
92787 bool "Yama support"
92788 - depends on SECURITY
92789 + depends on SECURITY && !GRKERNSEC
92790 select SECURITYFS
92791 select SECURITY_PATH
92792 default n
92793 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
92794 index 23414b9..f8c115e 100644
92795 --- a/security/yama/yama_lsm.c
92796 +++ b/security/yama/yama_lsm.c
92797 @@ -347,10 +347,8 @@ int yama_ptrace_traceme(struct task_struct *parent)
92798 /* Only disallow PTRACE_TRACEME on more aggressive settings. */
92799 switch (ptrace_scope) {
92800 case YAMA_SCOPE_CAPABILITY:
92801 - rcu_read_lock();
92802 - if (!ns_capable(__task_cred(parent)->user_ns, CAP_SYS_PTRACE))
92803 + if (!has_ns_capability(parent, current_user_ns(), CAP_SYS_PTRACE))
92804 rc = -EPERM;
92805 - rcu_read_unlock();
92806 break;
92807 case YAMA_SCOPE_NO_ATTACH:
92808 rc = -EPERM;
92809 @@ -367,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
92810 }
92811
92812 #ifndef CONFIG_SECURITY_YAMA_STACKED
92813 -static struct security_operations yama_ops = {
92814 +static struct security_operations yama_ops __read_only = {
92815 .name = "yama",
92816
92817 .ptrace_access_check = yama_ptrace_access_check,
92818 @@ -378,28 +376,24 @@ static struct security_operations yama_ops = {
92819 #endif
92820
92821 #ifdef CONFIG_SYSCTL
92822 +static int zero __read_only;
92823 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
92824 +
92825 static int yama_dointvec_minmax(struct ctl_table *table, int write,
92826 void __user *buffer, size_t *lenp, loff_t *ppos)
92827 {
92828 - int rc;
92829 + ctl_table_no_const yama_table;
92830
92831 if (write && !capable(CAP_SYS_PTRACE))
92832 return -EPERM;
92833
92834 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
92835 - if (rc)
92836 - return rc;
92837 -
92838 + yama_table = *table;
92839 /* Lock the max value if it ever gets set. */
92840 - if (write && *(int *)table->data == *(int *)table->extra2)
92841 - table->extra1 = table->extra2;
92842 -
92843 - return rc;
92844 + if (ptrace_scope == max_scope)
92845 + yama_table.extra1 = &max_scope;
92846 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
92847 }
92848
92849 -static int zero;
92850 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
92851 -
92852 struct ctl_path yama_sysctl_path[] = {
92853 { .procname = "kernel", },
92854 { .procname = "yama", },
92855 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
92856 index 4cedc69..e59d8a3 100644
92857 --- a/sound/aoa/codecs/onyx.c
92858 +++ b/sound/aoa/codecs/onyx.c
92859 @@ -54,7 +54,7 @@ struct onyx {
92860 spdif_locked:1,
92861 analog_locked:1,
92862 original_mute:2;
92863 - int open_count;
92864 + local_t open_count;
92865 struct codec_info *codec_info;
92866
92867 /* mutex serializes concurrent access to the device
92868 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
92869 struct onyx *onyx = cii->codec_data;
92870
92871 mutex_lock(&onyx->mutex);
92872 - onyx->open_count++;
92873 + local_inc(&onyx->open_count);
92874 mutex_unlock(&onyx->mutex);
92875
92876 return 0;
92877 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
92878 struct onyx *onyx = cii->codec_data;
92879
92880 mutex_lock(&onyx->mutex);
92881 - onyx->open_count--;
92882 - if (!onyx->open_count)
92883 + if (local_dec_and_test(&onyx->open_count))
92884 onyx->spdif_locked = onyx->analog_locked = 0;
92885 mutex_unlock(&onyx->mutex);
92886
92887 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
92888 index ffd2025..df062c9 100644
92889 --- a/sound/aoa/codecs/onyx.h
92890 +++ b/sound/aoa/codecs/onyx.h
92891 @@ -11,6 +11,7 @@
92892 #include <linux/i2c.h>
92893 #include <asm/pmac_low_i2c.h>
92894 #include <asm/prom.h>
92895 +#include <asm/local.h>
92896
92897 /* PCM3052 register definitions */
92898
92899 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
92900 index 4c1cc51..16040040 100644
92901 --- a/sound/core/oss/pcm_oss.c
92902 +++ b/sound/core/oss/pcm_oss.c
92903 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
92904 if (in_kernel) {
92905 mm_segment_t fs;
92906 fs = snd_enter_user();
92907 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92908 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92909 snd_leave_user(fs);
92910 } else {
92911 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
92912 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
92913 }
92914 if (ret != -EPIPE && ret != -ESTRPIPE)
92915 break;
92916 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
92917 if (in_kernel) {
92918 mm_segment_t fs;
92919 fs = snd_enter_user();
92920 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92921 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92922 snd_leave_user(fs);
92923 } else {
92924 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
92925 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
92926 }
92927 if (ret == -EPIPE) {
92928 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
92929 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
92930 struct snd_pcm_plugin_channel *channels;
92931 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
92932 if (!in_kernel) {
92933 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
92934 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
92935 return -EFAULT;
92936 buf = runtime->oss.buffer;
92937 }
92938 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
92939 }
92940 } else {
92941 tmp = snd_pcm_oss_write2(substream,
92942 - (const char __force *)buf,
92943 + (const char __force_kernel *)buf,
92944 runtime->oss.period_bytes, 0);
92945 if (tmp <= 0)
92946 goto err;
92947 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
92948 struct snd_pcm_runtime *runtime = substream->runtime;
92949 snd_pcm_sframes_t frames, frames1;
92950 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
92951 - char __user *final_dst = (char __force __user *)buf;
92952 + char __user *final_dst = (char __force_user *)buf;
92953 if (runtime->oss.plugin_first) {
92954 struct snd_pcm_plugin_channel *channels;
92955 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
92956 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
92957 xfer += tmp;
92958 runtime->oss.buffer_used -= tmp;
92959 } else {
92960 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
92961 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
92962 runtime->oss.period_bytes, 0);
92963 if (tmp <= 0)
92964 goto err;
92965 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
92966 size1);
92967 size1 /= runtime->channels; /* frames */
92968 fs = snd_enter_user();
92969 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
92970 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
92971 snd_leave_user(fs);
92972 }
92973 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
92974 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
92975 index af49721..e85058e 100644
92976 --- a/sound/core/pcm_compat.c
92977 +++ b/sound/core/pcm_compat.c
92978 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
92979 int err;
92980
92981 fs = snd_enter_user();
92982 - err = snd_pcm_delay(substream, &delay);
92983 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
92984 snd_leave_user(fs);
92985 if (err < 0)
92986 return err;
92987 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
92988 index 09b4286..8620fac 100644
92989 --- a/sound/core/pcm_native.c
92990 +++ b/sound/core/pcm_native.c
92991 @@ -2806,11 +2806,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
92992 switch (substream->stream) {
92993 case SNDRV_PCM_STREAM_PLAYBACK:
92994 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
92995 - (void __user *)arg);
92996 + (void __force_user *)arg);
92997 break;
92998 case SNDRV_PCM_STREAM_CAPTURE:
92999 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93000 - (void __user *)arg);
93001 + (void __force_user *)arg);
93002 break;
93003 default:
93004 result = -EINVAL;
93005 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93006 index 040c60e..989a19a 100644
93007 --- a/sound/core/seq/seq_device.c
93008 +++ b/sound/core/seq/seq_device.c
93009 @@ -64,7 +64,7 @@ struct ops_list {
93010 int argsize; /* argument size */
93011
93012 /* operators */
93013 - struct snd_seq_dev_ops ops;
93014 + struct snd_seq_dev_ops *ops;
93015
93016 /* registered devices */
93017 struct list_head dev_list; /* list of devices */
93018 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93019
93020 mutex_lock(&ops->reg_mutex);
93021 /* copy driver operators */
93022 - ops->ops = *entry;
93023 + ops->ops = entry;
93024 ops->driver |= DRIVER_LOADED;
93025 ops->argsize = argsize;
93026
93027 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93028 dev->name, ops->id, ops->argsize, dev->argsize);
93029 return -EINVAL;
93030 }
93031 - if (ops->ops.init_device(dev) >= 0) {
93032 + if (ops->ops->init_device(dev) >= 0) {
93033 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93034 ops->num_init_devices++;
93035 } else {
93036 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93037 dev->name, ops->id, ops->argsize, dev->argsize);
93038 return -EINVAL;
93039 }
93040 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93041 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93042 dev->status = SNDRV_SEQ_DEVICE_FREE;
93043 dev->driver_data = NULL;
93044 ops->num_init_devices--;
93045 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93046 index 4e0dd22..7a1f32c 100644
93047 --- a/sound/drivers/mts64.c
93048 +++ b/sound/drivers/mts64.c
93049 @@ -29,6 +29,7 @@
93050 #include <sound/initval.h>
93051 #include <sound/rawmidi.h>
93052 #include <sound/control.h>
93053 +#include <asm/local.h>
93054
93055 #define CARD_NAME "Miditerminal 4140"
93056 #define DRIVER_NAME "MTS64"
93057 @@ -67,7 +68,7 @@ struct mts64 {
93058 struct pardevice *pardev;
93059 int pardev_claimed;
93060
93061 - int open_count;
93062 + local_t open_count;
93063 int current_midi_output_port;
93064 int current_midi_input_port;
93065 u8 mode[MTS64_NUM_INPUT_PORTS];
93066 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93067 {
93068 struct mts64 *mts = substream->rmidi->private_data;
93069
93070 - if (mts->open_count == 0) {
93071 + if (local_read(&mts->open_count) == 0) {
93072 /* We don't need a spinlock here, because this is just called
93073 if the device has not been opened before.
93074 So there aren't any IRQs from the device */
93075 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93076
93077 msleep(50);
93078 }
93079 - ++(mts->open_count);
93080 + local_inc(&mts->open_count);
93081
93082 return 0;
93083 }
93084 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93085 struct mts64 *mts = substream->rmidi->private_data;
93086 unsigned long flags;
93087
93088 - --(mts->open_count);
93089 - if (mts->open_count == 0) {
93090 + if (local_dec_return(&mts->open_count) == 0) {
93091 /* We need the spinlock_irqsave here because we can still
93092 have IRQs at this point */
93093 spin_lock_irqsave(&mts->lock, flags);
93094 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93095
93096 msleep(500);
93097
93098 - } else if (mts->open_count < 0)
93099 - mts->open_count = 0;
93100 + } else if (local_read(&mts->open_count) < 0)
93101 + local_set(&mts->open_count, 0);
93102
93103 return 0;
93104 }
93105 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93106 index b953fb4..1999c01 100644
93107 --- a/sound/drivers/opl4/opl4_lib.c
93108 +++ b/sound/drivers/opl4/opl4_lib.c
93109 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93110 MODULE_DESCRIPTION("OPL4 driver");
93111 MODULE_LICENSE("GPL");
93112
93113 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93114 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93115 {
93116 int timeout = 10;
93117 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93118 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93119 index 991018d..8984740 100644
93120 --- a/sound/drivers/portman2x4.c
93121 +++ b/sound/drivers/portman2x4.c
93122 @@ -48,6 +48,7 @@
93123 #include <sound/initval.h>
93124 #include <sound/rawmidi.h>
93125 #include <sound/control.h>
93126 +#include <asm/local.h>
93127
93128 #define CARD_NAME "Portman 2x4"
93129 #define DRIVER_NAME "portman"
93130 @@ -85,7 +86,7 @@ struct portman {
93131 struct pardevice *pardev;
93132 int pardev_claimed;
93133
93134 - int open_count;
93135 + local_t open_count;
93136 int mode[PORTMAN_NUM_INPUT_PORTS];
93137 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93138 };
93139 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93140 index ea995af..f1bfa37 100644
93141 --- a/sound/firewire/amdtp.c
93142 +++ b/sound/firewire/amdtp.c
93143 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93144 ptr = s->pcm_buffer_pointer + data_blocks;
93145 if (ptr >= pcm->runtime->buffer_size)
93146 ptr -= pcm->runtime->buffer_size;
93147 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93148 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93149
93150 s->pcm_period_pointer += data_blocks;
93151 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93152 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93153 */
93154 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93155 {
93156 - ACCESS_ONCE(s->source_node_id_field) =
93157 + ACCESS_ONCE_RW(s->source_node_id_field) =
93158 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93159 }
93160 EXPORT_SYMBOL(amdtp_out_stream_update);
93161 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93162 index b680c5e..061b7a0 100644
93163 --- a/sound/firewire/amdtp.h
93164 +++ b/sound/firewire/amdtp.h
93165 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93166 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93167 struct snd_pcm_substream *pcm)
93168 {
93169 - ACCESS_ONCE(s->pcm) = pcm;
93170 + ACCESS_ONCE_RW(s->pcm) = pcm;
93171 }
93172
93173 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93174 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93175 index d428ffe..751ef78 100644
93176 --- a/sound/firewire/isight.c
93177 +++ b/sound/firewire/isight.c
93178 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93179 ptr += count;
93180 if (ptr >= runtime->buffer_size)
93181 ptr -= runtime->buffer_size;
93182 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93183 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93184
93185 isight->period_counter += count;
93186 if (isight->period_counter >= runtime->period_size) {
93187 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93188 if (err < 0)
93189 return err;
93190
93191 - ACCESS_ONCE(isight->pcm_active) = true;
93192 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93193
93194 return 0;
93195 }
93196 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93197 {
93198 struct isight *isight = substream->private_data;
93199
93200 - ACCESS_ONCE(isight->pcm_active) = false;
93201 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93202
93203 mutex_lock(&isight->mutex);
93204 isight_stop_streaming(isight);
93205 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93206
93207 switch (cmd) {
93208 case SNDRV_PCM_TRIGGER_START:
93209 - ACCESS_ONCE(isight->pcm_running) = true;
93210 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93211 break;
93212 case SNDRV_PCM_TRIGGER_STOP:
93213 - ACCESS_ONCE(isight->pcm_running) = false;
93214 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93215 break;
93216 default:
93217 return -EINVAL;
93218 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93219 index 844a555..985ab83 100644
93220 --- a/sound/firewire/scs1x.c
93221 +++ b/sound/firewire/scs1x.c
93222 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93223 {
93224 struct scs *scs = stream->rmidi->private_data;
93225
93226 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93227 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93228 if (up) {
93229 scs->output_idle = false;
93230 tasklet_schedule(&scs->tasklet);
93231 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93232 {
93233 struct scs *scs = stream->rmidi->private_data;
93234
93235 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93236 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93237 }
93238
93239 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93240 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93241
93242 snd_card_disconnect(scs->card);
93243
93244 - ACCESS_ONCE(scs->output) = NULL;
93245 - ACCESS_ONCE(scs->input) = NULL;
93246 + ACCESS_ONCE_RW(scs->output) = NULL;
93247 + ACCESS_ONCE_RW(scs->input) = NULL;
93248
93249 wait_event(scs->idle_wait, scs->output_idle);
93250
93251 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93252 index 048439a..3be9f6f 100644
93253 --- a/sound/oss/sb_audio.c
93254 +++ b/sound/oss/sb_audio.c
93255 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93256 buf16 = (signed short *)(localbuf + localoffs);
93257 while (c)
93258 {
93259 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93260 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93261 if (copy_from_user(lbuf8,
93262 userbuf+useroffs + p,
93263 locallen))
93264 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93265 index 7d8803a..559f8d0 100644
93266 --- a/sound/oss/swarm_cs4297a.c
93267 +++ b/sound/oss/swarm_cs4297a.c
93268 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93269 {
93270 struct cs4297a_state *s;
93271 u32 pwr, id;
93272 - mm_segment_t fs;
93273 int rval;
93274 #ifndef CONFIG_BCM_CS4297A_CSWARM
93275 u64 cfg;
93276 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93277 if (!rval) {
93278 char *sb1250_duart_present;
93279
93280 +#if 0
93281 + mm_segment_t fs;
93282 fs = get_fs();
93283 set_fs(KERNEL_DS);
93284 -#if 0
93285 val = SOUND_MASK_LINE;
93286 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93287 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93288 val = initvol[i].vol;
93289 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93290 }
93291 + set_fs(fs);
93292 // cs4297a_write_ac97(s, 0x18, 0x0808);
93293 #else
93294 // cs4297a_write_ac97(s, 0x5e, 0x180);
93295 cs4297a_write_ac97(s, 0x02, 0x0808);
93296 cs4297a_write_ac97(s, 0x18, 0x0808);
93297 #endif
93298 - set_fs(fs);
93299
93300 list_add(&s->list, &cs4297a_devs);
93301
93302 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93303 index 4631a23..001ae57 100644
93304 --- a/sound/pci/ymfpci/ymfpci.h
93305 +++ b/sound/pci/ymfpci/ymfpci.h
93306 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93307 spinlock_t reg_lock;
93308 spinlock_t voice_lock;
93309 wait_queue_head_t interrupt_sleep;
93310 - atomic_t interrupt_sleep_count;
93311 + atomic_unchecked_t interrupt_sleep_count;
93312 struct snd_info_entry *proc_entry;
93313 const struct firmware *dsp_microcode;
93314 const struct firmware *controller_microcode;
93315 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93316 index 22056c5..25d3244 100644
93317 --- a/sound/pci/ymfpci/ymfpci_main.c
93318 +++ b/sound/pci/ymfpci/ymfpci_main.c
93319 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93320 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93321 break;
93322 }
93323 - if (atomic_read(&chip->interrupt_sleep_count)) {
93324 - atomic_set(&chip->interrupt_sleep_count, 0);
93325 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93326 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93327 wake_up(&chip->interrupt_sleep);
93328 }
93329 __end:
93330 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93331 continue;
93332 init_waitqueue_entry(&wait, current);
93333 add_wait_queue(&chip->interrupt_sleep, &wait);
93334 - atomic_inc(&chip->interrupt_sleep_count);
93335 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93336 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93337 remove_wait_queue(&chip->interrupt_sleep, &wait);
93338 }
93339 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93340 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93341 spin_unlock(&chip->reg_lock);
93342
93343 - if (atomic_read(&chip->interrupt_sleep_count)) {
93344 - atomic_set(&chip->interrupt_sleep_count, 0);
93345 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93346 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93347 wake_up(&chip->interrupt_sleep);
93348 }
93349 }
93350 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93351 spin_lock_init(&chip->reg_lock);
93352 spin_lock_init(&chip->voice_lock);
93353 init_waitqueue_head(&chip->interrupt_sleep);
93354 - atomic_set(&chip->interrupt_sleep_count, 0);
93355 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93356 chip->card = card;
93357 chip->pci = pci;
93358 chip->irq = -1;
93359 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93360 new file mode 100644
93361 index 0000000..50f2f2f
93362 --- /dev/null
93363 +++ b/tools/gcc/.gitignore
93364 @@ -0,0 +1 @@
93365 +size_overflow_hash.h
93366 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93367 new file mode 100644
93368 index 0000000..144dbee
93369 --- /dev/null
93370 +++ b/tools/gcc/Makefile
93371 @@ -0,0 +1,45 @@
93372 +#CC := gcc
93373 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93374 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93375 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93376 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93377 +
93378 +ifeq ($(PLUGINCC),$(HOSTCC))
93379 +HOSTLIBS := hostlibs
93380 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93381 +else
93382 +HOSTLIBS := hostcxxlibs
93383 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93384 +endif
93385 +
93386 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93387 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93388 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93389 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93390 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93391 +$(HOSTLIBS)-y += colorize_plugin.so
93392 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93393 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93394 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93395 +
93396 +always := $($(HOSTLIBS)-y)
93397 +
93398 +constify_plugin-objs := constify_plugin.o
93399 +stackleak_plugin-objs := stackleak_plugin.o
93400 +kallocstat_plugin-objs := kallocstat_plugin.o
93401 +kernexec_plugin-objs := kernexec_plugin.o
93402 +checker_plugin-objs := checker_plugin.o
93403 +colorize_plugin-objs := colorize_plugin.o
93404 +size_overflow_plugin-objs := size_overflow_plugin.o
93405 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93406 +structleak_plugin-objs := structleak_plugin.o
93407 +
93408 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93409 +
93410 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93411 + cmd_build_size_overflow_hash = \
93412 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93413 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93414 + $(call if_changed,build_size_overflow_hash)
93415 +
93416 +targets += size_overflow_hash.h
93417 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
93418 new file mode 100644
93419 index 0000000..d41b5af
93420 --- /dev/null
93421 +++ b/tools/gcc/checker_plugin.c
93422 @@ -0,0 +1,171 @@
93423 +/*
93424 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
93425 + * Licensed under the GPL v2
93426 + *
93427 + * Note: the choice of the license means that the compilation process is
93428 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93429 + * but for the kernel it doesn't matter since it doesn't link against
93430 + * any of the gcc libraries
93431 + *
93432 + * gcc plugin to implement various sparse (source code checker) features
93433 + *
93434 + * TODO:
93435 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
93436 + *
93437 + * BUGS:
93438 + * - none known
93439 + */
93440 +#include "gcc-plugin.h"
93441 +#include "config.h"
93442 +#include "system.h"
93443 +#include "coretypes.h"
93444 +#include "tree.h"
93445 +#include "tree-pass.h"
93446 +#include "flags.h"
93447 +#include "intl.h"
93448 +#include "toplev.h"
93449 +#include "plugin.h"
93450 +//#include "expr.h" where are you...
93451 +#include "diagnostic.h"
93452 +#include "plugin-version.h"
93453 +#include "tm.h"
93454 +#include "function.h"
93455 +#include "basic-block.h"
93456 +#include "gimple.h"
93457 +#include "rtl.h"
93458 +#include "emit-rtl.h"
93459 +#include "tree-flow.h"
93460 +#include "target.h"
93461 +
93462 +extern void c_register_addr_space (const char *str, addr_space_t as);
93463 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
93464 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
93465 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
93466 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
93467 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
93468 +
93469 +extern void print_gimple_stmt(FILE *, gimple, int, int);
93470 +extern rtx emit_move_insn(rtx x, rtx y);
93471 +
93472 +int plugin_is_GPL_compatible;
93473 +
93474 +static struct plugin_info checker_plugin_info = {
93475 + .version = "201111150100",
93476 +};
93477 +
93478 +#define ADDR_SPACE_KERNEL 0
93479 +#define ADDR_SPACE_FORCE_KERNEL 1
93480 +#define ADDR_SPACE_USER 2
93481 +#define ADDR_SPACE_FORCE_USER 3
93482 +#define ADDR_SPACE_IOMEM 0
93483 +#define ADDR_SPACE_FORCE_IOMEM 0
93484 +#define ADDR_SPACE_PERCPU 0
93485 +#define ADDR_SPACE_FORCE_PERCPU 0
93486 +#define ADDR_SPACE_RCU 0
93487 +#define ADDR_SPACE_FORCE_RCU 0
93488 +
93489 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
93490 +{
93491 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
93492 +}
93493 +
93494 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
93495 +{
93496 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
93497 +}
93498 +
93499 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
93500 +{
93501 + return default_addr_space_valid_pointer_mode(mode, as);
93502 +}
93503 +
93504 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
93505 +{
93506 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
93507 +}
93508 +
93509 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
93510 +{
93511 + return default_addr_space_legitimize_address(x, oldx, mode, as);
93512 +}
93513 +
93514 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
93515 +{
93516 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
93517 + return true;
93518 +
93519 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
93520 + return true;
93521 +
93522 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
93523 + return true;
93524 +
93525 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
93526 + return true;
93527 +
93528 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
93529 + return true;
93530 +
93531 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
93532 + return true;
93533 +
93534 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
93535 + return true;
93536 +
93537 + return subset == superset;
93538 +}
93539 +
93540 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
93541 +{
93542 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
93543 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
93544 +
93545 + return op;
93546 +}
93547 +
93548 +static void register_checker_address_spaces(void *event_data, void *data)
93549 +{
93550 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
93551 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
93552 + c_register_addr_space("__user", ADDR_SPACE_USER);
93553 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
93554 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
93555 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
93556 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
93557 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
93558 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
93559 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
93560 +
93561 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
93562 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
93563 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
93564 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
93565 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
93566 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
93567 + targetm.addr_space.convert = checker_addr_space_convert;
93568 +}
93569 +
93570 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93571 +{
93572 + const char * const plugin_name = plugin_info->base_name;
93573 + const int argc = plugin_info->argc;
93574 + const struct plugin_argument * const argv = plugin_info->argv;
93575 + int i;
93576 +
93577 + if (!plugin_default_version_check(version, &gcc_version)) {
93578 + error(G_("incompatible gcc/plugin versions"));
93579 + return 1;
93580 + }
93581 +
93582 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
93583 +
93584 + for (i = 0; i < argc; ++i)
93585 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
93586 +
93587 + if (TARGET_64BIT == 0)
93588 + return 0;
93589 +
93590 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
93591 +
93592 + return 0;
93593 +}
93594 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
93595 new file mode 100644
93596 index 0000000..414fe5e
93597 --- /dev/null
93598 +++ b/tools/gcc/colorize_plugin.c
93599 @@ -0,0 +1,151 @@
93600 +/*
93601 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
93602 + * Licensed under the GPL v2
93603 + *
93604 + * Note: the choice of the license means that the compilation process is
93605 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
93606 + * but for the kernel it doesn't matter since it doesn't link against
93607 + * any of the gcc libraries
93608 + *
93609 + * gcc plugin to colorize diagnostic output
93610 + *
93611 + */
93612 +
93613 +#include "gcc-plugin.h"
93614 +#include "config.h"
93615 +#include "system.h"
93616 +#include "coretypes.h"
93617 +#include "tree.h"
93618 +#include "tree-pass.h"
93619 +#include "flags.h"
93620 +#include "intl.h"
93621 +#include "toplev.h"
93622 +#include "plugin.h"
93623 +#include "diagnostic.h"
93624 +#include "plugin-version.h"
93625 +#include "tm.h"
93626 +
93627 +int plugin_is_GPL_compatible;
93628 +
93629 +static struct plugin_info colorize_plugin_info = {
93630 + .version = "201302112000",
93631 + .help = NULL,
93632 +};
93633 +
93634 +#define GREEN "\033[32m\033[2m"
93635 +#define LIGHTGREEN "\033[32m\033[1m"
93636 +#define YELLOW "\033[33m\033[2m"
93637 +#define LIGHTYELLOW "\033[33m\033[1m"
93638 +#define RED "\033[31m\033[2m"
93639 +#define LIGHTRED "\033[31m\033[1m"
93640 +#define BLUE "\033[34m\033[2m"
93641 +#define LIGHTBLUE "\033[34m\033[1m"
93642 +#define BRIGHT "\033[m\033[1m"
93643 +#define NORMAL "\033[m"
93644 +
93645 +static diagnostic_starter_fn old_starter;
93646 +static diagnostic_finalizer_fn old_finalizer;
93647 +
93648 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93649 +{
93650 + const char *color;
93651 + char *newprefix;
93652 +
93653 + switch (diagnostic->kind) {
93654 + case DK_NOTE:
93655 + color = LIGHTBLUE;
93656 + break;
93657 +
93658 + case DK_PEDWARN:
93659 + case DK_WARNING:
93660 + color = LIGHTYELLOW;
93661 + break;
93662 +
93663 + case DK_ERROR:
93664 + case DK_FATAL:
93665 + case DK_ICE:
93666 + case DK_PERMERROR:
93667 + case DK_SORRY:
93668 + color = LIGHTRED;
93669 + break;
93670 +
93671 + default:
93672 + color = NORMAL;
93673 + }
93674 +
93675 + old_starter(context, diagnostic);
93676 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
93677 + return;
93678 + pp_destroy_prefix(context->printer);
93679 + pp_set_prefix(context->printer, newprefix);
93680 +}
93681 +
93682 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
93683 +{
93684 + old_finalizer(context, diagnostic);
93685 +}
93686 +
93687 +static void colorize_arm(void)
93688 +{
93689 + old_starter = diagnostic_starter(global_dc);
93690 + old_finalizer = diagnostic_finalizer(global_dc);
93691 +
93692 + diagnostic_starter(global_dc) = start_colorize;
93693 + diagnostic_finalizer(global_dc) = finalize_colorize;
93694 +}
93695 +
93696 +static unsigned int execute_colorize_rearm(void)
93697 +{
93698 + if (diagnostic_starter(global_dc) == start_colorize)
93699 + return 0;
93700 +
93701 + colorize_arm();
93702 + return 0;
93703 +}
93704 +
93705 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
93706 + .pass = {
93707 + .type = SIMPLE_IPA_PASS,
93708 + .name = "colorize_rearm",
93709 +#if BUILDING_GCC_VERSION >= 4008
93710 + .optinfo_flags = OPTGROUP_NONE,
93711 +#endif
93712 + .gate = NULL,
93713 + .execute = execute_colorize_rearm,
93714 + .sub = NULL,
93715 + .next = NULL,
93716 + .static_pass_number = 0,
93717 + .tv_id = TV_NONE,
93718 + .properties_required = 0,
93719 + .properties_provided = 0,
93720 + .properties_destroyed = 0,
93721 + .todo_flags_start = 0,
93722 + .todo_flags_finish = 0
93723 + }
93724 +};
93725 +
93726 +static void colorize_start_unit(void *gcc_data, void *user_data)
93727 +{
93728 + colorize_arm();
93729 +}
93730 +
93731 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
93732 +{
93733 + const char * const plugin_name = plugin_info->base_name;
93734 + struct register_pass_info colorize_rearm_pass_info = {
93735 + .pass = &pass_ipa_colorize_rearm.pass,
93736 + .reference_pass_name = "*free_lang_data",
93737 + .ref_pass_instance_number = 1,
93738 + .pos_op = PASS_POS_INSERT_AFTER
93739 + };
93740 +
93741 + if (!plugin_default_version_check(version, &gcc_version)) {
93742 + error(G_("incompatible gcc/plugin versions"));
93743 + return 1;
93744 + }
93745 +
93746 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
93747 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
93748 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
93749 + return 0;
93750 +}
93751 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
93752 new file mode 100644
93753 index 0000000..bee0acb
93754 --- /dev/null
93755 +++ b/tools/gcc/constify_plugin.c
93756 @@ -0,0 +1,518 @@
93757 +/*
93758 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
93759 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
93760 + * Licensed under the GPL v2, or (at your option) v3
93761 + *
93762 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
93763 + *
93764 + * Homepage:
93765 + * http://www.grsecurity.net/~ephox/const_plugin/
93766 + *
93767 + * Usage:
93768 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
93769 + * $ gcc -fplugin=constify_plugin.so test.c -O2
93770 + */
93771 +
93772 +#include "gcc-plugin.h"
93773 +#include "config.h"
93774 +#include "system.h"
93775 +#include "coretypes.h"
93776 +#include "tree.h"
93777 +#include "tree-pass.h"
93778 +#include "flags.h"
93779 +#include "intl.h"
93780 +#include "toplev.h"
93781 +#include "plugin.h"
93782 +#include "diagnostic.h"
93783 +#include "plugin-version.h"
93784 +#include "tm.h"
93785 +#include "function.h"
93786 +#include "basic-block.h"
93787 +#include "gimple.h"
93788 +#include "rtl.h"
93789 +#include "emit-rtl.h"
93790 +#include "tree-flow.h"
93791 +#include "target.h"
93792 +#include "langhooks.h"
93793 +
93794 +// should come from c-tree.h if only it were installed for gcc 4.5...
93795 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
93796 +
93797 +// unused type flag in all versions 4.5-4.8
93798 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
93799 +
93800 +int plugin_is_GPL_compatible;
93801 +
93802 +static struct plugin_info const_plugin_info = {
93803 + .version = "201303270300",
93804 + .help = "no-constify\tturn off constification\n",
93805 +};
93806 +
93807 +typedef struct {
93808 + bool has_fptr_field;
93809 + bool has_writable_field;
93810 + bool has_do_const_field;
93811 + bool has_no_const_field;
93812 +} constify_info;
93813 +
93814 +static const_tree get_field_type(const_tree field)
93815 +{
93816 + return strip_array_types(TREE_TYPE(field));
93817 +}
93818 +
93819 +static bool is_fptr(const_tree field)
93820 +{
93821 + const_tree ptr = get_field_type(field);
93822 +
93823 + if (TREE_CODE(ptr) != POINTER_TYPE)
93824 + return false;
93825 +
93826 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
93827 +}
93828 +
93829 +/*
93830 + * determine whether the given structure type meets the requirements for automatic constification,
93831 + * including the constification attributes on nested structure types
93832 + */
93833 +static void constifiable(const_tree node, constify_info *cinfo)
93834 +{
93835 + const_tree field;
93836 +
93837 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93838 +
93839 + // e.g., pointer to structure fields while still constructing the structure type
93840 + if (TYPE_FIELDS(node) == NULL_TREE)
93841 + return;
93842 +
93843 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
93844 + const_tree type = get_field_type(field);
93845 + enum tree_code code = TREE_CODE(type);
93846 +
93847 + if (node == type)
93848 + continue;
93849 +
93850 + if (is_fptr(field))
93851 + cinfo->has_fptr_field = true;
93852 + else if (!TREE_READONLY(field))
93853 + cinfo->has_writable_field = true;
93854 +
93855 + if (code == RECORD_TYPE || code == UNION_TYPE) {
93856 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93857 + cinfo->has_do_const_field = true;
93858 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
93859 + cinfo->has_no_const_field = true;
93860 + else
93861 + constifiable(type, cinfo);
93862 + }
93863 + }
93864 +}
93865 +
93866 +static bool constified(const_tree node)
93867 +{
93868 + constify_info cinfo = {
93869 + .has_fptr_field = false,
93870 + .has_writable_field = false,
93871 + .has_do_const_field = false,
93872 + .has_no_const_field = false
93873 + };
93874 +
93875 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
93876 +
93877 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
93878 + gcc_assert(!TYPE_READONLY(node));
93879 + return false;
93880 + }
93881 +
93882 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
93883 + gcc_assert(TYPE_READONLY(node));
93884 + return true;
93885 + }
93886 +
93887 + constifiable(node, &cinfo);
93888 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
93889 + return false;
93890 +
93891 + return TYPE_READONLY(node);
93892 +}
93893 +
93894 +static void deconstify_tree(tree node);
93895 +
93896 +static void deconstify_type(tree type)
93897 +{
93898 + tree field;
93899 +
93900 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
93901 +
93902 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
93903 + const_tree fieldtype = get_field_type(field);
93904 +
93905 + // special case handling of simple ptr-to-same-array-type members
93906 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
93907 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
93908 +
93909 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
93910 + continue;
93911 + if (TREE_TYPE(TREE_TYPE(field)) == type)
93912 + continue;
93913 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
93914 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
93915 + TREE_TYPE(TREE_TYPE(field)) = type;
93916 + }
93917 + continue;
93918 + }
93919 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
93920 + continue;
93921 + if (!constified(fieldtype))
93922 + continue;
93923 +
93924 + deconstify_tree(field);
93925 + TREE_READONLY(field) = 0;
93926 + }
93927 + TYPE_READONLY(type) = 0;
93928 + C_TYPE_FIELDS_READONLY(type) = 0;
93929 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
93930 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
93931 +}
93932 +
93933 +static void deconstify_tree(tree node)
93934 +{
93935 + tree old_type, new_type, field;
93936 +
93937 + old_type = TREE_TYPE(node);
93938 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
93939 + node = TREE_TYPE(node) = copy_node(old_type);
93940 + old_type = TREE_TYPE(old_type);
93941 + }
93942 +
93943 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
93944 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
93945 +
93946 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
93947 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
93948 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
93949 + DECL_FIELD_CONTEXT(field) = new_type;
93950 +
93951 + deconstify_type(new_type);
93952 +
93953 + TREE_TYPE(node) = new_type;
93954 +}
93955 +
93956 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
93957 +{
93958 + tree type;
93959 + constify_info cinfo = {
93960 + .has_fptr_field = false,
93961 + .has_writable_field = false,
93962 + .has_do_const_field = false,
93963 + .has_no_const_field = false
93964 + };
93965 +
93966 + *no_add_attrs = true;
93967 + if (TREE_CODE(*node) == FUNCTION_DECL) {
93968 + error("%qE attribute does not apply to functions", name);
93969 + return NULL_TREE;
93970 + }
93971 +
93972 + if (TREE_CODE(*node) == PARM_DECL) {
93973 + error("%qE attribute does not apply to function parameters", name);
93974 + return NULL_TREE;
93975 + }
93976 +
93977 + if (TREE_CODE(*node) == VAR_DECL) {
93978 + error("%qE attribute does not apply to variables", name);
93979 + return NULL_TREE;
93980 + }
93981 +
93982 + if (TYPE_P(*node)) {
93983 + *no_add_attrs = false;
93984 + type = *node;
93985 + } else {
93986 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
93987 + type = TREE_TYPE(*node);
93988 + }
93989 +
93990 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
93991 + error("%qE attribute applies to struct and union types only", name);
93992 + return NULL_TREE;
93993 + }
93994 +
93995 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
93996 + error("%qE attribute is already applied to the type", name);
93997 + return NULL_TREE;
93998 + }
93999 +
94000 + if (TYPE_P(*node)) {
94001 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94002 + error("%qE attribute is incompatible with 'do_const'", name);
94003 + return NULL_TREE;
94004 + }
94005 +
94006 + constifiable(type, &cinfo);
94007 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94008 + deconstify_tree(*node);
94009 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94010 + return NULL_TREE;
94011 + }
94012 +
94013 + error("%qE attribute used on type that is not constified", name);
94014 + return NULL_TREE;
94015 +}
94016 +
94017 +static void constify_type(tree type)
94018 +{
94019 + TYPE_READONLY(type) = 1;
94020 + C_TYPE_FIELDS_READONLY(type) = 1;
94021 + TYPE_CONSTIFY_VISITED(type) = 1;
94022 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94023 +}
94024 +
94025 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94026 +{
94027 + *no_add_attrs = true;
94028 + if (!TYPE_P(*node)) {
94029 + error("%qE attribute applies to types only", name);
94030 + return NULL_TREE;
94031 + }
94032 +
94033 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94034 + error("%qE attribute applies to struct and union types only", name);
94035 + return NULL_TREE;
94036 + }
94037 +
94038 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94039 + error("%qE attribute is already applied to the type", name);
94040 + return NULL_TREE;
94041 + }
94042 +
94043 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94044 + error("%qE attribute is incompatible with 'no_const'", name);
94045 + return NULL_TREE;
94046 + }
94047 +
94048 + *no_add_attrs = false;
94049 + return NULL_TREE;
94050 +}
94051 +
94052 +static struct attribute_spec no_const_attr = {
94053 + .name = "no_const",
94054 + .min_length = 0,
94055 + .max_length = 0,
94056 + .decl_required = false,
94057 + .type_required = false,
94058 + .function_type_required = false,
94059 + .handler = handle_no_const_attribute,
94060 +#if BUILDING_GCC_VERSION >= 4007
94061 + .affects_type_identity = true
94062 +#endif
94063 +};
94064 +
94065 +static struct attribute_spec do_const_attr = {
94066 + .name = "do_const",
94067 + .min_length = 0,
94068 + .max_length = 0,
94069 + .decl_required = false,
94070 + .type_required = false,
94071 + .function_type_required = false,
94072 + .handler = handle_do_const_attribute,
94073 +#if BUILDING_GCC_VERSION >= 4007
94074 + .affects_type_identity = true
94075 +#endif
94076 +};
94077 +
94078 +static void register_attributes(void *event_data, void *data)
94079 +{
94080 + register_attribute(&no_const_attr);
94081 + register_attribute(&do_const_attr);
94082 +}
94083 +
94084 +static void finish_type(void *event_data, void *data)
94085 +{
94086 + tree type = (tree)event_data;
94087 + constify_info cinfo = {
94088 + .has_fptr_field = false,
94089 + .has_writable_field = false,
94090 + .has_do_const_field = false,
94091 + .has_no_const_field = false
94092 + };
94093 +
94094 + if (type == NULL_TREE || type == error_mark_node)
94095 + return;
94096 +
94097 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94098 + return;
94099 +
94100 + constifiable(type, &cinfo);
94101 +
94102 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94103 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94104 + return;
94105 + if (cinfo.has_writable_field)
94106 + return;
94107 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94108 + return;
94109 + }
94110 +
94111 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94112 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94113 + deconstify_type(type);
94114 + TYPE_CONSTIFY_VISITED(type) = 1;
94115 + } else
94116 + error("'no_const' attribute used on type that is not constified");
94117 + return;
94118 + }
94119 +
94120 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94121 + constify_type(type);
94122 + return;
94123 + }
94124 +
94125 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94126 + constify_type(type);
94127 + return;
94128 + }
94129 +
94130 + deconstify_type(type);
94131 + TYPE_CONSTIFY_VISITED(type) = 1;
94132 +}
94133 +
94134 +static unsigned int check_local_variables(void)
94135 +{
94136 + unsigned int ret = 0;
94137 + tree var;
94138 +
94139 +#if BUILDING_GCC_VERSION == 4005
94140 + tree vars;
94141 +#else
94142 + unsigned int i;
94143 +#endif
94144 +
94145 +#if BUILDING_GCC_VERSION == 4005
94146 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94147 + var = TREE_VALUE(vars);
94148 +#else
94149 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94150 +#endif
94151 + tree type = TREE_TYPE(var);
94152 +
94153 + gcc_assert(DECL_P(var));
94154 + if (is_global_var(var))
94155 + continue;
94156 +
94157 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94158 + continue;
94159 +
94160 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94161 + continue;
94162 +
94163 + if (!TYPE_CONSTIFY_VISITED(type))
94164 + continue;
94165 +
94166 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94167 + ret = 1;
94168 + }
94169 + return ret;
94170 +}
94171 +
94172 +static struct gimple_opt_pass pass_local_variable = {
94173 + {
94174 + .type = GIMPLE_PASS,
94175 + .name = "check_local_variables",
94176 +#if BUILDING_GCC_VERSION >= 4008
94177 + .optinfo_flags = OPTGROUP_NONE,
94178 +#endif
94179 + .gate = NULL,
94180 + .execute = check_local_variables,
94181 + .sub = NULL,
94182 + .next = NULL,
94183 + .static_pass_number = 0,
94184 + .tv_id = TV_NONE,
94185 + .properties_required = 0,
94186 + .properties_provided = 0,
94187 + .properties_destroyed = 0,
94188 + .todo_flags_start = 0,
94189 + .todo_flags_finish = 0
94190 + }
94191 +};
94192 +
94193 +static struct {
94194 + const char *name;
94195 + const char *asm_op;
94196 +} sections[] = {
94197 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94198 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94199 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94200 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94201 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94202 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94203 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94204 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94205 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94206 +};
94207 +
94208 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94209 +
94210 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94211 +{
94212 + size_t i;
94213 +
94214 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94215 + if (!strcmp(sections[i].name, name))
94216 + return 0;
94217 + return old_section_type_flags(decl, name, reloc);
94218 +}
94219 +
94220 +static void constify_start_unit(void *gcc_data, void *user_data)
94221 +{
94222 +// size_t i;
94223 +
94224 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94225 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94226 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94227 +
94228 + old_section_type_flags = targetm.section_type_flags;
94229 + targetm.section_type_flags = constify_section_type_flags;
94230 +}
94231 +
94232 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94233 +{
94234 + const char * const plugin_name = plugin_info->base_name;
94235 + const int argc = plugin_info->argc;
94236 + const struct plugin_argument * const argv = plugin_info->argv;
94237 + int i;
94238 + bool constify = true;
94239 +
94240 + struct register_pass_info local_variable_pass_info = {
94241 + .pass = &pass_local_variable.pass,
94242 + .reference_pass_name = "ssa",
94243 + .ref_pass_instance_number = 1,
94244 + .pos_op = PASS_POS_INSERT_BEFORE
94245 + };
94246 +
94247 + if (!plugin_default_version_check(version, &gcc_version)) {
94248 + error(G_("incompatible gcc/plugin versions"));
94249 + return 1;
94250 + }
94251 +
94252 + for (i = 0; i < argc; ++i) {
94253 + if (!(strcmp(argv[i].key, "no-constify"))) {
94254 + constify = false;
94255 + continue;
94256 + }
94257 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94258 + }
94259 +
94260 + if (strcmp(lang_hooks.name, "GNU C")) {
94261 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94262 + constify = false;
94263 + }
94264 +
94265 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94266 + if (constify) {
94267 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94268 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94269 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94270 + }
94271 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94272 +
94273 + return 0;
94274 +}
94275 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94276 new file mode 100644
94277 index 0000000..e518932
94278 --- /dev/null
94279 +++ b/tools/gcc/generate_size_overflow_hash.sh
94280 @@ -0,0 +1,94 @@
94281 +#!/bin/bash
94282 +
94283 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94284 +
94285 +header1="size_overflow_hash.h"
94286 +database="size_overflow_hash.data"
94287 +n=65536
94288 +
94289 +usage() {
94290 +cat <<EOF
94291 +usage: $0 options
94292 +OPTIONS:
94293 + -h|--help help
94294 + -o header file
94295 + -d database file
94296 + -n hash array size
94297 +EOF
94298 + return 0
94299 +}
94300 +
94301 +while true
94302 +do
94303 + case "$1" in
94304 + -h|--help) usage && exit 0;;
94305 + -n) n=$2; shift 2;;
94306 + -o) header1="$2"; shift 2;;
94307 + -d) database="$2"; shift 2;;
94308 + --) shift 1; break ;;
94309 + *) break ;;
94310 + esac
94311 +done
94312 +
94313 +create_defines() {
94314 + for i in `seq 0 31`
94315 + do
94316 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94317 + done
94318 + echo >> "$header1"
94319 +}
94320 +
94321 +create_structs() {
94322 + rm -f "$header1"
94323 +
94324 + create_defines
94325 +
94326 + cat "$database" | while read data
94327 + do
94328 + data_array=($data)
94329 + struct_hash_name="${data_array[0]}"
94330 + funcn="${data_array[1]}"
94331 + params="${data_array[2]}"
94332 + next="${data_array[4]}"
94333 +
94334 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94335 +
94336 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94337 + echo -en "\t.param\t= " >> "$header1"
94338 + line=
94339 + for param_num in ${params//-/ };
94340 + do
94341 + line="${line}PARAM"$param_num"|"
94342 + done
94343 +
94344 + echo -e "${line%?},\n};\n" >> "$header1"
94345 + done
94346 +}
94347 +
94348 +create_headers() {
94349 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94350 +}
94351 +
94352 +create_array_elements() {
94353 + index=0
94354 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94355 + do
94356 + data_array=($data)
94357 + i="${data_array[3]}"
94358 + hash="${data_array[0]}"
94359 + while [[ $index -lt $i ]]
94360 + do
94361 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94362 + index=$(($index + 1))
94363 + done
94364 + index=$(($index + 1))
94365 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94366 + done
94367 + echo '};' >> $header1
94368 +}
94369 +
94370 +create_structs
94371 +create_headers
94372 +create_array_elements
94373 +
94374 +exit 0
94375 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
94376 new file mode 100644
94377 index 0000000..568b360
94378 --- /dev/null
94379 +++ b/tools/gcc/kallocstat_plugin.c
94380 @@ -0,0 +1,170 @@
94381 +/*
94382 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94383 + * Licensed under the GPL v2
94384 + *
94385 + * Note: the choice of the license means that the compilation process is
94386 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94387 + * but for the kernel it doesn't matter since it doesn't link against
94388 + * any of the gcc libraries
94389 + *
94390 + * gcc plugin to find the distribution of k*alloc sizes
94391 + *
94392 + * TODO:
94393 + *
94394 + * BUGS:
94395 + * - none known
94396 + */
94397 +#include "gcc-plugin.h"
94398 +#include "config.h"
94399 +#include "system.h"
94400 +#include "coretypes.h"
94401 +#include "tree.h"
94402 +#include "tree-pass.h"
94403 +#include "flags.h"
94404 +#include "intl.h"
94405 +#include "toplev.h"
94406 +#include "plugin.h"
94407 +//#include "expr.h" where are you...
94408 +#include "diagnostic.h"
94409 +#include "plugin-version.h"
94410 +#include "tm.h"
94411 +#include "function.h"
94412 +#include "basic-block.h"
94413 +#include "gimple.h"
94414 +#include "rtl.h"
94415 +#include "emit-rtl.h"
94416 +
94417 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94418 +
94419 +int plugin_is_GPL_compatible;
94420 +
94421 +static const char * const kalloc_functions[] = {
94422 + "__kmalloc",
94423 + "kmalloc",
94424 + "kmalloc_large",
94425 + "kmalloc_node",
94426 + "kmalloc_order",
94427 + "kmalloc_order_trace",
94428 + "kmalloc_slab",
94429 + "kzalloc",
94430 + "kzalloc_node",
94431 +};
94432 +
94433 +static struct plugin_info kallocstat_plugin_info = {
94434 + .version = "201302112000",
94435 +};
94436 +
94437 +static unsigned int execute_kallocstat(void);
94438 +
94439 +static struct gimple_opt_pass kallocstat_pass = {
94440 + .pass = {
94441 + .type = GIMPLE_PASS,
94442 + .name = "kallocstat",
94443 +#if BUILDING_GCC_VERSION >= 4008
94444 + .optinfo_flags = OPTGROUP_NONE,
94445 +#endif
94446 + .gate = NULL,
94447 + .execute = execute_kallocstat,
94448 + .sub = NULL,
94449 + .next = NULL,
94450 + .static_pass_number = 0,
94451 + .tv_id = TV_NONE,
94452 + .properties_required = 0,
94453 + .properties_provided = 0,
94454 + .properties_destroyed = 0,
94455 + .todo_flags_start = 0,
94456 + .todo_flags_finish = 0
94457 + }
94458 +};
94459 +
94460 +static bool is_kalloc(const char *fnname)
94461 +{
94462 + size_t i;
94463 +
94464 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
94465 + if (!strcmp(fnname, kalloc_functions[i]))
94466 + return true;
94467 + return false;
94468 +}
94469 +
94470 +static unsigned int execute_kallocstat(void)
94471 +{
94472 + basic_block bb;
94473 +
94474 + // 1. loop through BBs and GIMPLE statements
94475 + FOR_EACH_BB(bb) {
94476 + gimple_stmt_iterator gsi;
94477 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94478 + // gimple match:
94479 + tree fndecl, size;
94480 + gimple call_stmt;
94481 + const char *fnname;
94482 +
94483 + // is it a call
94484 + call_stmt = gsi_stmt(gsi);
94485 + if (!is_gimple_call(call_stmt))
94486 + continue;
94487 + fndecl = gimple_call_fndecl(call_stmt);
94488 + if (fndecl == NULL_TREE)
94489 + continue;
94490 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
94491 + continue;
94492 +
94493 + // is it a call to k*alloc
94494 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
94495 + if (!is_kalloc(fnname))
94496 + continue;
94497 +
94498 + // is the size arg the result of a simple const assignment
94499 + size = gimple_call_arg(call_stmt, 0);
94500 + while (true) {
94501 + gimple def_stmt;
94502 + expanded_location xloc;
94503 + size_t size_val;
94504 +
94505 + if (TREE_CODE(size) != SSA_NAME)
94506 + break;
94507 + def_stmt = SSA_NAME_DEF_STMT(size);
94508 + if (!def_stmt || !is_gimple_assign(def_stmt))
94509 + break;
94510 + if (gimple_num_ops(def_stmt) != 2)
94511 + break;
94512 + size = gimple_assign_rhs1(def_stmt);
94513 + if (!TREE_CONSTANT(size))
94514 + continue;
94515 + xloc = expand_location(gimple_location(def_stmt));
94516 + if (!xloc.file)
94517 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
94518 + size_val = TREE_INT_CST_LOW(size);
94519 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
94520 + break;
94521 + }
94522 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94523 +//debug_tree(gimple_call_fn(call_stmt));
94524 +//print_node(stderr, "pax", fndecl, 4);
94525 + }
94526 + }
94527 +
94528 + return 0;
94529 +}
94530 +
94531 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94532 +{
94533 + const char * const plugin_name = plugin_info->base_name;
94534 + struct register_pass_info kallocstat_pass_info = {
94535 + .pass = &kallocstat_pass.pass,
94536 + .reference_pass_name = "ssa",
94537 + .ref_pass_instance_number = 1,
94538 + .pos_op = PASS_POS_INSERT_AFTER
94539 + };
94540 +
94541 + if (!plugin_default_version_check(version, &gcc_version)) {
94542 + error(G_("incompatible gcc/plugin versions"));
94543 + return 1;
94544 + }
94545 +
94546 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
94547 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
94548 +
94549 + return 0;
94550 +}
94551 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
94552 new file mode 100644
94553 index 0000000..0408e06
94554 --- /dev/null
94555 +++ b/tools/gcc/kernexec_plugin.c
94556 @@ -0,0 +1,465 @@
94557 +/*
94558 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
94559 + * Licensed under the GPL v2
94560 + *
94561 + * Note: the choice of the license means that the compilation process is
94562 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94563 + * but for the kernel it doesn't matter since it doesn't link against
94564 + * any of the gcc libraries
94565 + *
94566 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
94567 + *
94568 + * TODO:
94569 + *
94570 + * BUGS:
94571 + * - none known
94572 + */
94573 +#include "gcc-plugin.h"
94574 +#include "config.h"
94575 +#include "system.h"
94576 +#include "coretypes.h"
94577 +#include "tree.h"
94578 +#include "tree-pass.h"
94579 +#include "flags.h"
94580 +#include "intl.h"
94581 +#include "toplev.h"
94582 +#include "plugin.h"
94583 +//#include "expr.h" where are you...
94584 +#include "diagnostic.h"
94585 +#include "plugin-version.h"
94586 +#include "tm.h"
94587 +#include "function.h"
94588 +#include "basic-block.h"
94589 +#include "gimple.h"
94590 +#include "rtl.h"
94591 +#include "emit-rtl.h"
94592 +#include "tree-flow.h"
94593 +
94594 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94595 +extern rtx emit_move_insn(rtx x, rtx y);
94596 +
94597 +#if BUILDING_GCC_VERSION <= 4006
94598 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
94599 +#endif
94600 +
94601 +#if BUILDING_GCC_VERSION >= 4008
94602 +#define TODO_dump_func 0
94603 +#endif
94604 +
94605 +int plugin_is_GPL_compatible;
94606 +
94607 +static struct plugin_info kernexec_plugin_info = {
94608 + .version = "201302112000",
94609 + .help = "method=[bts|or]\tinstrumentation method\n"
94610 +};
94611 +
94612 +static unsigned int execute_kernexec_reload(void);
94613 +static unsigned int execute_kernexec_fptr(void);
94614 +static unsigned int execute_kernexec_retaddr(void);
94615 +static bool kernexec_cmodel_check(void);
94616 +
94617 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
94618 +static void (*kernexec_instrument_retaddr)(rtx);
94619 +
94620 +static struct gimple_opt_pass kernexec_reload_pass = {
94621 + .pass = {
94622 + .type = GIMPLE_PASS,
94623 + .name = "kernexec_reload",
94624 +#if BUILDING_GCC_VERSION >= 4008
94625 + .optinfo_flags = OPTGROUP_NONE,
94626 +#endif
94627 + .gate = kernexec_cmodel_check,
94628 + .execute = execute_kernexec_reload,
94629 + .sub = NULL,
94630 + .next = NULL,
94631 + .static_pass_number = 0,
94632 + .tv_id = TV_NONE,
94633 + .properties_required = 0,
94634 + .properties_provided = 0,
94635 + .properties_destroyed = 0,
94636 + .todo_flags_start = 0,
94637 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94638 + }
94639 +};
94640 +
94641 +static struct gimple_opt_pass kernexec_fptr_pass = {
94642 + .pass = {
94643 + .type = GIMPLE_PASS,
94644 + .name = "kernexec_fptr",
94645 +#if BUILDING_GCC_VERSION >= 4008
94646 + .optinfo_flags = OPTGROUP_NONE,
94647 +#endif
94648 + .gate = kernexec_cmodel_check,
94649 + .execute = execute_kernexec_fptr,
94650 + .sub = NULL,
94651 + .next = NULL,
94652 + .static_pass_number = 0,
94653 + .tv_id = TV_NONE,
94654 + .properties_required = 0,
94655 + .properties_provided = 0,
94656 + .properties_destroyed = 0,
94657 + .todo_flags_start = 0,
94658 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
94659 + }
94660 +};
94661 +
94662 +static struct rtl_opt_pass kernexec_retaddr_pass = {
94663 + .pass = {
94664 + .type = RTL_PASS,
94665 + .name = "kernexec_retaddr",
94666 +#if BUILDING_GCC_VERSION >= 4008
94667 + .optinfo_flags = OPTGROUP_NONE,
94668 +#endif
94669 + .gate = kernexec_cmodel_check,
94670 + .execute = execute_kernexec_retaddr,
94671 + .sub = NULL,
94672 + .next = NULL,
94673 + .static_pass_number = 0,
94674 + .tv_id = TV_NONE,
94675 + .properties_required = 0,
94676 + .properties_provided = 0,
94677 + .properties_destroyed = 0,
94678 + .todo_flags_start = 0,
94679 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
94680 + }
94681 +};
94682 +
94683 +static bool kernexec_cmodel_check(void)
94684 +{
94685 + tree section;
94686 +
94687 + if (ix86_cmodel != CM_KERNEL)
94688 + return false;
94689 +
94690 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
94691 + if (!section || !TREE_VALUE(section))
94692 + return true;
94693 +
94694 + section = TREE_VALUE(TREE_VALUE(section));
94695 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
94696 + return true;
94697 +
94698 + return false;
94699 +}
94700 +
94701 +/*
94702 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
94703 + */
94704 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
94705 +{
94706 + gimple asm_movabs_stmt;
94707 +
94708 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
94709 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
94710 + gimple_asm_set_volatile(asm_movabs_stmt, true);
94711 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
94712 + update_stmt(asm_movabs_stmt);
94713 +}
94714 +
94715 +/*
94716 + * find all asm() stmts that clobber r10 and add a reload of r10
94717 + */
94718 +static unsigned int execute_kernexec_reload(void)
94719 +{
94720 + basic_block bb;
94721 +
94722 + // 1. loop through BBs and GIMPLE statements
94723 + FOR_EACH_BB(bb) {
94724 + gimple_stmt_iterator gsi;
94725 +
94726 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94727 + // gimple match: __asm__ ("" : : : "r10");
94728 + gimple asm_stmt;
94729 + size_t nclobbers;
94730 +
94731 + // is it an asm ...
94732 + asm_stmt = gsi_stmt(gsi);
94733 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
94734 + continue;
94735 +
94736 + // ... clobbering r10
94737 + nclobbers = gimple_asm_nclobbers(asm_stmt);
94738 + while (nclobbers--) {
94739 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
94740 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
94741 + continue;
94742 + kernexec_reload_fptr_mask(&gsi);
94743 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
94744 + break;
94745 + }
94746 + }
94747 + }
94748 +
94749 + return 0;
94750 +}
94751 +
94752 +/*
94753 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
94754 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
94755 + */
94756 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
94757 +{
94758 + gimple assign_intptr, assign_new_fptr, call_stmt;
94759 + tree intptr, old_fptr, new_fptr, kernexec_mask;
94760 +
94761 + call_stmt = gsi_stmt(*gsi);
94762 + old_fptr = gimple_call_fn(call_stmt);
94763 +
94764 + // create temporary unsigned long variable used for bitops and cast fptr to it
94765 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
94766 +#if BUILDING_GCC_VERSION <= 4007
94767 + add_referenced_var(intptr);
94768 + mark_sym_for_renaming(intptr);
94769 +#endif
94770 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
94771 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94772 + update_stmt(assign_intptr);
94773 +
94774 + // apply logical or to temporary unsigned long and bitmask
94775 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
94776 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
94777 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
94778 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
94779 + update_stmt(assign_intptr);
94780 +
94781 + // cast temporary unsigned long back to a temporary fptr variable
94782 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
94783 +#if BUILDING_GCC_VERSION <= 4007
94784 + add_referenced_var(new_fptr);
94785 + mark_sym_for_renaming(new_fptr);
94786 +#endif
94787 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
94788 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
94789 + update_stmt(assign_new_fptr);
94790 +
94791 + // replace call stmt fn with the new fptr
94792 + gimple_call_set_fn(call_stmt, new_fptr);
94793 + update_stmt(call_stmt);
94794 +}
94795 +
94796 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
94797 +{
94798 + gimple asm_or_stmt, call_stmt;
94799 + tree old_fptr, new_fptr, input, output;
94800 +#if BUILDING_GCC_VERSION <= 4007
94801 + VEC(tree, gc) *inputs = NULL;
94802 + VEC(tree, gc) *outputs = NULL;
94803 +#else
94804 + vec<tree, va_gc> *inputs = NULL;
94805 + vec<tree, va_gc> *outputs = NULL;
94806 +#endif
94807 +
94808 + call_stmt = gsi_stmt(*gsi);
94809 + old_fptr = gimple_call_fn(call_stmt);
94810 +
94811 + // create temporary fptr variable
94812 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
94813 +#if BUILDING_GCC_VERSION <= 4007
94814 + add_referenced_var(new_fptr);
94815 + mark_sym_for_renaming(new_fptr);
94816 +#endif
94817 +
94818 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
94819 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
94820 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
94821 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
94822 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
94823 +#if BUILDING_GCC_VERSION <= 4007
94824 + VEC_safe_push(tree, gc, inputs, input);
94825 + VEC_safe_push(tree, gc, outputs, output);
94826 +#else
94827 + vec_safe_push(inputs, input);
94828 + vec_safe_push(outputs, output);
94829 +#endif
94830 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
94831 + gimple_asm_set_volatile(asm_or_stmt, true);
94832 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
94833 + update_stmt(asm_or_stmt);
94834 +
94835 + // replace call stmt fn with the new fptr
94836 + gimple_call_set_fn(call_stmt, new_fptr);
94837 + update_stmt(call_stmt);
94838 +}
94839 +
94840 +/*
94841 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
94842 + */
94843 +static unsigned int execute_kernexec_fptr(void)
94844 +{
94845 + basic_block bb;
94846 +
94847 + // 1. loop through BBs and GIMPLE statements
94848 + FOR_EACH_BB(bb) {
94849 + gimple_stmt_iterator gsi;
94850 +
94851 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
94852 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
94853 + tree fn;
94854 + gimple call_stmt;
94855 +
94856 + // is it a call ...
94857 + call_stmt = gsi_stmt(gsi);
94858 + if (!is_gimple_call(call_stmt))
94859 + continue;
94860 + fn = gimple_call_fn(call_stmt);
94861 + if (TREE_CODE(fn) == ADDR_EXPR)
94862 + continue;
94863 + if (TREE_CODE(fn) != SSA_NAME)
94864 + gcc_unreachable();
94865 +
94866 + // ... through a function pointer
94867 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
94868 + fn = SSA_NAME_VAR(fn);
94869 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
94870 + debug_tree(fn);
94871 + gcc_unreachable();
94872 + }
94873 + }
94874 + fn = TREE_TYPE(fn);
94875 + if (TREE_CODE(fn) != POINTER_TYPE)
94876 + continue;
94877 + fn = TREE_TYPE(fn);
94878 + if (TREE_CODE(fn) != FUNCTION_TYPE)
94879 + continue;
94880 +
94881 + kernexec_instrument_fptr(&gsi);
94882 +
94883 +//debug_tree(gimple_call_fn(call_stmt));
94884 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
94885 + }
94886 + }
94887 +
94888 + return 0;
94889 +}
94890 +
94891 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
94892 +static void kernexec_instrument_retaddr_bts(rtx insn)
94893 +{
94894 + rtx btsq;
94895 + rtvec argvec, constraintvec, labelvec;
94896 + int line;
94897 +
94898 + // create asm volatile("btsq $63,(%%rsp)":::)
94899 + argvec = rtvec_alloc(0);
94900 + constraintvec = rtvec_alloc(0);
94901 + labelvec = rtvec_alloc(0);
94902 + line = expand_location(RTL_LOCATION(insn)).line;
94903 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94904 + MEM_VOLATILE_P(btsq) = 1;
94905 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
94906 + emit_insn_before(btsq, insn);
94907 +}
94908 +
94909 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
94910 +static void kernexec_instrument_retaddr_or(rtx insn)
94911 +{
94912 + rtx orq;
94913 + rtvec argvec, constraintvec, labelvec;
94914 + int line;
94915 +
94916 + // create asm volatile("orq %%r10,(%%rsp)":::)
94917 + argvec = rtvec_alloc(0);
94918 + constraintvec = rtvec_alloc(0);
94919 + labelvec = rtvec_alloc(0);
94920 + line = expand_location(RTL_LOCATION(insn)).line;
94921 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
94922 + MEM_VOLATILE_P(orq) = 1;
94923 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
94924 + emit_insn_before(orq, insn);
94925 +}
94926 +
94927 +/*
94928 + * find all asm level function returns and forcibly set the highest bit of the return address
94929 + */
94930 +static unsigned int execute_kernexec_retaddr(void)
94931 +{
94932 + rtx insn;
94933 +
94934 + // 1. find function returns
94935 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
94936 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
94937 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
94938 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
94939 + rtx body;
94940 +
94941 + // is it a retn
94942 + if (!JUMP_P(insn))
94943 + continue;
94944 + body = PATTERN(insn);
94945 + if (GET_CODE(body) == PARALLEL)
94946 + body = XVECEXP(body, 0, 0);
94947 + if (!ANY_RETURN_P(body))
94948 + continue;
94949 + kernexec_instrument_retaddr(insn);
94950 + }
94951 +
94952 +// print_simple_rtl(stderr, get_insns());
94953 +// print_rtl(stderr, get_insns());
94954 +
94955 + return 0;
94956 +}
94957 +
94958 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94959 +{
94960 + const char * const plugin_name = plugin_info->base_name;
94961 + const int argc = plugin_info->argc;
94962 + const struct plugin_argument * const argv = plugin_info->argv;
94963 + int i;
94964 + struct register_pass_info kernexec_reload_pass_info = {
94965 + .pass = &kernexec_reload_pass.pass,
94966 + .reference_pass_name = "ssa",
94967 + .ref_pass_instance_number = 1,
94968 + .pos_op = PASS_POS_INSERT_AFTER
94969 + };
94970 + struct register_pass_info kernexec_fptr_pass_info = {
94971 + .pass = &kernexec_fptr_pass.pass,
94972 + .reference_pass_name = "ssa",
94973 + .ref_pass_instance_number = 1,
94974 + .pos_op = PASS_POS_INSERT_AFTER
94975 + };
94976 + struct register_pass_info kernexec_retaddr_pass_info = {
94977 + .pass = &kernexec_retaddr_pass.pass,
94978 + .reference_pass_name = "pro_and_epilogue",
94979 + .ref_pass_instance_number = 1,
94980 + .pos_op = PASS_POS_INSERT_AFTER
94981 + };
94982 +
94983 + if (!plugin_default_version_check(version, &gcc_version)) {
94984 + error(G_("incompatible gcc/plugin versions"));
94985 + return 1;
94986 + }
94987 +
94988 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
94989 +
94990 + if (TARGET_64BIT == 0)
94991 + return 0;
94992 +
94993 + for (i = 0; i < argc; ++i) {
94994 + if (!strcmp(argv[i].key, "method")) {
94995 + if (!argv[i].value) {
94996 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94997 + continue;
94998 + }
94999 + if (!strcmp(argv[i].value, "bts")) {
95000 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95001 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95002 + } else if (!strcmp(argv[i].value, "or")) {
95003 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95004 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95005 + fix_register("r10", 1, 1);
95006 + } else
95007 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95008 + continue;
95009 + }
95010 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95011 + }
95012 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95013 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95014 +
95015 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95016 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95017 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95018 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95019 +
95020 + return 0;
95021 +}
95022 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95023 new file mode 100644
95024 index 0000000..b5395ba
95025 --- /dev/null
95026 +++ b/tools/gcc/latent_entropy_plugin.c
95027 @@ -0,0 +1,327 @@
95028 +/*
95029 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95030 + * Licensed under the GPL v2
95031 + *
95032 + * Note: the choice of the license means that the compilation process is
95033 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95034 + * but for the kernel it doesn't matter since it doesn't link against
95035 + * any of the gcc libraries
95036 + *
95037 + * gcc plugin to help generate a little bit of entropy from program state,
95038 + * used during boot in the kernel
95039 + *
95040 + * TODO:
95041 + * - add ipa pass to identify not explicitly marked candidate functions
95042 + * - mix in more program state (function arguments/return values, loop variables, etc)
95043 + * - more instrumentation control via attribute parameters
95044 + *
95045 + * BUGS:
95046 + * - LTO needs -flto-partition=none for now
95047 + */
95048 +#include "gcc-plugin.h"
95049 +#include "config.h"
95050 +#include "system.h"
95051 +#include "coretypes.h"
95052 +#include "tree.h"
95053 +#include "tree-pass.h"
95054 +#include "flags.h"
95055 +#include "intl.h"
95056 +#include "toplev.h"
95057 +#include "plugin.h"
95058 +//#include "expr.h" where are you...
95059 +#include "diagnostic.h"
95060 +#include "plugin-version.h"
95061 +#include "tm.h"
95062 +#include "function.h"
95063 +#include "basic-block.h"
95064 +#include "gimple.h"
95065 +#include "rtl.h"
95066 +#include "emit-rtl.h"
95067 +#include "tree-flow.h"
95068 +#include "langhooks.h"
95069 +
95070 +#if BUILDING_GCC_VERSION >= 4008
95071 +#define TODO_dump_func 0
95072 +#endif
95073 +
95074 +int plugin_is_GPL_compatible;
95075 +
95076 +static tree latent_entropy_decl;
95077 +
95078 +static struct plugin_info latent_entropy_plugin_info = {
95079 + .version = "201303102320",
95080 + .help = NULL
95081 +};
95082 +
95083 +static unsigned int execute_latent_entropy(void);
95084 +static bool gate_latent_entropy(void);
95085 +
95086 +static struct gimple_opt_pass latent_entropy_pass = {
95087 + .pass = {
95088 + .type = GIMPLE_PASS,
95089 + .name = "latent_entropy",
95090 +#if BUILDING_GCC_VERSION >= 4008
95091 + .optinfo_flags = OPTGROUP_NONE,
95092 +#endif
95093 + .gate = gate_latent_entropy,
95094 + .execute = execute_latent_entropy,
95095 + .sub = NULL,
95096 + .next = NULL,
95097 + .static_pass_number = 0,
95098 + .tv_id = TV_NONE,
95099 + .properties_required = PROP_gimple_leh | PROP_cfg,
95100 + .properties_provided = 0,
95101 + .properties_destroyed = 0,
95102 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95103 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95104 + }
95105 +};
95106 +
95107 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95108 +{
95109 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95110 + *no_add_attrs = true;
95111 + error("%qE attribute only applies to functions", name);
95112 + }
95113 + return NULL_TREE;
95114 +}
95115 +
95116 +static struct attribute_spec latent_entropy_attr = {
95117 + .name = "latent_entropy",
95118 + .min_length = 0,
95119 + .max_length = 0,
95120 + .decl_required = true,
95121 + .type_required = false,
95122 + .function_type_required = false,
95123 + .handler = handle_latent_entropy_attribute,
95124 +#if BUILDING_GCC_VERSION >= 4007
95125 + .affects_type_identity = false
95126 +#endif
95127 +};
95128 +
95129 +static void register_attributes(void *event_data, void *data)
95130 +{
95131 + register_attribute(&latent_entropy_attr);
95132 +}
95133 +
95134 +static bool gate_latent_entropy(void)
95135 +{
95136 + tree latent_entropy_attr;
95137 +
95138 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95139 + return latent_entropy_attr != NULL_TREE;
95140 +}
95141 +
95142 +static unsigned HOST_WIDE_INT seed;
95143 +static unsigned HOST_WIDE_INT get_random_const(void)
95144 +{
95145 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95146 + return seed;
95147 +}
95148 +
95149 +static enum tree_code get_op(tree *rhs)
95150 +{
95151 + static enum tree_code op;
95152 + unsigned HOST_WIDE_INT random_const;
95153 +
95154 + random_const = get_random_const();
95155 +
95156 + switch (op) {
95157 + case BIT_XOR_EXPR:
95158 + op = PLUS_EXPR;
95159 + break;
95160 +
95161 + case PLUS_EXPR:
95162 + if (rhs) {
95163 + op = LROTATE_EXPR;
95164 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95165 + break;
95166 + }
95167 +
95168 + case LROTATE_EXPR:
95169 + default:
95170 + op = BIT_XOR_EXPR;
95171 + break;
95172 + }
95173 + if (rhs)
95174 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95175 + return op;
95176 +}
95177 +
95178 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95179 +{
95180 + gimple_stmt_iterator gsi;
95181 + gimple assign;
95182 + tree addxorrol, rhs;
95183 + enum tree_code op;
95184 +
95185 + op = get_op(&rhs);
95186 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95187 + assign = gimple_build_assign(local_entropy, addxorrol);
95188 +#if BUILDING_GCC_VERSION <= 4007
95189 + find_referenced_vars_in(assign);
95190 +#endif
95191 +//debug_bb(bb);
95192 + gsi = gsi_after_labels(bb);
95193 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95194 + update_stmt(assign);
95195 +}
95196 +
95197 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95198 +{
95199 + gimple_stmt_iterator gsi;
95200 + gimple assign;
95201 + tree addxorrol, temp;
95202 +
95203 + // 1. create temporary copy of latent_entropy
95204 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95205 +#if BUILDING_GCC_VERSION <= 4007
95206 + add_referenced_var(temp);
95207 + mark_sym_for_renaming(temp);
95208 +#endif
95209 +
95210 + // 2. read...
95211 + assign = gimple_build_assign(temp, latent_entropy_decl);
95212 +#if BUILDING_GCC_VERSION <= 4007
95213 + find_referenced_vars_in(assign);
95214 +#endif
95215 + gsi = gsi_after_labels(bb);
95216 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95217 + update_stmt(assign);
95218 +
95219 + // 3. ...modify...
95220 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95221 + assign = gimple_build_assign(temp, addxorrol);
95222 +#if BUILDING_GCC_VERSION <= 4007
95223 + find_referenced_vars_in(assign);
95224 +#endif
95225 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95226 + update_stmt(assign);
95227 +
95228 + // 4. ...write latent_entropy
95229 + assign = gimple_build_assign(latent_entropy_decl, temp);
95230 +#if BUILDING_GCC_VERSION <= 4007
95231 + find_referenced_vars_in(assign);
95232 +#endif
95233 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95234 + update_stmt(assign);
95235 +}
95236 +
95237 +static unsigned int execute_latent_entropy(void)
95238 +{
95239 + basic_block bb;
95240 + gimple assign;
95241 + gimple_stmt_iterator gsi;
95242 + tree local_entropy;
95243 +
95244 + if (!latent_entropy_decl) {
95245 + struct varpool_node *node;
95246 +
95247 +#if BUILDING_GCC_VERSION <= 4007
95248 + for (node = varpool_nodes; node; node = node->next) {
95249 + tree var = node->decl;
95250 +#else
95251 + FOR_EACH_VARIABLE(node) {
95252 + tree var = node->symbol.decl;
95253 +#endif
95254 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95255 + continue;
95256 + latent_entropy_decl = var;
95257 +// debug_tree(var);
95258 + break;
95259 + }
95260 + if (!latent_entropy_decl) {
95261 +// debug_tree(current_function_decl);
95262 + return 0;
95263 + }
95264 + }
95265 +
95266 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95267 +
95268 + // 1. create local entropy variable
95269 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95270 +#if BUILDING_GCC_VERSION <= 4007
95271 + add_referenced_var(local_entropy);
95272 + mark_sym_for_renaming(local_entropy);
95273 +#endif
95274 +
95275 + // 2. initialize local entropy variable
95276 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95277 + if (dom_info_available_p(CDI_DOMINATORS))
95278 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95279 + gsi = gsi_start_bb(bb);
95280 +
95281 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95282 +// gimple_set_location(assign, loc);
95283 +#if BUILDING_GCC_VERSION <= 4007
95284 + find_referenced_vars_in(assign);
95285 +#endif
95286 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95287 + update_stmt(assign);
95288 + bb = bb->next_bb;
95289 +
95290 + // 3. instrument each BB with an operation on the local entropy variable
95291 + while (bb != EXIT_BLOCK_PTR) {
95292 + perturb_local_entropy(bb, local_entropy);
95293 + bb = bb->next_bb;
95294 + };
95295 +
95296 + // 4. mix local entropy into the global entropy variable
95297 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95298 + return 0;
95299 +}
95300 +
95301 +static void start_unit_callback(void *gcc_data, void *user_data)
95302 +{
95303 + tree latent_entropy_type;
95304 +
95305 +#if BUILDING_GCC_VERSION >= 4007
95306 + seed = get_random_seed(false);
95307 +#else
95308 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95309 + seed *= seed;
95310 +#endif
95311 +
95312 + if (in_lto_p)
95313 + return;
95314 +
95315 + // extern volatile u64 latent_entropy
95316 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95317 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95318 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95319 +
95320 + TREE_STATIC(latent_entropy_decl) = 1;
95321 + TREE_PUBLIC(latent_entropy_decl) = 1;
95322 + TREE_USED(latent_entropy_decl) = 1;
95323 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95324 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95325 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95326 + DECL_INITIAL(latent_entropy_decl) = NULL;
95327 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95328 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95329 +// varpool_finalize_decl(latent_entropy_decl);
95330 +// varpool_mark_needed_node(latent_entropy_decl);
95331 +}
95332 +
95333 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95334 +{
95335 + const char * const plugin_name = plugin_info->base_name;
95336 + struct register_pass_info latent_entropy_pass_info = {
95337 + .pass = &latent_entropy_pass.pass,
95338 + .reference_pass_name = "optimized",
95339 + .ref_pass_instance_number = 1,
95340 + .pos_op = PASS_POS_INSERT_BEFORE
95341 + };
95342 +
95343 + if (!plugin_default_version_check(version, &gcc_version)) {
95344 + error(G_("incompatible gcc/plugin versions"));
95345 + return 1;
95346 + }
95347 +
95348 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95349 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95350 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95351 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95352 +
95353 + return 0;
95354 +}
95355 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95356 new file mode 100644
95357 index 0000000..ddd5b2e
95358 --- /dev/null
95359 +++ b/tools/gcc/size_overflow_hash.data
95360 @@ -0,0 +1,5876 @@
95361 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95362 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95363 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95364 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95365 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95366 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95367 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95368 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95369 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95370 +DepcaSignature_80 DepcaSignature 2 80 NULL nohasharray
95371 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 &DepcaSignature_80
95372 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
95373 +load_msg_95 load_msg 2 95 NULL
95374 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
95375 +init_q_132 init_q 4 132 NULL
95376 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
95377 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
95378 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
95379 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
95380 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
95381 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
95382 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
95383 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
95384 +br_port_info_size_268 br_port_info_size 0 268 NULL
95385 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
95386 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
95387 +syslog_print_307 syslog_print 2 307 NULL
95388 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
95389 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
95390 +next_node_allowed_318 next_node_allowed 1 318 NULL
95391 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
95392 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
95393 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
95394 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
95395 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
95396 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
95397 +pidlist_resize_496 pidlist_resize 2 496 NULL
95398 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
95399 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
95400 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
95401 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
95402 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
95403 +dle_count_543 dle_count 0 543 NULL
95404 +devres_alloc_551 devres_alloc 2 551 NULL
95405 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
95406 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
95407 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
95408 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
95409 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
95410 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
95411 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
95412 +isp1760_register_628 isp1760_register 1-2 628 NULL
95413 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
95414 +unlink_queued_645 unlink_queued 3-4 645 NULL
95415 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
95416 +ceph_copy_user_to_page_vector_656 ceph_copy_user_to_page_vector 4-3 656 NULL
95417 +div_u64_rem_672 div_u64_rem 0 672 NULL
95418 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
95419 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
95420 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
95421 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
95422 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
95423 +wm8962_gpio_direction_out_738 wm8962_gpio_direction_out 2 738 NULL
95424 +dvb_video_write_754 dvb_video_write 3 754 NULL
95425 +iwl_read_targ_mem_772 iwl_read_targ_mem 0 772 NULL
95426 +snd_pcm_drain_811 snd_pcm_drain 0 811 NULL
95427 +if_writecmd_815 if_writecmd 2 815 NULL
95428 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
95429 +read_fifo_826 read_fifo 3 826 NULL
95430 +read_tree_block_841 read_tree_block 3 841 NULL
95431 +um_idi_read_850 um_idi_read 3 850 NULL
95432 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
95433 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
95434 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
95435 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
95436 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
95437 +readw_931 readw 0 931 NULL
95438 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
95439 +ieee80211_ie_build_vht_cap_956 ieee80211_ie_build_vht_cap 0 956 NULL nohasharray
95440 +__nodes_weight_956 __nodes_weight 2-0 956 &ieee80211_ie_build_vht_cap_956
95441 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
95442 +hdlcdev_rx_997 hdlcdev_rx 3 997 NULL
95443 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
95444 +lp872x_select_buck_vout_addr_1045 lp872x_select_buck_vout_addr 0 1045 NULL
95445 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
95446 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
95447 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
95448 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
95449 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
95450 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
95451 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
95452 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
95453 +store_risefalltime_1109 store_risefalltime 5 1109 NULL
95454 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
95455 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
95456 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
95457 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
95458 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
95459 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
95460 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
95461 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
95462 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
95463 +thin_status_1239 thin_status 5 1239 NULL
95464 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
95465 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
95466 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
95467 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
95468 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
95469 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
95470 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
95471 +ffs_1322 ffs 0 1322 NULL
95472 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
95473 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
95474 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
95475 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
95476 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
95477 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
95478 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
95479 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
95480 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
95481 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
95482 +zone_page_state_1393 zone_page_state 0 1393 NULL
95483 +file_read_actor_1401 file_read_actor 4 1401 NULL
95484 +lm3533_als_get_threshold_reg_1404 lm3533_als_get_threshold_reg 0-1 1404 NULL
95485 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
95486 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
95487 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
95488 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
95489 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
95490 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
95491 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
95492 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
95493 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
95494 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
95495 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
95496 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
95497 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
95498 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
95499 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
95500 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
95501 +rmap_add_1677 rmap_add 3 1677 NULL
95502 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
95503 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
95504 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
95505 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
95506 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
95507 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
95508 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
95509 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
95510 +cosa_write_1774 cosa_write 3 1774 NULL
95511 +update_macheader_1775 update_macheader 7 1775 NULL
95512 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
95513 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
95514 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
95515 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
95516 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
95517 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
95518 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
95519 +read_swap_header_1957 read_swap_header 0 1957 NULL
95520 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
95521 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
95522 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
95523 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
95524 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
95525 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
95526 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
95527 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
95528 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
95529 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
95530 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
95531 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
95532 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
95533 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
95534 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
95535 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
95536 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
95537 +audit_expand_2098 audit_expand 2 2098 NULL
95538 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
95539 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
95540 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
95541 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
95542 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
95543 +pcf50633_write_block_2124 pcf50633_write_block 3-2 2124 NULL
95544 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
95545 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL nohasharray
95546 +multipath_status_2151 multipath_status 5 2151 &mlx4_init_icm_table_2151
95547 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
95548 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
95549 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
95550 +u32_array_read_2219 u32_array_read 3 2219 NULL
95551 +vhci_write_2224 vhci_write 3 2224 NULL
95552 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
95553 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
95554 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
95555 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
95556 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
95557 +do_update_counters_2259 do_update_counters 4 2259 NULL
95558 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
95559 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
95560 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4 2308 NULL
95561 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
95562 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
95563 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
95564 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
95565 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
95566 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
95567 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
95568 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
95569 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
95570 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
95571 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
95572 +raid1_size_2419 raid1_size 0-2 2419 NULL
95573 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
95574 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
95575 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
95576 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
95577 +nfs4_alloc_slots_2454 nfs4_alloc_slots 1 2454 NULL nohasharray
95578 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 &nfs4_alloc_slots_2454
95579 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
95580 +update_pmkid_2481 update_pmkid 4 2481 NULL
95581 +wiphy_new_2482 wiphy_new 2 2482 NULL
95582 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
95583 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
95584 +dm_write_2513 dm_write 3 2513 NULL
95585 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
95586 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
95587 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
95588 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
95589 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
95590 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
95591 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
95592 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
95593 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
95594 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
95595 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
95596 +__next_cpu_2782 __next_cpu 1 2782 NULL
95597 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
95598 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
95599 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
95600 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
95601 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
95602 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
95603 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
95604 +__swab64p_2875 __swab64p 0 2875 NULL
95605 +nla_padlen_2883 nla_padlen 1 2883 NULL
95606 +cmm_write_2896 cmm_write 3 2896 NULL
95607 +rbd_req_sync_read_2915 rbd_req_sync_read 4-5 2915 NULL
95608 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
95609 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
95610 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
95611 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
95612 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
95613 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
95614 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
95615 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
95616 +depth_write_3021 depth_write 3 3021 NULL
95617 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
95618 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
95619 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
95620 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
95621 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
95622 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
95623 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
95624 +free_coherent_3082 free_coherent 4-2 3082 NULL
95625 +ttusb2_msg_3100 ttusb2_msg 4 3100 NULL
95626 +rb_alloc_3102 rb_alloc 1 3102 NULL
95627 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
95628 +print_time_3132 print_time 0 3132 NULL
95629 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
95630 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
95631 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
95632 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
95633 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
95634 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
95635 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
95636 +alloc_context_3194 alloc_context 1 3194 NULL
95637 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
95638 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
95639 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
95640 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
95641 +key_key_read_3241 key_key_read 3 3241 NULL
95642 +number_3243 number 0 3243 NULL
95643 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
95644 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
95645 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
95646 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
95647 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
95648 +de600_read_byte_3332 de600_read_byte 0 3332 NULL
95649 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
95650 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
95651 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
95652 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
95653 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
95654 +scnprintf_3360 scnprintf 0-2 3360 NULL nohasharray
95655 +tps65090_clr_bits_3360 tps65090_clr_bits 2 3360 &scnprintf_3360
95656 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
95657 +send_stream_3397 send_stream 4 3397 NULL
95658 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
95659 +msix_map_region_3411 msix_map_region 3 3411 NULL
95660 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
95661 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
95662 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
95663 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
95664 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
95665 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
95666 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
95667 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
95668 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
95669 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
95670 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
95671 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
95672 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
95673 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
95674 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
95675 +evtchn_read_3569 evtchn_read 3 3569 NULL
95676 +vc_resize_3585 vc_resize 2-3 3585 NULL
95677 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
95678 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
95679 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
95680 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
95681 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
95682 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
95683 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
95684 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
95685 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
95686 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0 3694 NULL
95687 +create_irq_3703 create_irq 0 3703 NULL nohasharray
95688 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
95689 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
95690 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
95691 +lm3533_als_get_threshold_3725 lm3533_als_get_threshold 2 3725 NULL
95692 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
95693 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
95694 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
95695 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
95696 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
95697 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
95698 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
95699 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
95700 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
95701 +get_fd_set_3866 get_fd_set 1 3866 NULL
95702 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
95703 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
95704 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
95705 +nvram_write_3894 nvram_write 3 3894 NULL
95706 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
95707 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
95708 +vcs_write_3910 vcs_write 3 3910 NULL
95709 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
95710 +do_add_counters_3992 do_add_counters 3 3992 NULL
95711 +userspace_status_4004 userspace_status 4 4004 NULL
95712 +mei_write_4005 mei_write 3 4005 NULL nohasharray
95713 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
95714 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
95715 +blk_end_request_4024 blk_end_request 3 4024 NULL
95716 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
95717 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
95718 +read_file_queues_4078 read_file_queues 3 4078 NULL
95719 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
95720 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
95721 +tm6000_read_4151 tm6000_read 3 4151 NULL
95722 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
95723 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
95724 +get_alua_req_4166 get_alua_req 3 4166 NULL
95725 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
95726 +read_file_bool_4180 read_file_bool 3 4180 NULL
95727 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
95728 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
95729 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
95730 +ext4_new_inode_4247 ext4_new_inode 5 4247 NULL
95731 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
95732 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
95733 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 2-3-5 4303 NULL
95734 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
95735 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
95736 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
95737 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
95738 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
95739 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
95740 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
95741 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
95742 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
95743 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
95744 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
95745 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
95746 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
95747 +set_link_security_4502 set_link_security 4 4502 NULL
95748 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
95749 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
95750 +tty_register_device_4544 tty_register_device 2 4544 NULL
95751 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
95752 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
95753 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
95754 +bch_alloc_4593 bch_alloc 1 4593 NULL
95755 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
95756 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
95757 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
95758 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
95759 +kone_receive_4690 kone_receive 4 4690 NULL
95760 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
95761 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
95762 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
95763 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
95764 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
95765 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
95766 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
95767 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
95768 +__iio_allocate_sw_ring_buffer_4843 __iio_allocate_sw_ring_buffer 3 4843 NULL
95769 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
95770 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
95771 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
95772 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
95773 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
95774 +sys_ipc_4889 sys_ipc 3 4889 NULL
95775 +lp872x_write_byte_4914 lp872x_write_byte 2 4914 NULL
95776 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
95777 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
95778 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
95779 +da9055_reg_write_4942 da9055_reg_write 2 4942 NULL
95780 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
95781 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
95782 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
95783 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
95784 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
95785 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
95786 +lm3533_als_set_target_5010 lm3533_als_set_target 2-3 5010 NULL
95787 +do_mincore_5018 do_mincore 0-1 5018 NULL
95788 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
95789 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
95790 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
95791 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
95792 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
95793 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
95794 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
95795 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
95796 +sound_write_5102 sound_write 3 5102 NULL
95797 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
95798 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
95799 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
95800 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
95801 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
95802 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
95803 +skb_network_header_5203 skb_network_header 0 5203 NULL
95804 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
95805 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
95806 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
95807 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
95808 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
95809 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
95810 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
95811 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
95812 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
95813 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
95814 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
95815 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
95816 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
95817 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
95818 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
95819 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
95820 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
95821 +tty_write_5494 tty_write 3 5494 NULL
95822 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
95823 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
95824 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
95825 +spidev_message_5518 spidev_message 3 5518 NULL
95826 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
95827 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
95828 +le_readq_5557 le_readq 0 5557 NULL
95829 +inw_5558 inw 0 5558 NULL
95830 +__first_dma_cap_5560 __first_dma_cap 0 5560 NULL
95831 +fir16_create_5574 fir16_create 3 5574 NULL
95832 +bioset_create_5580 bioset_create 1 5580 NULL
95833 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
95834 +do_msgrcv_5590 do_msgrcv 4 5590 NULL
95835 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
95836 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
95837 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
95838 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
95839 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
95840 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
95841 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
95842 +get_arg_5694 get_arg 3 5694 NULL
95843 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
95844 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
95845 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
95846 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
95847 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
95848 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
95849 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
95850 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
95851 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
95852 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
95853 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
95854 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
95855 +setup_req_5848 setup_req 3 5848 NULL
95856 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
95857 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
95858 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
95859 +port_show_regs_5904 port_show_regs 3 5904 NULL
95860 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
95861 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
95862 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
95863 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
95864 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
95865 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
95866 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
95867 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
95868 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
95869 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
95870 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
95871 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
95872 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
95873 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
95874 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
95875 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
95876 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
95877 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
95878 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
95879 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
95880 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
95881 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
95882 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
95883 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
95884 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
95885 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
95886 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
95887 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
95888 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 0 6282 NULL nohasharray
95889 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
95890 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
95891 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
95892 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
95893 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
95894 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
95895 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
95896 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
95897 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
95898 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
95899 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 NULL
95900 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
95901 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
95902 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
95903 +mei_read_6507 mei_read 3 6507 NULL
95904 +cpumask_next_and_6516 cpumask_next_and 1 6516 NULL
95905 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
95906 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
95907 +wdm_read_6549 wdm_read 3 6549 NULL
95908 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
95909 +usb_dump_config_descriptor_6572 usb_dump_config_descriptor 0 6572 NULL
95910 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
95911 +usemap_size_6601 usemap_size 0-1 6601 NULL
95912 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
95913 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
95914 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
95915 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
95916 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
95917 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
95918 +ieee80211_build_preq_ies_6691 ieee80211_build_preq_ies 0-4 6691 NULL
95919 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
95920 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
95921 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
95922 +mpeg_read_6708 mpeg_read 3 6708 NULL
95923 +video_proc_write_6724 video_proc_write 3 6724 NULL
95924 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
95925 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
95926 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
95927 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
95928 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
95929 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
95930 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
95931 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
95932 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
95933 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
95934 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
95935 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
95936 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
95937 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
95938 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
95939 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
95940 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
95941 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
95942 +ieee80211_rx_mgmt_probe_resp_6918 ieee80211_rx_mgmt_probe_resp 3 6918 NULL
95943 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
95944 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
95945 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
95946 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
95947 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
95948 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
95949 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
95950 +request_key_async_6990 request_key_async 4 6990 NULL
95951 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
95952 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
95953 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
95954 +wimax_msg_7030 wimax_msg 4 7030 NULL
95955 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
95956 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
95957 +event_enable_read_7074 event_enable_read 3 7074 NULL
95958 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
95959 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
95960 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
95961 +check_header_7108 check_header 0 7108 NULL
95962 +utf16_strsize_7203 utf16_strsize 0 7203 NULL nohasharray
95963 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 &utf16_strsize_7203
95964 +sys32_ipc_7238 sys32_ipc 3-5-6-4 7238 NULL
95965 +get_param_h_7247 get_param_h 0 7247 NULL
95966 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
95967 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
95968 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
95969 +mgmt_control_7349 mgmt_control 3 7349 NULL
95970 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
95971 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
95972 +hweight_long_7388 hweight_long 0-1 7388 NULL
95973 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
95974 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
95975 +readb_7401 readb 0 7401 NULL
95976 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
95977 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
95978 +ms_rw_multi_sector_7459 ms_rw_multi_sector 3-4 7459 NULL
95979 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL nohasharray
95980 +wm8996_gpio_direction_out_7469 wm8996_gpio_direction_out 2 7469 &__mutex_lock_common_7469
95981 +garp_request_join_7471 garp_request_join 4 7471 NULL
95982 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
95983 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
95984 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
95985 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
95986 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
95987 +setup_usemap_7524 setup_usemap 3 7524 NULL
95988 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
95989 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
95990 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
95991 +groups_alloc_7614 groups_alloc 1 7614 NULL
95992 +sg_virt_7616 sg_virt 0 7616 NULL
95993 +cpumask_first_7648 cpumask_first 0 7648 NULL
95994 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
95995 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
95996 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
95997 +dev_write_7708 dev_write 3 7708 NULL
95998 +tps65090_set_bits_7709 tps65090_set_bits 2 7709 NULL
95999 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL nohasharray
96000 +dbg_check_cats_7713 dbg_check_cats 0 7713 &brcmf_sdcard_send_buf_7713
96001 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96002 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96003 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96004 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96005 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96006 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96007 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96008 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96009 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96010 +da9052_reg_update_7858 da9052_reg_update 2 7858 NULL
96011 +tps6586x_clr_bits_7889 tps6586x_clr_bits 2 7889 NULL
96012 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96013 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96014 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96015 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96016 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96017 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96018 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96019 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96020 +sys_mbind_7990 sys_mbind 5 7990 NULL
96021 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96022 +vcs_read_8017 vcs_read 3 8017 NULL
96023 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96024 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96025 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96026 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96027 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96028 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96029 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96030 +venus_lookup_8121 venus_lookup 4 8121 NULL
96031 +lm3533_als_set_threshold_8125 lm3533_als_set_threshold 2 8125 NULL
96032 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96033 +ext_sd_execute_write_data_8175 ext_sd_execute_write_data 9 8175 NULL
96034 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96035 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96036 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96037 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96038 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96039 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96040 +play_iframe_8219 play_iframe 3 8219 NULL
96041 +create_log_8225 create_log 2 8225 NULL nohasharray
96042 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96043 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96044 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96045 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96046 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96047 +init_cdev_8274 init_cdev 1 8274 NULL
96048 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96049 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96050 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
96051 +lm3533_led_get_pattern_8321 lm3533_led_get_pattern 0 8321 NULL nohasharray
96052 +construct_key_and_link_8321 construct_key_and_link 4 8321 &lm3533_led_get_pattern_8321
96053 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96054 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96055 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96056 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96057 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96058 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96059 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96060 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96061 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96062 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96063 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96064 +_irq_to_enable_addr_8485 _irq_to_enable_addr 0-1 8485 NULL
96065 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96066 +dev_config_8506 dev_config 3 8506 NULL
96067 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96068 +utf16_strnlen_8513 utf16_strnlen 0 8513 NULL
96069 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96070 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96071 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96072 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96073 +profile_remove_8556 profile_remove 3 8556 NULL
96074 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96075 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96076 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96077 +tower_write_8580 tower_write 3 8580 NULL
96078 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96079 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96080 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96081 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96082 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96083 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96084 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96085 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96086 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96087 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96088 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96089 +arcfb_write_8702 arcfb_write 3 8702 NULL
96090 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96091 +init_header_8703 init_header 0 8703 &i_size_read_8703
96092 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96093 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL nohasharray
96094 +snapshot_status_8729 snapshot_status 5 8729 &jffs2_acl_count_8729
96095 +f_dupfd_8730 f_dupfd 1 8730 NULL
96096 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96097 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96098 +sys_prctl_8766 sys_prctl 4 8766 NULL
96099 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96100 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96101 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96102 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96103 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96104 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96105 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96106 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96107 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96108 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96109 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96110 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96111 +send_pages_8872 send_pages 3 8872 NULL
96112 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96113 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96114 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96115 +layout_commit_8926 layout_commit 3 8926 NULL
96116 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96117 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96118 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96119 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96120 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96121 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96122 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96123 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96124 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96125 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96126 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
96127 +palmas_ldo_write_9012 palmas_ldo_write 2 9012 NULL
96128 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96129 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96130 +nla_put_9042 nla_put 3 9042 NULL
96131 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96132 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96133 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96134 +string_9080 string 0 9080 NULL
96135 +create_queues_9088 create_queues 2-3 9088 NULL
96136 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96137 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96138 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96139 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96140 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96141 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96142 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96143 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96144 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96145 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96146 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96147 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96148 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96149 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96150 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96151 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96152 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96153 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96154 +flakey_status_9274 flakey_status 5 9274 NULL
96155 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96156 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96157 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96158 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96159 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96160 +read_9397 read 3 9397 NULL
96161 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96162 +cfg80211_report_obss_beacon_9422 cfg80211_report_obss_beacon 3 9422 NULL
96163 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96164 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96165 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96166 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96167 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96168 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96169 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96170 +rbd_coll_end_req_9472 rbd_coll_end_req 3 9472 NULL
96171 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96172 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96173 +lp_write_9511 lp_write 3 9511 NULL
96174 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96175 +lm3533_update_9529 lm3533_update 2 9529 NULL
96176 +read_file_dma_9530 read_file_dma 3 9530 NULL
96177 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96178 +tps65910_gpio_output_9539 tps65910_gpio_output 2 9539 NULL
96179 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96180 +readl_9557 readl 0 9557 NULL
96181 +fw_node_create_9559 fw_node_create 2 9559 NULL
96182 +kobj_map_9566 kobj_map 2-3 9566 NULL
96183 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96184 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96185 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96186 +do_sync_9604 do_sync 1 9604 NULL
96187 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96188 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96189 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96190 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96191 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96192 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96193 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96194 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96195 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96196 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96197 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96198 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 NULL nohasharray
96199 +is_hole_9694 is_hole 2 9694 &x25_asy_compat_ioctl_9694
96200 +fnb_9703 fnb 2-3 9703 NULL
96201 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 NULL
96202 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96203 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96204 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96205 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96206 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96207 +do_sigpending_9766 do_sigpending 2 9766 NULL
96208 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96209 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96210 +_regmap_write_9803 _regmap_write 2 9803 NULL
96211 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96212 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96213 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96214 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96215 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96216 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96217 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96218 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96219 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96220 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96221 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96222 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96223 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96224 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96225 +receive_DataRequest_9904 receive_DataRequest 3 9904 NULL
96226 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96227 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96228 +read_file_misc_9948 read_file_misc 3 9948 NULL
96229 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96230 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96231 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96232 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96233 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96234 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96235 +twl6040_clear_bits_9985 twl6040_clear_bits 2 9985 NULL
96236 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96237 +handle_request_10024 handle_request 9 10024 NULL
96238 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96239 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96240 +rbd_coll_end_req_index_10041 rbd_coll_end_req_index 5 10041 NULL
96241 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96242 +wm831x_gpio_direction_in_10099 wm831x_gpio_direction_in 2 10099 NULL
96243 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96244 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96245 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96246 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
96247 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96248 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96249 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96250 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96251 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96252 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96253 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96254 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96255 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96256 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96257 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96258 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96259 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96260 +lm3533_led_delay_set_10291 lm3533_led_delay_set 2 10291 NULL
96261 +read_emulate_10310 read_emulate 2-4 10310 NULL
96262 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96263 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96264 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96265 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96266 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96267 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96268 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96269 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96270 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96271 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96272 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96273 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96274 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96275 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96276 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96277 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96278 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96279 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
96280 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96281 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96282 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96283 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96284 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96285 +otp_read_10594 otp_read 2-4-5 10594 NULL
96286 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96287 +mc13783_set_fmt_10616 mc13783_set_fmt 3 10616 NULL
96288 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96289 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96290 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96291 +parport_write_10669 parport_write 0 10669 NULL
96292 +inl_10708 inl 0 10708 NULL nohasharray
96293 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96294 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96295 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96296 +spi_sync_10731 spi_sync 0 10731 NULL
96297 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96298 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96299 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96300 +sys_syslog_10746 sys_syslog 3 10746 NULL
96301 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96302 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96303 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4 10765 NULL
96304 +sys_bind_10799 sys_bind 3 10799 NULL
96305 +compat_put_int_10828 compat_put_int 1 10828 NULL
96306 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96307 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96308 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96309 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96310 +batadv_check_unicast_packet_10866 batadv_check_unicast_packet 2 10866 NULL
96311 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96312 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96313 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96314 +get_scq_10897 get_scq 2 10897 NULL
96315 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96316 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96317 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96318 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96319 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96320 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96321 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96322 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96323 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96324 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96325 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96326 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96327 +nouveau_gpio_create__11048 nouveau_gpio_create_ 4 11048 NULL
96328 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96329 +carl9170_handle_mpdu_11056 carl9170_handle_mpdu 3 11056 NULL
96330 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96331 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
96332 +count_argc_11083 count_argc 0 11083 NULL
96333 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96334 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96335 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96336 +page_offset_11120 page_offset 0 11120 NULL
96337 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96338 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
96339 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96340 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96341 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96342 +__swab16p_11220 __swab16p 0 11220 NULL
96343 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96344 +of_irq_count_11253 of_irq_count 0 11253 NULL
96345 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96346 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96347 +cru_detect_11272 cru_detect 1 11272 NULL
96348 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96349 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96350 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96351 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96352 +next_segment_11330 next_segment 0-2-1 11330 NULL
96353 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96354 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96355 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96356 +sel_write_create_11353 sel_write_create 3 11353 NULL
96357 +handle_unit_11355 handle_unit 0-1 11355 NULL
96358 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96359 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96360 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96361 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96362 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
96363 +str_to_user_11411 str_to_user 2 11411 NULL
96364 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
96365 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
96366 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
96367 +trace_options_read_11419 trace_options_read 3 11419 NULL
96368 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
96369 +prepare_image_11424 prepare_image 0 11424 NULL
96370 +vring_size_11426 vring_size 0-1-2 11426 NULL
96371 +bttv_read_11432 bttv_read 3 11432 NULL
96372 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
96373 +swp_offset_11475 swp_offset 0 11475 NULL
96374 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
96375 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
96376 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
96377 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
96378 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
96379 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
96380 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
96381 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
96382 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
96383 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
96384 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
96385 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
96386 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
96387 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
96388 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
96389 +da9055_gpio_direction_output_11680 da9055_gpio_direction_output 2 11680 NULL
96390 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
96391 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
96392 +split_11691 split 2 11691 NULL
96393 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
96394 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
96395 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
96396 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
96397 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
96398 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
96399 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
96400 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
96401 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
96402 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
96403 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
96404 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
96405 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
96406 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
96407 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
96408 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
96409 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
96410 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
96411 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
96412 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
96413 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
96414 +kvm_set_msr_common_11953 kvm_set_msr_common 3 11953 NULL
96415 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
96416 +atmel_read16_11981 atmel_read16 0 11981 NULL
96417 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
96418 +mwifiex_cfg80211_mgmt_tx_12022 mwifiex_cfg80211_mgmt_tx 9 12022 NULL
96419 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
96420 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
96421 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
96422 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
96423 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
96424 +da9052_gpio_direction_output_12120 da9052_gpio_direction_output 2 12120 NULL
96425 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
96426 +set_powered_12129 set_powered 4 12129 NULL
96427 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
96428 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
96429 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
96430 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
96431 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
96432 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
96433 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
96434 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
96435 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
96436 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
96437 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
96438 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
96439 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
96440 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
96441 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
96442 +receive_copy_12216 receive_copy 3 12216 NULL
96443 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
96444 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 NULL
96445 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
96446 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
96447 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
96448 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
96449 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
96450 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
96451 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
96452 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
96453 +split_bvec_12312 split_bvec 6 12312 NULL
96454 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
96455 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
96456 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
96457 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
96458 +receive_packet_12367 receive_packet 2 12367 NULL
96459 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
96460 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
96461 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL
96462 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
96463 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
96464 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
96465 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
96466 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
96467 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
96468 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
96469 +arizona_gpio_direction_out_12564 arizona_gpio_direction_out 2 12564 NULL
96470 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
96471 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
96472 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
96473 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
96474 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
96475 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
96476 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
96477 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
96478 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
96479 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
96480 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
96481 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
96482 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
96483 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
96484 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
96485 +ivtv_write_12721 ivtv_write 3 12721 NULL
96486 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
96487 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
96488 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
96489 +listxattr_12769 listxattr 3 12769 NULL
96490 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
96491 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
96492 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
96493 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
96494 +readq_12825 readq 0 12825 NULL
96495 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
96496 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 NULL nohasharray
96497 +spidev_sync_12842 spidev_sync 0 12842 &ath6kl_wmi_add_wow_pattern_cmd_12842
96498 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
96499 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
96500 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
96501 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
96502 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
96503 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
96504 +tps65910_reg_update_bits_12934 tps65910_reg_update_bits 2 12934 NULL
96505 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
96506 +bm_status_write_12964 bm_status_write 3 12964 NULL
96507 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
96508 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
96509 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
96510 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
96511 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
96512 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
96513 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
96514 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
96515 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
96516 +tps6586x_set_bits_13089 tps6586x_set_bits 2 13089 NULL
96517 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
96518 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
96519 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
96520 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
96521 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
96522 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
96523 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
96524 +blk_update_request_13146 blk_update_request 3 13146 NULL
96525 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
96526 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
96527 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
96528 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
96529 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
96530 +comedi_read_13199 comedi_read 3 13199 NULL
96531 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
96532 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
96533 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
96534 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
96535 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
96536 +fw_download_code_13249 fw_download_code 3 13249 NULL
96537 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
96538 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
96539 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
96540 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
96541 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
96542 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
96543 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
96544 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
96545 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
96546 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5 13337 NULL
96547 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
96548 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
96549 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
96550 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
96551 +sky2_receive_13407 sky2_receive 2 13407 NULL
96552 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
96553 +keyring_read_13438 keyring_read 3 13438 NULL
96554 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
96555 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
96556 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 7-8-9 13443 NULL
96557 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
96558 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
96559 +core_status_13515 core_status 4 13515 NULL
96560 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
96561 +bm_init_13529 bm_init 2 13529 NULL
96562 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
96563 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
96564 +alloc_tio_13564 alloc_tio 3 13564 NULL
96565 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
96566 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
96567 +pm860x_set_bits_13582 pm860x_set_bits 2 13582 NULL
96568 +cache_write_13589 cache_write 3 13589 NULL
96569 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
96570 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
96571 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
96572 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
96573 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
96574 +wm8994_bulk_write_13615 wm8994_bulk_write 3-2 13615 NULL
96575 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
96576 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
96577 +packet_snd_13634 packet_snd 3 13634 NULL
96578 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
96579 +cache_downcall_13666 cache_downcall 3 13666 NULL
96580 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
96581 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
96582 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
96583 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
96584 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
96585 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
96586 +random_read_13815 random_read 3 13815 NULL
96587 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
96588 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
96589 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
96590 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
96591 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
96592 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
96593 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
96594 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
96595 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
96596 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
96597 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
96598 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
96599 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
96600 +com90xx_found_13974 com90xx_found 3 13974 NULL
96601 +qcam_read_13977 qcam_read 3 13977 NULL
96602 +dsp_read_13980 dsp_read 2 13980 NULL
96603 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
96604 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
96605 +ieee80211_bss_info_update_13991 ieee80211_bss_info_update 4 13991 NULL
96606 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
96607 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
96608 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
96609 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
96610 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
96611 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
96612 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
96613 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
96614 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
96615 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
96616 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
96617 +em_canid_change_14150 em_canid_change 3 14150 NULL
96618 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
96619 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
96620 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
96621 +alloc_async_14208 alloc_async 1 14208 NULL
96622 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
96623 +pool_status_14230 pool_status 5 14230 NULL
96624 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
96625 +inode_to_path_14235 inode_to_path 2 14235 NULL
96626 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
96627 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 4-2 14245 NULL
96628 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
96629 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
96630 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
96631 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
96632 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
96633 +rr_status_14293 rr_status 5 14293 NULL
96634 +lp8788_write_byte_14299 lp8788_write_byte 2 14299 NULL
96635 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
96636 +oo_objects_14319 oo_objects 0 14319 NULL
96637 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
96638 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
96639 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
96640 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
96641 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
96642 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
96643 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
96644 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
96645 +block_size_14443 block_size 0 14443 NULL
96646 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
96647 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
96648 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
96649 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
96650 +stripe_status_14506 stripe_status 5 14506 NULL
96651 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
96652 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
96653 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
96654 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
96655 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
96656 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
96657 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
96658 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
96659 +dbJoin_14644 dbJoin 0 14644 NULL
96660 +profile_replace_14652 profile_replace 3 14652 NULL
96661 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
96662 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
96663 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
96664 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
96665 +vfd_write_14717 vfd_write 3 14717 NULL
96666 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
96667 +raid1_resize_14740 raid1_resize 2 14740 NULL
96668 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
96669 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
96670 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
96671 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
96672 +lm3533_als_get_hysteresis_14776 lm3533_als_get_hysteresis 2 14776 NULL
96673 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
96674 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
96675 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
96676 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
96677 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
96678 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
96679 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
96680 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
96681 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
96682 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
96683 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
96684 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
96685 +unifi_read_14899 unifi_read 3 14899 NULL
96686 +krealloc_14908 krealloc 2 14908 NULL
96687 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
96688 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL
96689 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
96690 +queue_cnt_14951 queue_cnt 0 14951 NULL
96691 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
96692 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
96693 +setkey_14987 setkey 3 14987 NULL nohasharray
96694 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
96695 +vmap_15025 vmap 2 15025 NULL
96696 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
96697 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
96698 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
96699 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
96700 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
96701 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
96702 +__alloc_extent_buffer_15093 __alloc_extent_buffer 3 15093 NULL
96703 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
96704 +start_port_15124 start_port 0 15124 NULL
96705 +memchr_15126 memchr 0 15126 NULL
96706 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
96707 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
96708 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
96709 +reserve_resources_15194 reserve_resources 3 15194 NULL
96710 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
96711 +variax_alloc_sysex_buffer_15237 variax_alloc_sysex_buffer 3 15237 NULL
96712 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
96713 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
96714 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
96715 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
96716 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
96717 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
96718 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
96719 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
96720 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
96721 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
96722 +ioread16_15342 ioread16 0 15342 NULL
96723 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
96724 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
96725 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
96726 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
96727 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
96728 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
96729 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
96730 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
96731 +get_modalias_15406 get_modalias 2 15406 NULL
96732 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
96733 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 0-2 15438 NULL
96734 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
96735 +memweight_15450 memweight 2 15450 NULL
96736 +vmalloc_15464 vmalloc 1 15464 NULL
96737 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
96738 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
96739 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
96740 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
96741 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
96742 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
96743 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
96744 +persistent_status_15574 persistent_status 4 15574 NULL
96745 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
96746 +vme_user_write_15587 vme_user_write 3 15587 NULL
96747 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
96748 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
96749 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
96750 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
96751 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
96752 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
96753 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
96754 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
96755 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
96756 +fs_path_add_15648 fs_path_add 3 15648 NULL
96757 +xsd_read_15653 xsd_read 3 15653 NULL
96758 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
96759 +unix_bind_15668 unix_bind 3 15668 NULL
96760 +dm_read_15674 dm_read 3 15674 NULL
96761 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
96762 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
96763 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
96764 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
96765 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
96766 +do_test_15766 do_test 1 15766 NULL
96767 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
96768 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
96769 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
96770 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
96771 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
96772 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
96773 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
96774 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
96775 +table_size_15851 table_size 0-1-2 15851 NULL
96776 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
96777 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
96778 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
96779 +ERR_PTR_15881 ERR_PTR 0 15881 NULL
96780 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
96781 +native_read_msr_15905 native_read_msr 0 15905 NULL
96782 +wm5100_gpio_direction_in_15934 wm5100_gpio_direction_in 2 15934 NULL
96783 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
96784 +power_read_15939 power_read 3 15939 NULL
96785 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
96786 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
96787 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
96788 +set_spte_15977 set_spte 7-6 15977 NULL
96789 +frame_alloc_15981 frame_alloc 4 15981 NULL
96790 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
96791 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
96792 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
96793 +got_frame_16028 got_frame 2 16028 NULL
96794 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
96795 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
96796 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
96797 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
96798 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
96799 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
96800 +fsm_init_16134 fsm_init 2 16134 NULL
96801 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
96802 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
96803 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
96804 +mapping_level_16188 mapping_level 2 16188 NULL
96805 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
96806 +create_table_16213 create_table 2 16213 NULL
96807 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
96808 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
96809 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 NULL
96810 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
96811 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
96812 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
96813 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
96814 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
96815 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
96816 +account_16283 account 0-2-4 16283 NULL nohasharray
96817 +mirror_status_16283 mirror_status 5 16283 &account_16283
96818 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
96819 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
96820 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
96821 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
96822 +tps80031_update_16360 tps80031_update 3 16360 NULL
96823 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
96824 +rbd_add_16366 rbd_add 3 16366 NULL
96825 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
96826 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
96827 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
96828 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
96829 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
96830 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
96831 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
96832 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
96833 +raid10_resize_16537 raid10_resize 2 16537 NULL
96834 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
96835 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
96836 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
96837 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
96838 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
96839 +da9052_reg_write_16685 da9052_reg_write 2 16685 NULL
96840 +em28xx_v4l2_read_16701 em28xx_v4l2_read 3 16701 NULL
96841 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
96842 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
96843 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
96844 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
96845 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
96846 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
96847 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
96848 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
96849 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
96850 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
96851 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
96852 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
96853 +st_write_16874 st_write 3 16874 NULL
96854 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
96855 +wm8350_set_bits_16911 wm8350_set_bits 2 16911 NULL
96856 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
96857 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
96858 +random32_16937 random32 0 16937 NULL
96859 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
96860 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
96861 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
96862 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
96863 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
96864 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
96865 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
96866 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
96867 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
96868 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
96869 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
96870 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
96871 +mac_address_string_17091 mac_address_string 0 17091 NULL
96872 +entry_length_17093 entry_length 0 17093 NULL
96873 +sys_preadv_17100 sys_preadv 3 17100 NULL
96874 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
96875 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
96876 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
96877 +sep_read_17161 sep_read 3 17161 NULL
96878 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
96879 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
96880 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
96881 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
96882 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
96883 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
96884 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
96885 +ms_rw_17220 ms_rw 3-4 17220 NULL
96886 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
96887 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
96888 +alloc_ep_17269 alloc_ep 1 17269 NULL
96889 +pg_read_17276 pg_read 3 17276 NULL
96890 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
96891 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
96892 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
96893 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
96894 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
96895 +skb_pad_17302 skb_pad 2 17302 NULL
96896 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
96897 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
96898 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
96899 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
96900 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
96901 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
96902 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
96903 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
96904 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
96905 +compat_cmd_17465 compat_cmd 2 17465 NULL
96906 +probe_bios_17467 probe_bios 1 17467 NULL
96907 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
96908 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
96909 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
96910 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
96911 +arizona_apply_fll_17538 arizona_apply_fll 2 17538 NULL
96912 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
96913 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
96914 +copy_from_user_17559 copy_from_user 3 17559 NULL
96915 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
96916 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
96917 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
96918 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
96919 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
96920 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
96921 +osst_execute_17607 osst_execute 7-6 17607 NULL
96922 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
96923 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
96924 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
96925 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
96926 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
96927 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
96928 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
96929 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
96930 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
96931 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
96932 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
96933 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
96934 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
96935 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL
96936 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
96937 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
96938 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
96939 +count_leafs_17842 count_leafs 0 17842 NULL
96940 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
96941 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
96942 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
96943 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
96944 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
96945 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
96946 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
96947 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
96948 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
96949 +wm8400_set_bits_17898 wm8400_set_bits 2 17898 NULL
96950 +recover_head_17904 recover_head 3 17904 NULL
96951 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
96952 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
96953 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
96954 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
96955 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
96956 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
96957 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
96958 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
96959 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
96960 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
96961 +prandom32_18007 prandom32 0 18007 NULL
96962 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
96963 +fill_read_18019 fill_read 0 18019 NULL
96964 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
96965 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
96966 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
96967 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
96968 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
96969 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
96970 +packet_came_18072 packet_came 3 18072 NULL
96971 +kvm_read_guest_page_18074 kvm_read_guest_page 5 18074 NULL
96972 +get_vm_area_18080 get_vm_area 1 18080 NULL
96973 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
96974 +tps65910_gpio_input_18110 tps65910_gpio_input 2 18110 NULL
96975 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
96976 +svc_getnl_18120 svc_getnl 0 18120 NULL
96977 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
96978 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
96979 +tps65910_gpio_set_18135 tps65910_gpio_set 2 18135 NULL
96980 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
96981 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
96982 +_has_tag_18169 _has_tag 2 18169 NULL
96983 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
96984 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
96985 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
96986 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
96987 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
96988 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
96989 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
96990 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
96991 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
96992 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
96993 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
96994 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
96995 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
96996 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
96997 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
96998 +um_idi_write_18293 um_idi_write 3 18293 NULL
96999 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97000 +vga_r_18310 vga_r 0 18310 NULL
97001 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97002 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97003 +wm8994_gpio_direction_out_18337 wm8994_gpio_direction_out 2 18337 NULL
97004 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97005 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97006 +ep_io_18367 ep_io 0 18367 NULL
97007 +lp872x_update_bits_18368 lp872x_update_bits 2 18368 NULL
97008 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 NULL
97009 +__video_register_device_18399 __video_register_device 3 18399 NULL
97010 +reada_tree_block_flagged_18402 reada_tree_block_flagged 3 18402 NULL nohasharray
97011 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &reada_tree_block_flagged_18402
97012 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97013 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97014 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97015 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97016 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97017 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97018 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97019 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97020 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97021 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97022 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97023 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97024 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97025 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97026 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97027 +debug_output_18575 debug_output 3 18575 NULL
97028 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97029 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97030 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
97031 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
97032 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97033 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97034 +from_buffer_18625 from_buffer 3 18625 NULL
97035 +f1x_map_sysaddr_to_csrow_18628 f1x_map_sysaddr_to_csrow 2 18628 NULL
97036 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97037 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97038 +unmap_page_18665 unmap_page 2-3 18665 NULL
97039 +edge_tty_recv_18667 edge_tty_recv 4 18667 NULL nohasharray
97040 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 &edge_tty_recv_18667
97041 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97042 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97043 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97044 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97045 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97046 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97047 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97048 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97049 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97050 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97051 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97052 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97053 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97054 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97055 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97056 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97057 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97058 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97059 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97060 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97061 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97062 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97063 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97064 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97065 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97066 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97067 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97068 +alc_auto_create_extra_outs_18975 alc_auto_create_extra_outs 2 18975 NULL
97069 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97070 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97071 +huge_page_size_19008 huge_page_size 0 19008 NULL
97072 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97073 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97074 +revalidate_19043 revalidate 2 19043 NULL
97075 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97076 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97077 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97078 +copy_and_check_19089 copy_and_check 3 19089 NULL
97079 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97080 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97081 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97082 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97083 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97084 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97085 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97086 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97087 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97088 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97089 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97090 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97091 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97092 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97093 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97094 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97095 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97096 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
97097 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97098 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97099 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97100 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97101 +qc_capture_19298 qc_capture 3 19298 NULL
97102 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97103 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97104 +debug_read_19322 debug_read 3 19322 NULL
97105 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97106 +read_zero_19366 read_zero 3 19366 NULL
97107 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97108 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
97109 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97110 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97111 +__phys_addr_19434 __phys_addr 0 19434 NULL
97112 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97113 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97114 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97115 +sky2_read16_19475 sky2_read16 0 19475 NULL
97116 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97117 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97118 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97119 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97120 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97121 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97122 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97123 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97124 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97125 +nfsd_read_19568 nfsd_read 5 19568 NULL
97126 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97127 +bm_status_read_19583 bm_status_read 3 19583 NULL
97128 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97129 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97130 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97131 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97132 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97133 +read_reg_19723 read_reg 0 19723 NULL
97134 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97135 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97136 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97137 +p9_client_read_19750 p9_client_read 5 19750 NULL
97138 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97139 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97140 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97141 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97142 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97143 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97144 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97145 +vip_read_19832 vip_read 3 19832 NULL nohasharray
97146 +vfs_getxattr_19832 vfs_getxattr 0 19832 &vip_read_19832
97147 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97148 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97149 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97150 +__nla_put_19857 __nla_put 3 19857 NULL
97151 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97152 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97153 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97154 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97155 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97156 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97157 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97158 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97159 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
97160 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97161 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97162 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97163 +team_options_register_20091 team_options_register 3 20091 NULL
97164 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97165 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97166 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97167 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97168 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97169 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97170 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97171 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97172 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97173 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97174 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97175 +resource_size_20256 resource_size 0 20256 NULL
97176 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97177 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97178 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97179 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97180 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97181 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
97182 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97183 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97184 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97185 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97186 +pm860x_write_reg_cache_20448 pm860x_write_reg_cache 2 20448 NULL
97187 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97188 +ip_vs_icmp_xmit_v6_20464 ip_vs_icmp_xmit_v6 4 20464 NULL
97189 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97190 +read_buf_20469 read_buf 2 20469 NULL
97191 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97192 +fast_user_write_20494 fast_user_write 5 20494 NULL
97193 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97194 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97195 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97196 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97197 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97198 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97199 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97200 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97201 +venus_create_20555 venus_create 4 20555 NULL
97202 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97203 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97204 +rc5t583_set_bits_20573 rc5t583_set_bits 2 20573 NULL
97205 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97206 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97207 +lirc_write_20604 lirc_write 3 20604 NULL
97208 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97209 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97210 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97211 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97212 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97213 +ceph_osdc_new_request_20654 ceph_osdc_new_request 15-4 20654 NULL
97214 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97215 +sec_reg_write_20667 sec_reg_write 2 20667 NULL
97216 +tps65910_reg_clear_bits_20672 tps65910_reg_clear_bits 2 20672 NULL
97217 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97218 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 NULL
97219 +cpumask_size_20683 cpumask_size 0 20683 NULL
97220 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97221 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97222 +__maestro_read_20700 __maestro_read 0 20700 NULL
97223 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97224 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97225 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97226 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97227 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97228 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97229 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97230 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97231 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97232 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97233 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97234 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97235 +sys_sendto_20809 sys_sendto 6 20809 NULL
97236 +strndup_user_20819 strndup_user 2 20819 NULL
97237 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97238 +uvc_alloc_entity_20836 uvc_alloc_entity 4-3 20836 NULL
97239 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97240 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97241 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97242 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97243 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97244 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97245 +htable_bits_20933 htable_bits 0 20933 NULL
97246 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97247 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97248 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97249 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97250 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97251 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97252 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97253 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97254 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97255 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97256 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97257 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97258 +multipath_status_21094 multipath_status 5 21094 NULL
97259 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97260 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97261 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97262 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97263 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97264 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97265 +ath6kl_mgmt_tx_21153 ath6kl_mgmt_tx 9 21153 NULL
97266 +setup_msi_irq_21169 setup_msi_irq 3 21169 NULL
97267 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97268 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97269 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97270 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97271 +input_ff_create_21240 input_ff_create 2 21240 NULL
97272 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97273 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97274 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97275 +rc5t583_clear_bits_21300 rc5t583_clear_bits 2 21300 NULL
97276 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97277 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97278 +add_res_range_21310 add_res_range 4 21310 NULL
97279 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97280 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97281 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97282 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97283 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97284 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97285 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97286 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97287 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97288 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97289 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97290 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97291 +btrfs_iref_to_path_21445 btrfs_iref_to_path 7 21445 NULL
97292 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97293 +concat_writev_21451 concat_writev 3 21451 NULL
97294 +extend_netdev_table_21453 extend_netdev_table 2 21453 NULL
97295 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97296 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97297 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97298 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97299 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97300 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97301 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97302 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97303 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97304 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
97305 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97306 +rbd_req_sync_op_21632 rbd_req_sync_op 7-8 21632 NULL
97307 +validate_nnode_21638 validate_nnode 0 21638 NULL
97308 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97309 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97310 +hpet_setup_msi_irq_21662 hpet_setup_msi_irq 1 21662 NULL
97311 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97312 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97313 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97314 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97315 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97316 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97317 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97318 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97319 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97320 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97321 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97322 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97323 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97324 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97325 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97326 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97327 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97328 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97329 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97330 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97331 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97332 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97333 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97334 +rbd_req_read_21952 rbd_req_read 4-5 21952 NULL
97335 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97336 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97337 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97338 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97339 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97340 +ti_recv_22027 ti_recv 4 22027 NULL
97341 +pcf50633_irq_unmask_22034 pcf50633_irq_unmask 2 22034 NULL
97342 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97343 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97344 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97345 +mem_rw_22085 mem_rw 3 22085 NULL
97346 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
97347 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97348 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97349 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97350 +compat_insn_22142 compat_insn 2 22142 NULL
97351 +pn533_dep_link_up_22154 pn533_dep_link_up 5 22154 NULL
97352 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97353 +__kfifo_alloc_22173 __kfifo_alloc 2-3 22173 NULL
97354 +fls_22210 fls 0 22210 NULL
97355 +bio_chain_clone_22227 bio_chain_clone 4 22227 NULL
97356 +mem_write_22232 mem_write 3 22232 NULL
97357 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97358 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97359 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97360 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97361 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97362 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97363 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97364 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97365 +get_segment_base_22324 get_segment_base 0 22324 NULL
97366 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97367 +atomic_read_22342 atomic_read 0 22342 NULL
97368 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97369 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL
97370 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97371 +wlcore_alloc_hw_22365 wlcore_alloc_hw 1 22365 NULL nohasharray
97372 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 &wlcore_alloc_hw_22365
97373 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
97374 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
97375 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
97376 +zoran_write_22404 zoran_write 3 22404 NULL
97377 +queue_reply_22416 queue_reply 3 22416 NULL
97378 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
97379 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
97380 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
97381 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
97382 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
97383 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
97384 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
97385 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
97386 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
97387 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
97388 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
97389 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
97390 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
97391 +snapshot_read_22601 snapshot_read 3 22601 NULL
97392 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
97393 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
97394 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
97395 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
97396 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
97397 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
97398 +fill_gap_22681 fill_gap 0 22681 NULL
97399 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
97400 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
97401 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
97402 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
97403 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
97404 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
97405 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
97406 +print_frame_22769 print_frame 0 22769 NULL
97407 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
97408 +retu_write_22800 retu_write 2 22800 NULL
97409 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
97410 +can_nocow_odirect_22854 can_nocow_odirect 3 22854 NULL nohasharray
97411 +read_file_rcstat_22854 read_file_rcstat 3 22854 &can_nocow_odirect_22854
97412 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
97413 +nfs4_realloc_slot_table_22859 nfs4_realloc_slot_table 2 22859 NULL
97414 +create_attr_set_22861 create_attr_set 1 22861 NULL
97415 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
97416 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
97417 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
97418 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
97419 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
97420 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
97421 +vme_get_size_22964 vme_get_size 0 22964 NULL
97422 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
97423 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
97424 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
97425 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
97426 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
97427 +st_status_23032 st_status 5 23032 NULL
97428 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
97429 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
97430 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
97431 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
97432 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
97433 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
97434 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
97435 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
97436 +fls_long_23096 fls_long 0 23096 NULL
97437 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
97438 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
97439 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
97440 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
97441 +__clear_user_23118 __clear_user 0 23118 NULL
97442 +dm_write_async_23120 dm_write_async 3 23120 NULL
97443 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
97444 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
97445 +wm831x_set_bits_23158 wm831x_set_bits 2 23158 NULL
97446 +read_file_ani_23161 read_file_ani 3 23161 NULL
97447 +ioremap_23172 ioremap 1-2 23172 NULL
97448 +usblp_write_23178 usblp_write 3 23178 NULL
97449 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
97450 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
97451 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
97452 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
97453 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
97454 +__next_dma_cap_23195 __next_dma_cap 1 23195 NULL
97455 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
97456 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
97457 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
97458 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
97459 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
97460 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
97461 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
97462 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
97463 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
97464 +doc_probe_23285 doc_probe 1 23285 NULL
97465 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
97466 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
97467 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
97468 +page_readlink_23346 page_readlink 3 23346 NULL
97469 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
97470 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
97471 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
97472 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
97473 +__cxio_init_resource_fifo_23447 __cxio_init_resource_fifo 3 23447 NULL nohasharray
97474 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 &__cxio_init_resource_fifo_23447
97475 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
97476 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
97477 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
97478 +event_filter_read_23494 event_filter_read 3 23494 NULL
97479 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
97480 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
97481 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
97482 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
97483 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
97484 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
97485 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
97486 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
97487 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
97488 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
97489 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
97490 +sInW_23663 sInW 0 23663 NULL
97491 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
97492 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
97493 +cx18_read_23699 cx18_read 3 23699 NULL
97494 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
97495 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
97496 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
97497 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
97498 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
97499 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
97500 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
97501 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
97502 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
97503 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
97504 +p54_init_common_23850 p54_init_common 1 23850 NULL
97505 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
97506 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
97507 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
97508 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
97509 +ieee80211_if_read_channel_type_23884 ieee80211_if_read_channel_type 3 23884 NULL
97510 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
97511 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
97512 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
97513 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
97514 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
97515 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
97516 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
97517 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
97518 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
97519 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
97520 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
97521 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
97522 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
97523 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
97524 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
97525 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
97526 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
97527 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
97528 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
97529 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
97530 +ieee80211_send_auth_24121 ieee80211_send_auth 5 24121 NULL
97531 +mpu401_read_24126 mpu401_read 3 24126 NULL
97532 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
97533 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
97534 +adu_read_24177 adu_read 3 24177 NULL
97535 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
97536 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
97537 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
97538 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
97539 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
97540 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
97541 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
97542 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
97543 +thin_status_24278 thin_status 5 24278 NULL
97544 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
97545 +msg_size_24288 msg_size 0 24288 NULL
97546 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
97547 +map_page_24298 map_page 3-4 24298 NULL
97548 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
97549 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
97550 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
97551 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
97552 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
97553 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
97554 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
97555 +igetword_24373 igetword 0 24373 NULL
97556 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
97557 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
97558 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
97559 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
97560 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
97561 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
97562 +smk_user_access_24440 smk_user_access 3 24440 NULL
97563 +page_address_24444 page_address 0 24444 NULL
97564 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
97565 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
97566 +pd_video_read_24510 pd_video_read 3 24510 NULL
97567 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
97568 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
97569 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
97570 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
97571 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
97572 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
97573 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
97574 +palmas_smps_write_24600 palmas_smps_write 2 24600 NULL nohasharray
97575 +count_preds_24600 count_preds 0 24600 &palmas_smps_write_24600
97576 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
97577 +context_alloc_24645 context_alloc 3 24645 NULL
97578 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
97579 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
97580 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
97581 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
97582 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
97583 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
97584 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
97585 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
97586 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
97587 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
97588 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
97589 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
97590 +cache_read_24790 cache_read 3 24790 NULL
97591 +unpack_str_24798 unpack_str 0 24798 NULL
97592 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
97593 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
97594 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
97595 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
97596 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
97597 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
97598 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
97599 +queues_read_24877 queues_read 3 24877 NULL
97600 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
97601 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
97602 +next_token_24929 next_token 0 24929 NULL
97603 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
97604 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
97605 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
97606 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
97607 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
97608 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
97609 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
97610 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
97611 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
97612 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
97613 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
97614 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
97615 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
97616 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL
97617 +cxio_hal_init_rhdl_resource_25104 cxio_hal_init_rhdl_resource 1 25104 NULL
97618 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
97619 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
97620 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
97621 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
97622 +mmu_set_spte_25177 mmu_set_spte 8-9 25177 NULL
97623 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
97624 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
97625 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
97626 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
97627 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
97628 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
97629 +stripe_status_25259 stripe_status 5 25259 NULL
97630 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
97631 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
97632 +vfs_writev_25278 vfs_writev 3 25278 NULL
97633 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
97634 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
97635 +help_25316 help 5 25316 NULL nohasharray
97636 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
97637 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
97638 +i915_gem_execbuffer_relocate_slow_25355 i915_gem_execbuffer_relocate_slow 7 25355 NULL
97639 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
97640 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
97641 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
97642 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
97643 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
97644 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
97645 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
97646 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
97647 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
97648 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
97649 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
97650 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
97651 +sb_permission_25523 sb_permission 0 25523 NULL
97652 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
97653 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
97654 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
97655 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
97656 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
97657 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
97658 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
97659 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
97660 +__get_user_pages_25628 __get_user_pages 0 25628 NULL nohasharray
97661 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
97662 +__direct_map_25647 __direct_map 5-6 25647 NULL
97663 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
97664 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
97665 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
97666 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
97667 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
97668 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
97669 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
97670 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
97671 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
97672 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
97673 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
97674 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
97675 +sg_read_25799 sg_read 3 25799 NULL
97676 +sys32_rt_sigpending_25814 sys32_rt_sigpending 2 25814 NULL
97677 +system_enable_read_25815 system_enable_read 3 25815 NULL
97678 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
97679 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
97680 +parport_read_25855 parport_read 0 25855 NULL
97681 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
97682 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
97683 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
97684 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
97685 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
97686 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
97687 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
97688 +utf16_strlen_25913 utf16_strlen 0 25913 NULL
97689 +rcname_read_25919 rcname_read 3 25919 NULL
97690 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
97691 +key_flags_read_25931 key_flags_read 3 25931 NULL
97692 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
97693 +tps80031_clr_bits_25942 tps80031_clr_bits 3 25942 NULL
97694 +flush_25957 flush 2 25957 NULL
97695 +video_register_device_25971 video_register_device 3 25971 NULL
97696 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
97697 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
97698 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
97699 +mirror_status_26010 mirror_status 5 26010 NULL
97700 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
97701 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
97702 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
97703 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
97704 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
97705 +tun_do_read_26047 tun_do_read 5 26047 NULL
97706 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
97707 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
97708 +cpumask_next_26096 cpumask_next 1 26096 NULL
97709 +skb_cow_26138 skb_cow 2 26138 NULL
97710 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
97711 +__fswab64_26155 __fswab64 0 26155 NULL
97712 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
97713 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
97714 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
97715 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
97716 +disk_devt_26180 disk_devt 0 26180 NULL
97717 +get_registers_26187 get_registers 3 26187 NULL
97718 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
97719 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
97720 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
97721 +mce_write_26201 mce_write 3 26201 NULL
97722 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
97723 +cxio_num_stags_26233 cxio_num_stags 0 26233 NULL
97724 +bio_split_26235 bio_split 2 26235 NULL
97725 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
97726 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
97727 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
97728 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
97729 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
97730 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
97731 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
97732 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
97733 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
97734 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
97735 +virtio_has_feature_26467 virtio_has_feature 0 26467 NULL
97736 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
97737 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
97738 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
97739 +read_vmcore_26501 read_vmcore 3 26501 NULL
97740 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
97741 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
97742 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
97743 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
97744 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
97745 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
97746 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
97747 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
97748 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
97749 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
97750 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
97751 +mmap_region_26649 mmap_region 0-2 26649 NULL
97752 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
97753 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
97754 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
97755 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
97756 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
97757 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
97758 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
97759 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
97760 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
97761 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
97762 +ntfs_are_rl_mergeable_26777 ntfs_are_rl_mergeable 0 26777 NULL
97763 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
97764 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
97765 +smk_write_load_26829 smk_write_load 3 26829 NULL
97766 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
97767 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
97768 +scnprint_id_26842 scnprint_id 3 26842 NULL
97769 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
97770 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
97771 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
97772 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
97773 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
97774 +wm8994_reg_write_26919 wm8994_reg_write 2 26919 NULL
97775 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
97776 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
97777 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
97778 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
97779 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
97780 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
97781 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
97782 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
97783 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
97784 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
97785 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
97786 +rbd_do_op_27025 rbd_do_op 7-8 27025 NULL
97787 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
97788 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
97789 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
97790 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
97791 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
97792 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
97793 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
97794 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
97795 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
97796 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
97797 +pms_capture_27142 pms_capture 4 27142 NULL
97798 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
97799 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
97800 +mc13xxx_irq_handle_27166 mc13xxx_irq_handle 3 27166 NULL
97801 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
97802 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
97803 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
97804 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
97805 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
97806 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
97807 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
97808 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
97809 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
97810 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
97811 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
97812 +rbd_req_sync_exec_27320 rbd_req_sync_exec 8 27320 NULL
97813 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
97814 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
97815 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
97816 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
97817 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
97818 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
97819 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
97820 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
97821 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
97822 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
97823 +tps65910_reg_set_bits_27468 tps65910_reg_set_bits 2 27468 NULL
97824 +rtsx_write_cfg_seq_27485 rtsx_write_cfg_seq 5-3 27485 NULL
97825 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
97826 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
97827 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
97828 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
97829 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
97830 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
97831 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
97832 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
97833 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
97834 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
97835 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
97836 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
97837 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
97838 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
97839 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
97840 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
97841 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
97842 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
97843 +qword_get_27670 qword_get 0 27670 NULL
97844 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
97845 +__tty_buffer_request_room_27700 __tty_buffer_request_room 2 27700 NULL
97846 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
97847 +evm_write_key_27715 evm_write_key 3 27715 NULL
97848 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
97849 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
97850 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
97851 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
97852 +kcalloc_27770 kcalloc 1-2 27770 NULL
97853 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
97854 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
97855 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
97856 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
97857 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
97858 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
97859 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
97860 +read_profile_27859 read_profile 3 27859 NULL
97861 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
97862 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
97863 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
97864 +gluebi_write_27905 gluebi_write 3 27905 NULL
97865 +mc13783_set_sysclk_27914 mc13783_set_sysclk 5 27914 NULL
97866 +bm_find_next_27929 bm_find_next 2 27929 NULL
97867 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
97868 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
97869 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
97870 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
97871 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
97872 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
97873 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
97874 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
97875 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
97876 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
97877 +pool_status_28055 pool_status 5 28055 NULL
97878 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
97879 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
97880 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
97881 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
97882 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
97883 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
97884 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
97885 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
97886 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
97887 +video_read_28148 video_read 3 28148 NULL
97888 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
97889 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
97890 +vread_28173 vread 0 28173 NULL
97891 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
97892 +d_path_28198 d_path 0 28198 NULL
97893 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
97894 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
97895 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
97896 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
97897 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
97898 +usemap_size_28281 usemap_size 0 28281 NULL
97899 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
97900 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
97901 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
97902 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
97903 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
97904 +snapshot_write_28351 snapshot_write 3 28351 NULL
97905 +__next_wq_cpu_28352 __next_wq_cpu 1 28352 NULL
97906 +sys_writev_28384 sys_writev 3 28384 NULL
97907 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
97908 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
97909 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
97910 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
97911 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
97912 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
97913 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
97914 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
97915 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
97916 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
97917 +max_response_pages_28492 max_response_pages 0 28492 NULL
97918 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
97919 +__next_node_28521 __next_node 1 28521 NULL
97920 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
97921 +early_init_dt_alloc_memory_arch_28528 early_init_dt_alloc_memory_arch 1 28528 NULL
97922 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
97923 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
97924 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
97925 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
97926 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
97927 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
97928 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
97929 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
97930 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
97931 +wm8350_clear_bits_28596 wm8350_clear_bits 2 28596 NULL
97932 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
97933 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
97934 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
97935 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
97936 +_set_range_28627 _set_range 3 28627 NULL
97937 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
97938 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
97939 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
97940 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
97941 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
97942 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
97943 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
97944 +spi_execute_28736 spi_execute 5 28736 NULL
97945 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
97946 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
97947 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
97948 +cxio_init_resource_fifo_28764 cxio_init_resource_fifo 3 28764 NULL
97949 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
97950 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
97951 +sel_write_member_28800 sel_write_member 3 28800 NULL
97952 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
97953 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0-8-3 28809 NULL
97954 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
97955 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
97956 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
97957 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
97958 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
97959 +tps6586x_update_28898 tps6586x_update 2 28898 NULL
97960 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
97961 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
97962 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
97963 +push_rx_28939 push_rx 3 28939 NULL
97964 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
97965 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
97966 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
97967 +bin_uuid_28999 bin_uuid 3 28999 NULL
97968 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
97969 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
97970 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
97971 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
97972 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
97973 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
97974 +ieee80211_probereq_get_29069 ieee80211_probereq_get 4-6 29069 NULL
97975 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
97976 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
97977 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
97978 +snprintf_29125 snprintf 0 29125 NULL
97979 +iov_shorten_29130 iov_shorten 0 29130 NULL
97980 +pm860x_reg_write_29141 pm860x_reg_write 2 29141 NULL
97981 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
97982 +reshape_ring_29147 reshape_ring 2 29147 NULL
97983 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
97984 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
97985 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
97986 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
97987 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
97988 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
97989 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
97990 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
97991 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
97992 +recover_peb_29238 recover_peb 6-7 29238 NULL
97993 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
97994 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
97995 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
97996 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
97997 +fd_do_writev_29329 fd_do_writev 3 29329 NULL
97998 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
97999 +tun_put_user_29337 tun_put_user 5 29337 NULL
98000 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98001 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98002 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98003 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98004 +mempool_create_29437 mempool_create 1 29437 NULL
98005 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98006 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98007 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98008 +do_register_entry_29478 do_register_entry 4 29478 NULL
98009 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98010 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98011 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98012 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98013 +ftrace_write_29551 ftrace_write 3 29551 NULL
98014 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98015 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98016 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98017 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98018 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98019 +wm8903_gpio_set_29597 wm8903_gpio_set 2 29597 NULL
98020 +slots_per_page_29601 slots_per_page 0 29601 NULL
98021 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98022 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98023 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98024 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98025 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98026 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98027 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98028 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98029 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98030 +probes_write_29711 probes_write 3 29711 NULL
98031 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98032 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98033 +da9055_gpio_direction_input_29742 da9055_gpio_direction_input 2 29742 NULL
98034 +cxio_hal_init_resource_29771 cxio_hal_init_resource 2-6-7 29771 NULL nohasharray
98035 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 &cxio_hal_init_resource_29771
98036 +dbAlloc_29794 dbAlloc 0 29794 NULL
98037 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98038 +arizona_gpio_set_29823 arizona_gpio_set 2 29823 NULL
98039 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98040 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98041 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98042 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98043 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98044 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98045 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98046 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98047 +tps6586x_write_29894 tps6586x_write 2 29894 NULL
98048 +check586_29914 check586 2 29914 NULL
98049 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98050 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98051 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98052 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98053 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98054 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98055 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98056 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98057 +drp_wmove_30043 drp_wmove 4 30043 NULL
98058 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98059 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98060 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98061 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
98062 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98063 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98064 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98065 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98066 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98067 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98068 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98069 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98070 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
98071 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98072 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98073 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98074 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98075 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98076 +compat_readv_30273 compat_readv 3 30273 NULL
98077 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98078 +__be64_to_cpup_30283 __be64_to_cpup 0 30283 NULL
98079 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98080 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98081 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98082 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98083 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98084 +resource_from_user_30341 resource_from_user 3 30341 NULL
98085 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98086 +sys_get_mempolicy_30379 sys_get_mempolicy 3 30379 NULL
98087 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98088 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98089 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98090 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98091 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98092 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98093 +enable_write_30456 enable_write 3 30456 NULL
98094 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98095 +urandom_read_30462 urandom_read 3 30462 NULL
98096 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98097 +write_head_30481 write_head 4 30481 NULL
98098 +adu_write_30487 adu_write 3 30487 NULL
98099 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
98100 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98101 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98102 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98103 +set_le_30581 set_le 4 30581 NULL
98104 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98105 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98106 +sgl_map_user_pages_30610 sgl_map_user_pages 2 30610 NULL
98107 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98108 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98109 +nfsd_nrpools_30651 nfsd_nrpools 0 30651 NULL
98110 +agp_remap_30665 agp_remap 2 30665 NULL
98111 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98112 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98113 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98114 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98115 +snapshot_status_30744 snapshot_status 5 30744 NULL
98116 +max77693_update_reg_30747 max77693_update_reg 2 30747 NULL
98117 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98118 +wm8350_read_auxadc_30780 wm8350_read_auxadc 2 30780 NULL
98119 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98120 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98121 +create_subvol_30836 create_subvol 4 30836 NULL
98122 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98123 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL nohasharray
98124 +twl6040_set_bits_30844 twl6040_set_bits 2 30844 &cfg80211_rx_mgmt_30844
98125 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98126 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98127 +f1x_match_to_this_node_30888 f1x_match_to_this_node 3 30888 NULL
98128 +regmap_update_bits_check_30894 regmap_update_bits_check 2 30894 NULL
98129 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98130 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98131 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98132 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98133 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98134 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98135 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98136 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98137 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98138 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98139 +sys_mincore_31079 sys_mincore 1 31079 NULL
98140 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98141 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98142 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
98143 +depth_read_31112 depth_read 3 31112 NULL
98144 +ssb_read16_31139 ssb_read16 0 31139 NULL
98145 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98146 +size_inside_page_31141 size_inside_page 0 31141 NULL
98147 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98148 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98149 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98150 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98151 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98152 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98153 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98154 +__read_reg_31216 __read_reg 0 31216 NULL
98155 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98156 +cyy_readb_31240 cyy_readb 0 31240 NULL
98157 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98158 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98159 +ceph_copy_page_vector_to_user_31270 ceph_copy_page_vector_to_user 3-4 31270 NULL
98160 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98161 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98162 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98163 +futex_uaddr_31316 futex_uaddr 2 31316 NULL
98164 +command_file_write_31318 command_file_write 3 31318 NULL
98165 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
98166 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98167 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3 31374 NULL
98168 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98169 +inb_31388 inb 0 31388 NULL
98170 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98171 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98172 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98173 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98174 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98175 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98176 +_regmap_update_bits_31456 _regmap_update_bits 2 31456 NULL
98177 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98178 +do_fcntl_31468 do_fcntl 3 31468 NULL
98179 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98180 +alg_setkey_31485 alg_setkey 3 31485 NULL
98181 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98182 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98183 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
98184 +hidraw_write_31536 hidraw_write 3 31536 NULL
98185 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98186 +usbvision_read_31555 usbvision_read 3 31555 NULL
98187 +normalize_31566 normalize 0-1-2 31566 NULL
98188 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98189 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98190 +osst_write_31581 osst_write 3 31581 NULL
98191 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98192 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98193 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98194 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98195 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98196 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98197 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98198 +__lgread_31668 __lgread 4 31668 NULL
98199 +symbol_string_31670 symbol_string 0 31670 NULL
98200 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98201 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98202 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98203 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98204 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL
98205 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98206 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98207 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98208 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98209 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98210 +lm3533_led_get_pattern_reg_31752 lm3533_led_get_pattern_reg 0-2 31752 NULL
98211 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98212 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98213 +get_count_order_31800 get_count_order 0 31800 NULL
98214 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98215 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98216 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98217 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98218 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98219 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98220 +xattr_permission_31907 xattr_permission 0 31907 NULL
98221 +new_dir_31919 new_dir 3 31919 NULL
98222 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98223 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98224 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98225 +vb2_write_31948 vb2_write 3 31948 NULL
98226 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98227 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
98228 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98229 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98230 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98231 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98232 +calc_hmac_32010 calc_hmac 3 32010 NULL
98233 +aead_len_32021 aead_len 0 32021 NULL
98234 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98235 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98236 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98237 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98238 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98239 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98240 +bio_alloc_32095 bio_alloc 2 32095 NULL
98241 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98242 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98243 +disk_status_32120 disk_status 4 32120 NULL
98244 +rc5t583_write_32124 rc5t583_write 2 32124 NULL
98245 +venus_link_32165 venus_link 5 32165 NULL
98246 +drbd_new_dev_size_32171 drbd_new_dev_size 0 32171 NULL
98247 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98248 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98249 +load_header_32183 load_header 0 32183 NULL
98250 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98251 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98252 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98253 +lm3533_write_32236 lm3533_write 2 32236 NULL
98254 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98255 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98256 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98257 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98258 +hex_string_32310 hex_string 0 32310 NULL
98259 +flakey_status_32315 flakey_status 5 32315 NULL
98260 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98261 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98262 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98263 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98264 +f1x_translate_sysaddr_to_cs_32359 f1x_translate_sysaddr_to_cs 2 32359 NULL
98265 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98266 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98267 +variax_set_raw2_32374 variax_set_raw2 4 32374 NULL
98268 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98269 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98270 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98271 +log_text_32428 log_text 0 32428 NULL
98272 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98273 +hid_input_report_32458 hid_input_report 4 32458 NULL
98274 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
98275 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98276 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98277 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98278 +disconnect_32521 disconnect 4 32521 NULL
98279 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98280 +ilo_read_32531 ilo_read 3 32531 NULL
98281 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL nohasharray
98282 +crypt_status_32533 crypt_status 5 32533 &ieee80211_if_read_estab_plinks_32533
98283 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98284 +__first_node_32558 __first_node 0 32558 NULL
98285 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98286 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98287 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98288 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98289 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98290 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98291 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98292 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98293 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98294 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98295 +kvmalloc_32646 kvmalloc 1 32646 NULL
98296 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98297 +generic_readlink_32654 generic_readlink 3 32654 NULL
98298 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98299 +tps80031_set_bits_32686 tps80031_set_bits 3 32686 NULL
98300 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98301 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98302 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98303 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98304 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98305 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98306 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98307 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98308 +vga_rseq_32848 vga_rseq 0 32848 NULL
98309 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98310 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98311 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98312 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98313 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98314 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98315 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98316 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98317 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98318 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98319 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98320 +compat_filldir_32999 compat_filldir 3 32999 NULL
98321 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98322 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
98323 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98324 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98325 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98326 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98327 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98328 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98329 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98330 +write_node_33121 write_node 4 33121 NULL
98331 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98332 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98333 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98334 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98335 +pp_read_33210 pp_read 3 33210 NULL
98336 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98337 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98338 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98339 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98340 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98341 +pcf50633_irq_mask_33280 pcf50633_irq_mask 2 33280 NULL
98342 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98343 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98344 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98345 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98346 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98347 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98348 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98349 +ceph_osdc_writepages_33375 ceph_osdc_writepages 5 33375 NULL
98350 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98351 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98352 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98353 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98354 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98355 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98356 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98357 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98358 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98359 +create_entry_33479 create_entry 2 33479 NULL
98360 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98361 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98362 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98363 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98364 +res_counter_read_33499 res_counter_read 4 33499 NULL
98365 +fb_read_33506 fb_read 3 33506 NULL
98366 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98367 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98368 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98369 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98370 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98371 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98372 +dup_array_33551 dup_array 3 33551 NULL
98373 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98374 +count_subheaders_33591 count_subheaders 0 33591 NULL
98375 +scsi_execute_33596 scsi_execute 5 33596 NULL
98376 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
98377 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
98378 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
98379 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 NULL
98380 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
98381 +inw_p_33668 inw_p 0 33668 NULL
98382 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
98383 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
98384 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
98385 +rbd_alloc_coll_33678 rbd_alloc_coll 1 33678 NULL
98386 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
98387 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
98388 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
98389 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
98390 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
98391 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
98392 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
98393 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
98394 +Read_hfc_33755 Read_hfc 0 33755 NULL
98395 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
98396 +hashtab_create_33769 hashtab_create 3 33769 NULL
98397 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
98398 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
98399 +find_next_offset_33804 find_next_offset 3 33804 NULL
98400 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
98401 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
98402 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
98403 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
98404 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
98405 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
98406 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
98407 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
98408 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
98409 +config_proc_write_33878 config_proc_write 3 33878 NULL
98410 +get_user_pages_33908 get_user_pages 0 33908 NULL
98411 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
98412 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
98413 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
98414 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
98415 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
98416 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
98417 +ppp_write_34034 ppp_write 3 34034 NULL
98418 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
98419 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
98420 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
98421 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
98422 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
98423 +show_risefalltime_34084 show_risefalltime 4 34084 NULL
98424 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
98425 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
98426 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
98427 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
98428 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
98429 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
98430 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
98431 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
98432 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
98433 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
98434 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
98435 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
98436 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
98437 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
98438 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
98439 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
98440 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
98441 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
98442 +ea_read_34378 ea_read 0 34378 NULL
98443 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
98444 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
98445 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
98446 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
98447 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
98448 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
98449 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
98450 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
98451 +line6_dumpreq_init_34473 line6_dumpreq_init 3 34473 NULL
98452 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
98453 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
98454 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
98455 +alloc_buf_34532 alloc_buf 1 34532 NULL
98456 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
98457 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
98458 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
98459 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
98460 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
98461 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
98462 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
98463 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
98464 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
98465 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
98466 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
98467 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
98468 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
98469 +port_print_34704 port_print 3 34704 NULL
98470 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
98471 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
98472 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
98473 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
98474 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
98475 +ssd1307fb_write_array_34779 ssd1307fb_write_array 4 34779 NULL
98476 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
98477 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
98478 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
98479 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
98480 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
98481 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
98482 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
98483 +lm3533_ctrlbank_get_reg_34886 lm3533_ctrlbank_get_reg 0-2 34886 NULL
98484 +msg_print_text_34889 msg_print_text 0 34889 NULL
98485 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
98486 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
98487 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
98488 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
98489 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
98490 +Realloc_34961 Realloc 2 34961 NULL
98491 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
98492 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
98493 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
98494 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
98495 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
98496 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
98497 +store_ifalias_35088 store_ifalias 4 35088 NULL
98498 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
98499 +capi_write_35104 capi_write 3 35104 NULL nohasharray
98500 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
98501 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
98502 +pointer_35138 pointer 0 35138 NULL
98503 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
98504 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
98505 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
98506 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
98507 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
98508 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
98509 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
98510 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
98511 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
98512 +set_fd_set_35249 set_fd_set 1 35249 NULL
98513 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
98514 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
98515 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
98516 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
98517 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
98518 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
98519 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
98520 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
98521 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
98522 +new_bind_ctl_35324 new_bind_ctl 2 35324 NULL
98523 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
98524 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
98525 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
98526 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
98527 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
98528 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
98529 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
98530 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
98531 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
98532 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
98533 +rdev_get_id_35454 rdev_get_id 0 35454 NULL
98534 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
98535 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
98536 +async_setkey_35521 async_setkey 3 35521 NULL
98537 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
98538 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
98539 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
98540 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
98541 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
98542 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
98543 +ReadZReg_35604 ReadZReg 0 35604 NULL
98544 +kernel_readv_35617 kernel_readv 3 35617 NULL
98545 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
98546 +scrub_stripe_35637 scrub_stripe 4-3 35637 NULL
98547 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
98548 +store_debug_level_35652 store_debug_level 3 35652 NULL
98549 +regmap_update_bits_35668 regmap_update_bits 2 35668 NULL
98550 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
98551 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
98552 +dm_table_create_35687 dm_table_create 3 35687 NULL
98553 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
98554 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
98555 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
98556 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
98557 +read_file_stations_35795 read_file_stations 3 35795 NULL
98558 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
98559 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
98560 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
98561 +fls64_35862 fls64 0 35862 NULL
98562 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
98563 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
98564 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
98565 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
98566 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
98567 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
98568 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
98569 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
98570 +wm8350_reg_write_35967 wm8350_reg_write 2 35967 NULL
98571 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
98572 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
98573 +acl_alloc_35979 acl_alloc 1 35979 NULL
98574 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
98575 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
98576 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
98577 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
98578 +sys_init_module_36047 sys_init_module 2 36047 NULL
98579 +account_shadowed_36048 account_shadowed 2 36048 NULL
98580 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
98581 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
98582 +write_emulate_36065 write_emulate 2-4 36065 NULL
98583 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
98584 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
98585 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
98586 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
98587 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
98588 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
98589 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
98590 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
98591 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
98592 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
98593 +iwl_trans_txq_alloc_36147 iwl_trans_txq_alloc 3 36147 NULL
98594 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
98595 +twl_set_36154 twl_set 2 36154 NULL
98596 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
98597 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
98598 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
98599 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
98600 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
98601 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
98602 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
98603 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
98604 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
98605 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
98606 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
98607 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
98608 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
98609 +readahead_tree_block_36285 readahead_tree_block 3 36285 NULL
98610 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
98611 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
98612 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
98613 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
98614 +lc_create_36332 lc_create 4 36332 NULL
98615 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
98616 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
98617 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
98618 +to_sector_36361 to_sector 0-1 36361 NULL
98619 +tunables_read_36385 tunables_read 3 36385 NULL
98620 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
98621 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
98622 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
98623 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
98624 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
98625 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
98626 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
98627 +get_param_l_36518 get_param_l 0 36518 NULL
98628 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
98629 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
98630 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
98631 +ssd1307fb_write_data_array_36538 ssd1307fb_write_data_array 3 36538 NULL
98632 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
98633 +get_entry_len_36549 get_entry_len 0 36549 NULL
98634 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
98635 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
98636 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
98637 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
98638 +__erst_read_36579 __erst_read 0 36579 NULL
98639 +put_cmsg_36589 put_cmsg 4 36589 NULL
98640 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
98641 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
98642 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
98643 +format_decode_36638 format_decode 0 36638 NULL
98644 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
98645 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
98646 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
98647 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
98648 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
98649 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
98650 +snd_soc_update_bits_36714 snd_soc_update_bits 2 36714 NULL
98651 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
98652 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
98653 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
98654 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
98655 +snd_soc_update_bits_locked_36766 snd_soc_update_bits_locked 2 36766 NULL
98656 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
98657 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
98658 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
98659 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
98660 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
98661 +pcf50633_reg_write_36841 pcf50633_reg_write 2 36841 NULL nohasharray
98662 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 &pcf50633_reg_write_36841
98663 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
98664 +cm_write_36858 cm_write 3 36858 NULL
98665 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
98666 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
98667 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
98668 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
98669 +lm3533_als_get_target_36905 lm3533_als_get_target 2-3 36905 NULL
98670 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
98671 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
98672 +div_u64_36951 div_u64 0 36951 NULL
98673 +write_leb_36957 write_leb 5 36957 NULL
98674 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
98675 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
98676 +mc13xxx_reg_rmw_36997 mc13xxx_reg_rmw 2 36997 NULL
98677 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
98678 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
98679 +setxattr_37006 setxattr 4 37006 NULL
98680 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 NULL
98681 +parse_command_37079 parse_command 2 37079 NULL
98682 +wm8994_gpio_set_37082 wm8994_gpio_set 2 37082 NULL
98683 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
98684 +tun_get_user_37094 tun_get_user 5 37094 NULL
98685 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
98686 +msg_word_37164 msg_word 0 37164 NULL
98687 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
98688 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
98689 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
98690 +__do_replace_37227 __do_replace 5 37227 NULL
98691 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
98692 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
98693 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
98694 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
98695 +c101_run_37279 c101_run 2 37279 NULL
98696 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
98697 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
98698 +send_msg_37323 send_msg 4 37323 NULL
98699 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
98700 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
98701 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
98702 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
98703 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
98704 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
98705 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
98706 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
98707 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
98708 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
98709 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
98710 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
98711 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
98712 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
98713 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
98714 +get_est_timing_37484 get_est_timing 0 37484 NULL
98715 +xfs_trans_read_buf_map_37487 xfs_trans_read_buf_map 5 37487 NULL
98716 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
98717 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
98718 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
98719 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
98720 +hdr_size_37536 hdr_size 0 37536 NULL
98721 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
98722 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
98723 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
98724 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
98725 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6 37611 NULL
98726 +alloc_fd_37637 alloc_fd 1 37637 NULL
98727 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
98728 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
98729 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
98730 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
98731 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
98732 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
98733 +nametbl_header_37698 nametbl_header 2 37698 NULL
98734 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
98735 +soc_widget_update_bits_locked_37715 soc_widget_update_bits_locked 2 37715 NULL
98736 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
98737 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
98738 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
98739 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
98740 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
98741 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
98742 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
98743 +deny_write_access_37813 deny_write_access 0 37813 NULL
98744 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
98745 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
98746 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
98747 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
98748 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
98749 +lm3533_als_get_target_reg_37881 lm3533_als_get_target_reg 0-1-2 37881 NULL
98750 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
98751 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
98752 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
98753 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
98754 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
98755 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
98756 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
98757 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
98758 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
98759 +vfs_readv_38011 vfs_readv 3 38011 NULL
98760 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
98761 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
98762 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
98763 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL
98764 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
98765 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
98766 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
98767 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
98768 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
98769 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
98770 +ep0_read_38095 ep0_read 3 38095 NULL
98771 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
98772 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
98773 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
98774 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
98775 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
98776 +cdev_add_38176 cdev_add 2-3 38176 NULL
98777 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
98778 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
98779 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
98780 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
98781 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
98782 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
98783 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
98784 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
98785 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
98786 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
98787 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
98788 +verity_status_38273 verity_status 5 38273 NULL
98789 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
98790 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
98791 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
98792 +ieee80211_send_probe_req_38307 ieee80211_send_probe_req 6-4 38307 NULL
98793 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
98794 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
98795 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
98796 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
98797 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
98798 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
98799 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
98800 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
98801 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
98802 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
98803 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
98804 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
98805 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
98806 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
98807 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
98808 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
98809 +dev_names_read_38509 dev_names_read 3 38509 NULL
98810 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
98811 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
98812 +set_queue_count_38519 set_queue_count 0 38519 NULL
98813 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
98814 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
98815 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
98816 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
98817 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
98818 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
98819 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
98820 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
98821 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
98822 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
98823 +delay_status_38606 delay_status 5 38606 NULL
98824 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
98825 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
98826 +cma_create_area_38642 cma_create_area 2 38642 NULL
98827 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
98828 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
98829 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
98830 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
98831 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
98832 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
98833 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
98834 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
98835 +udf_readpages_38761 udf_readpages 4 38761 NULL
98836 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
98837 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
98838 +err_decode_38804 err_decode 2 38804 NULL
98839 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
98840 +sys_select_38827 sys_select 1 38827 NULL
98841 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
98842 +direct_entry_38836 direct_entry 3 38836 NULL
98843 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
98844 +interfaces_38859 interfaces 2 38859 NULL
98845 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
98846 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
98847 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
98848 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
98849 +__fswab16_38898 __fswab16 0 38898 NULL
98850 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
98851 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
98852 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
98853 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
98854 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
98855 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
98856 +udf_new_block_38999 udf_new_block 4 38999 NULL
98857 +get_nodes_39012 get_nodes 3 39012 NULL
98858 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
98859 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
98860 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
98861 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
98862 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
98863 +tun_get_user_39099 tun_get_user 4 39099 NULL
98864 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
98865 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
98866 +ea_foreach_39133 ea_foreach 0 39133 NULL
98867 +generic_permission_39150 generic_permission 0 39150 NULL
98868 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
98869 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
98870 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
98871 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
98872 +init_list_set_39188 init_list_set 2-3 39188 NULL
98873 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
98874 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
98875 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
98876 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
98877 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
98878 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
98879 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
98880 +drm_order_39244 drm_order 0 39244 NULL
98881 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
98882 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
98883 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
98884 +__skb_cow_39254 __skb_cow 2 39254 NULL
98885 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
98886 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
98887 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
98888 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
98889 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
98890 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
98891 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
98892 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
98893 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
98894 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
98895 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
98896 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
98897 +__send_to_port_39386 __send_to_port 3 39386 NULL
98898 +user_power_read_39414 user_power_read 3 39414 NULL
98899 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
98900 +sys_semop_39457 sys_semop 3 39457 NULL
98901 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
98902 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
98903 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
98904 +int_proc_write_39542 int_proc_write 3 39542 NULL
98905 +pp_write_39554 pp_write 3 39554 NULL
98906 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
98907 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
98908 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
98909 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
98910 +adau1373_set_pll_39593 adau1373_set_pll 2 39593 NULL
98911 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
98912 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
98913 +ext_depth_39607 ext_depth 0 39607 NULL
98914 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
98915 +sdio_readb_39618 sdio_readb 0 39618 NULL
98916 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
98917 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
98918 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
98919 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
98920 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
98921 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
98922 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
98923 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
98924 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
98925 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
98926 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
98927 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
98928 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
98929 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
98930 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
98931 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
98932 +pkt_add_39897 pkt_add 3 39897 NULL
98933 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
98934 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
98935 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
98936 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
98937 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
98938 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
98939 +__spi_async_39932 __spi_async 0 39932 NULL
98940 +__get_order_39935 __get_order 0 39935 NULL
98941 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
98942 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
98943 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
98944 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
98945 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
98946 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
98947 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
98948 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
98949 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
98950 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
98951 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
98952 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
98953 +add_tty_40055 add_tty 1 40055 NULL nohasharray
98954 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
98955 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
98956 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
98957 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
98958 +rbd_do_op_40128 rbd_do_op 4-5 40128 NULL
98959 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
98960 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
98961 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
98962 +pt_write_40159 pt_write 3 40159 NULL
98963 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
98964 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
98965 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
98966 +allocate_probes_40204 allocate_probes 1 40204 NULL
98967 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
98968 +compat_put_long_40214 compat_put_long 1 40214 NULL
98969 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
98970 +xfs_buf_read_map_40226 xfs_buf_read_map 3 40226 NULL
98971 +osst_read_40237 osst_read 3 40237 NULL
98972 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
98973 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
98974 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
98975 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
98976 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
98977 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
98978 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
98979 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
98980 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
98981 +mmio_read_40348 mmio_read 4 40348 NULL
98982 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
98983 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
98984 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
98985 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
98986 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
98987 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
98988 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
98989 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
98990 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
98991 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
98992 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
98993 +tty_write_room_40495 tty_write_room 0 40495 NULL
98994 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
98995 +sg_phys_40507 sg_phys 0 40507 NULL
98996 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
98997 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
98998 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
98999 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99000 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99001 +arch_setup_hpet_msi_40584 arch_setup_hpet_msi 1 40584 NULL
99002 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99003 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99004 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99005 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99006 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99007 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99008 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99009 +fops_read_40672 fops_read 3 40672 NULL
99010 +tps80031_write_40678 tps80031_write 3 40678 NULL
99011 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99012 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99013 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99014 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99015 +tps65910_irq_map_40748 tps65910_irq_map 2 40748 NULL
99016 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99017 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99018 +card_send_command_40757 card_send_command 3 40757 NULL
99019 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99020 +pg_write_40766 pg_write 3 40766 NULL
99021 +show_list_40775 show_list 3 40775 NULL
99022 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99023 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99024 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99025 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99026 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99027 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99028 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99029 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99030 +read_file_queue_40895 read_file_queue 3 40895 NULL
99031 +waiters_read_40902 waiters_read 3 40902 NULL
99032 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99033 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99034 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99035 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99036 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99037 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99038 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99039 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
99040 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99041 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99042 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99043 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99044 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99045 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99046 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99047 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99048 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99049 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99050 +dma_attach_41094 dma_attach 5-6 41094 NULL
99051 +provide_user_output_41105 provide_user_output 3 41105 NULL
99052 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99053 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99054 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99055 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99056 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99057 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99058 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99059 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99060 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99061 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99062 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99063 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99064 +erst_read_41260 erst_read 0 41260 NULL
99065 +__fprog_create_41263 __fprog_create 2 41263 NULL
99066 +alloc_context_41283 alloc_context 1 41283 NULL
99067 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99068 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99069 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99070 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99071 +kmp_init_41373 kmp_init 2 41373 NULL
99072 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99073 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99074 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99075 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99076 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99077 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99078 +ext4_trim_extent_41436 ext4_trim_extent 4 41436 NULL
99079 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99080 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99081 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99082 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99083 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
99084 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99085 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99086 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99087 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99088 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99089 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99090 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99091 +gserial_setup_41558 gserial_setup 2 41558 NULL
99092 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99093 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99094 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99095 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99096 +vga_io_r_41609 vga_io_r 0 41609 NULL
99097 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99098 +a2mp_send_41615 a2mp_send 4 41615 NULL
99099 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99100 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99101 +get_std_timing_41654 get_std_timing 0 41654 NULL
99102 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99103 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99104 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99105 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99106 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99107 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99108 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99109 +fillonedir_41746 fillonedir 3 41746 NULL
99110 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99111 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99112 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99113 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99114 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99115 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99116 +irq_data_to_status_reg_41854 irq_data_to_status_reg 0 41854 NULL
99117 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99118 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99119 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99120 +ceph_get_direct_page_vector_41917 ceph_get_direct_page_vector 2 41917 NULL
99121 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99122 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99123 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99124 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99125 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99126 +portnames_read_41958 portnames_read 3 41958 NULL
99127 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99128 +dst_mtu_41969 dst_mtu 0 41969 NULL
99129 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99130 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99131 +lguest_map_42008 lguest_map 1-2 42008 NULL
99132 +pool_allocate_42012 pool_allocate 3 42012 NULL
99133 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99134 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99135 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99136 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99137 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99138 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99139 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99140 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99141 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99142 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99143 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99144 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL
99145 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99146 +v9fs_alloc_rdir_buf_42150 v9fs_alloc_rdir_buf 2 42150 NULL
99147 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99148 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99149 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99150 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99151 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99152 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99153 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99154 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99155 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99156 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99157 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99158 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99159 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99160 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99161 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
99162 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99163 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99164 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99165 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99166 +krng_get_random_42420 krng_get_random 3 42420 NULL
99167 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99168 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99169 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99170 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99171 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99172 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99173 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99174 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99175 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99176 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99177 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99178 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99179 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99180 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99181 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99182 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99183 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99184 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99185 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99186 +map_state_42602 map_state 1 42602 NULL nohasharray
99187 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99188 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99189 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99190 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99191 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99192 +_regmap_raw_write_42652 _regmap_raw_write 4-2 42652 NULL
99193 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99194 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99195 +vb2_read_42703 vb2_read 3 42703 NULL
99196 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99197 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99198 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99199 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99200 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99201 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99202 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99203 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99204 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99205 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99206 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99207 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99208 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99209 +set_arg_42824 set_arg 3 42824 NULL
99210 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99211 +xfs_buf_read_uncached_42844 xfs_buf_read_uncached 3 42844 NULL
99212 +prandom_u32_42853 prandom_u32 0 42853 NULL
99213 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99214 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99215 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99216 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99217 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99218 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99219 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99220 +hd_end_request_42904 hd_end_request 2 42904 NULL
99221 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99222 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99223 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99224 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99225 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99226 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99227 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99228 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99229 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99230 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99231 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99232 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99233 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99234 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99235 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99236 +uuid_string_43154 uuid_string 0 43154 NULL
99237 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99238 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99239 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99240 +process_measurement_43190 process_measurement 0 43190 NULL
99241 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99242 +uio_write_43202 uio_write 3 43202 NULL
99243 +iso_callback_43208 iso_callback 3 43208 NULL
99244 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99245 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99246 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99247 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99248 +fixup_leb_43256 fixup_leb 3 43256 NULL
99249 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99250 +evtchn_write_43278 evtchn_write 3 43278 NULL
99251 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99252 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99253 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99254 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99255 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99256 +xenfb_write_43412 xenfb_write 3 43412 NULL
99257 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 NULL nohasharray
99258 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 &gdm_wimax_netif_rx_43423
99259 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99260 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99261 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99262 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99263 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99264 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99265 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99266 +do_readlink_43518 do_readlink 2 43518 NULL
99267 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99268 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99269 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99270 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99271 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99272 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99273 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99274 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99275 +proc_read_43614 proc_read 3 43614 NULL
99276 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99277 +tps65217_set_bits_43659 tps65217_set_bits 2 43659 NULL nohasharray
99278 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 &tps65217_set_bits_43659
99279 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99280 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99281 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99282 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
99283 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99284 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99285 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99286 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99287 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99288 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99289 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99290 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99291 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99292 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99293 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99294 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99295 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99296 +read_flush_43851 read_flush 3 43851 NULL
99297 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99298 +pm860x_bulk_write_43875 pm860x_bulk_write 3-2 43875 NULL
99299 +ec_dbgfs_cmd_write_43895 ec_dbgfs_cmd_write 3 43895 NULL
99300 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99301 +SendString_43928 SendString 3 43928 NULL
99302 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99303 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99304 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99305 +nla_reserve_43984 nla_reserve 3 43984 NULL
99306 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99307 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99308 +emit_flags_44006 emit_flags 4-3 44006 NULL
99309 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99310 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99311 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99312 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99313 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99314 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99315 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99316 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99317 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99318 +__set_free_44211 __set_free 2 44211 NULL
99319 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99320 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99321 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99322 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99323 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99324 +enlarge_skb_44248 enlarge_skb 2 44248 NULL nohasharray
99325 +xfs_buf_readahead_map_44248 xfs_buf_readahead_map 3 44248 &enlarge_skb_44248
99326 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99327 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99328 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99329 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
99330 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99331 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99332 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99333 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99334 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99335 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99336 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99337 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99338 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99339 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99340 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99341 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99342 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99343 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99344 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99345 +spidev_write_44510 spidev_write 3 44510 NULL
99346 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99347 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99348 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
99349 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
99350 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99351 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99352 +wm5100_gpio_set_44602 wm5100_gpio_set 2 44602 NULL
99353 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99354 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99355 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99356 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99357 +mpi_resize_44674 mpi_resize 2 44674 NULL
99358 +ts_read_44687 ts_read 3 44687 NULL
99359 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99360 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99361 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
99362 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
99363 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
99364 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
99365 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
99366 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
99367 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
99368 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
99369 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
99370 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
99371 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
99372 +sisusb_write_44834 sisusb_write 3 44834 NULL
99373 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
99374 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
99375 +skb_availroom_44883 skb_availroom 0 44883 NULL
99376 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
99377 +do_tty_write_44896 do_tty_write 5 44896 NULL
99378 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
99379 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
99380 +max77693_write_reg_45004 max77693_write_reg 2 45004 NULL
99381 +ftdi_process_packet_45005 ftdi_process_packet 5 45005 NULL
99382 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
99383 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
99384 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
99385 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
99386 +sel_write_user_45060 sel_write_user 3 45060 NULL
99387 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
99388 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
99389 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
99390 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
99391 +usbdev_read_45114 usbdev_read 3 45114 NULL
99392 +send_to_tty_45141 send_to_tty 3 45141 NULL
99393 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
99394 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
99395 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
99396 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
99397 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
99398 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
99399 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
99400 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
99401 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
99402 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
99403 +add_child_45201 add_child 4 45201 NULL
99404 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
99405 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
99406 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
99407 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
99408 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
99409 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
99410 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
99411 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
99412 +keymap_store_45406 keymap_store 4 45406 NULL
99413 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 NULL
99414 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
99415 +do_mmap_pgoff_45441 do_mmap_pgoff 0 45441 NULL
99416 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
99417 +__node_remap_45458 __node_remap 4 45458 NULL
99418 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
99419 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
99420 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
99421 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
99422 +arizona_init_fll_45503 arizona_init_fll 4-5 45503 NULL
99423 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
99424 +clone_bio_45516 clone_bio 6 45516 NULL
99425 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
99426 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
99427 +copy_macs_45534 copy_macs 4 45534 NULL
99428 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
99429 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
99430 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
99431 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
99432 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
99433 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
99434 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
99435 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
99436 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
99437 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
99438 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
99439 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
99440 +da9052_gpio_set_45643 da9052_gpio_set 2 45643 NULL
99441 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
99442 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
99443 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
99444 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
99445 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
99446 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
99447 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
99448 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
99449 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
99450 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
99451 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
99452 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
99453 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
99454 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
99455 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
99456 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
99457 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
99458 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
99459 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
99460 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
99461 +amthi_read_45831 amthi_read 4 45831 NULL
99462 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
99463 +isdn_write_45863 isdn_write 3 45863 NULL
99464 +rbd_get_num_segments_45864 rbd_get_num_segments 0-2-3 45864 NULL
99465 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
99466 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
99467 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
99468 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
99469 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
99470 +alloc_mr_45935 alloc_mr 1 45935 NULL
99471 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
99472 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
99473 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
99474 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
99475 +get_free_entries_46030 get_free_entries 1 46030 NULL
99476 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
99477 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
99478 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
99479 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
99480 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
99481 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
99482 +slhc_toss_46066 slhc_toss 0 46066 NULL
99483 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
99484 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
99485 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
99486 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
99487 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
99488 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
99489 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
99490 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
99491 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
99492 +qlcnic_alloc_msix_entries_46160 qlcnic_alloc_msix_entries 2 46160 NULL
99493 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
99494 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
99495 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
99496 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
99497 +dsp_write_46218 dsp_write 2 46218 NULL
99498 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
99499 +__le64_to_cpup_46257 __le64_to_cpup 0 46257 NULL
99500 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
99501 +ReadReg_46277 ReadReg 0 46277 NULL
99502 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
99503 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
99504 +twl6040_write_46351 twl6040_write 2 46351 NULL
99505 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
99506 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
99507 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
99508 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
99509 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
99510 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
99511 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
99512 +filldir64_46469 filldir64 3 46469 NULL
99513 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
99514 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
99515 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
99516 +kmsg_read_46514 kmsg_read 3 46514 NULL
99517 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
99518 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
99519 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
99520 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
99521 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
99522 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
99523 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
99524 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
99525 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
99526 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
99527 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
99528 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
99529 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
99530 +aircable_process_packet_46639 aircable_process_packet 5 46639 NULL
99531 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
99532 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
99533 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
99534 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
99535 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
99536 +prepare_copy_46725 prepare_copy 2 46725 NULL
99537 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
99538 +ext4_count_free_46754 ext4_count_free 2 46754 NULL
99539 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
99540 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
99541 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
99542 +scrub_chunk_46789 scrub_chunk 4 46789 NULL
99543 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
99544 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
99545 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
99546 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
99547 +ieee80211_rx_radiotap_len_46846 ieee80211_rx_radiotap_len 0 46846 NULL
99548 +spi_async_46857 spi_async 0 46857 NULL
99549 +ieee80211_mgmt_tx_46860 ieee80211_mgmt_tx 9 46860 NULL
99550 +vsnprintf_46863 vsnprintf 0 46863 NULL
99551 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
99552 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
99553 +rvmalloc_46873 rvmalloc 1 46873 NULL
99554 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
99555 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
99556 +em28xx_alloc_isoc_46892 em28xx_alloc_isoc 4 46892 NULL
99557 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
99558 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
99559 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
99560 +fb_write_46924 fb_write 3 46924 NULL
99561 +raid_status_46930 raid_status 5 46930 NULL
99562 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
99563 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
99564 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
99565 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
99566 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
99567 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
99568 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
99569 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
99570 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
99571 +__map_single_47020 __map_single 3-4-7 47020 NULL
99572 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
99573 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
99574 +wm8994_set_bits_47052 wm8994_set_bits 2 47052 NULL
99575 +fs_path_len_47060 fs_path_len 0 47060 NULL
99576 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
99577 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
99578 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
99579 +mousedev_read_47123 mousedev_read 3 47123 NULL
99580 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
99581 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
99582 +cxio_init_resource_fifo_random_47151 cxio_init_resource_fifo_random 3 47151 NULL
99583 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
99584 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
99585 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
99586 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
99587 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
99588 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
99589 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
99590 +wm8903_gpio_direction_in_47213 wm8903_gpio_direction_in 2 47213 NULL
99591 +l2headersize_47238 l2headersize 0 47238 NULL
99592 +options_write_47243 options_write 3 47243 NULL
99593 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
99594 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
99595 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
99596 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
99597 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
99598 +vsnprintf_47291 vsnprintf 0 47291 NULL
99599 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
99600 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
99601 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
99602 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
99603 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
99604 +trace_options_core_read_47390 trace_options_core_read 3 47390 NULL
99605 +nametbl_list_47391 nametbl_list 2 47391 NULL
99606 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
99607 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
99608 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
99609 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
99610 +vzalloc_47421 vzalloc 1 47421 NULL
99611 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
99612 +newpart_47485 newpart 6 47485 NULL
99613 +core_sys_select_47494 core_sys_select 1 47494 NULL
99614 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
99615 +unlink_simple_47506 unlink_simple 3 47506 NULL
99616 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
99617 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
99618 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
99619 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
99620 +oz_events_read_47535 oz_events_read 3 47535 NULL
99621 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
99622 +cycx_setup_47562 cycx_setup 4 47562 NULL
99623 +read_ldt_47570 read_ldt 2 47570 NULL
99624 +pci_iomap_47575 pci_iomap 3 47575 NULL
99625 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
99626 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
99627 +wm831x_gpio_direction_out_47607 wm831x_gpio_direction_out 2 47607 NULL
99628 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
99629 +uea_request_47613 uea_request 4 47613 NULL
99630 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
99631 +tps65217_clear_bits_47619 tps65217_clear_bits 2 47619 NULL
99632 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
99633 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
99634 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
99635 +irq_linear_revmap_47682 irq_linear_revmap 0 47682 NULL
99636 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
99637 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
99638 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
99639 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
99640 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
99641 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
99642 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
99643 +irq_domain_legacy_revmap_47765 irq_domain_legacy_revmap 0-2 47765 NULL
99644 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
99645 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
99646 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
99647 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
99648 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
99649 +__pcf50633_irq_mask_set_47847 __pcf50633_irq_mask_set 2 47847 NULL
99650 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
99651 +vhci_read_47878 vhci_read 3 47878 NULL
99652 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
99653 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
99654 +timeout_read_47915 timeout_read 3 47915 NULL
99655 +comedi_write_47926 comedi_write 3 47926 NULL
99656 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
99657 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
99658 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
99659 +pnpacpi_parse_allocated_irqresource_47986 pnpacpi_parse_allocated_irqresource 2 47986 NULL
99660 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
99661 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
99662 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
99663 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
99664 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
99665 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
99666 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
99667 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
99668 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
99669 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
99670 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
99671 +rtsx_read_cfg_seq_48139 rtsx_read_cfg_seq 5-3 48139 NULL
99672 +set_discoverable_48141 set_discoverable 4 48141 NULL
99673 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
99674 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
99675 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
99676 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
99677 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
99678 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
99679 +init_ipath_48187 init_ipath 1 48187 NULL nohasharray
99680 +ieee80211_send_auth_48187 ieee80211_send_auth 6 48187 &init_ipath_48187
99681 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
99682 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
99683 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
99684 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
99685 +read_file_recv_48232 read_file_recv 3 48232 NULL
99686 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
99687 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
99688 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
99689 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
99690 +send_set_info_48288 send_set_info 7 48288 NULL
99691 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
99692 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
99693 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
99694 +hash_setkey_48310 hash_setkey 3 48310 NULL
99695 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
99696 +skb_add_data_48363 skb_add_data 3 48363 NULL
99697 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
99698 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
99699 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
99700 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
99701 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
99702 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
99703 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
99704 +send_control_msg_48498 send_control_msg 6 48498 NULL
99705 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
99706 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
99707 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
99708 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
99709 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
99710 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
99711 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
99712 +named_distribute_48544 named_distribute 4 48544 NULL
99713 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
99714 +ext_sd_execute_read_data_48589 ext_sd_execute_read_data 9 48589 NULL
99715 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
99716 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
99717 +mtd_read_48655 mtd_read 0 48655 NULL
99718 +lc_create_48662 lc_create 3 48662 NULL
99719 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
99720 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
99721 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
99722 +altera_drscan_48698 altera_drscan 2 48698 NULL
99723 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
99724 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
99725 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
99726 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
99727 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
99728 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
99729 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
99730 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
99731 +azx_get_position_48841 azx_get_position 0 48841 NULL
99732 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
99733 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
99734 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
99735 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
99736 +get_num_ops_48886 get_num_ops 0 48886 NULL
99737 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
99738 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
99739 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
99740 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
99741 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL nohasharray
99742 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 &gdth_isa_probe_one_48925
99743 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
99744 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
99745 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
99746 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
99747 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
99748 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
99749 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
99750 +xd_rw_49020 xd_rw 3-4 49020 NULL
99751 +transient_status_49027 transient_status 4 49027 NULL
99752 +ubi_read_49061 ubi_read 0 49061 NULL
99753 +tps65910_reg_write_49066 tps65910_reg_write 2 49066 NULL
99754 +calc_layout_49074 calc_layout 4 49074 NULL
99755 +vmx_set_msr_49090 vmx_set_msr 3 49090 NULL
99756 +scsi_register_49094 scsi_register 2 49094 NULL
99757 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
99758 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
99759 +pt_read_49136 pt_read 3 49136 NULL
99760 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
99761 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
99762 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
99763 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
99764 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
99765 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
99766 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
99767 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
99768 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
99769 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
99770 +pcf50633_gpio_invert_set_49256 pcf50633_gpio_invert_set 2 49256 NULL
99771 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
99772 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
99773 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
99774 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
99775 +uio_read_49300 uio_read 3 49300 NULL
99776 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
99777 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
99778 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
99779 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
99780 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
99781 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
99782 +px_raw_event_49371 px_raw_event 4 49371 NULL
99783 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
99784 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
99785 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
99786 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
99787 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
99788 +md_domain_init_49432 md_domain_init 2 49432 NULL
99789 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
99790 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
99791 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
99792 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
99793 +ieee80211_ie_split_49474 ieee80211_ie_split 0-5 49474 NULL
99794 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
99795 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
99796 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
99797 +wm831x_dcdc_set_mode_int_49546 wm831x_dcdc_set_mode_int 2 49546 NULL
99798 +smk_write_access_49561 smk_write_access 3 49561 NULL
99799 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
99800 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
99801 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
99802 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
99803 +heap_init_49617 heap_init 2 49617 NULL
99804 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
99805 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
99806 +svm_set_msr_49643 svm_set_msr 3 49643 NULL
99807 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
99808 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
99809 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
99810 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
99811 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
99812 +check_frame_49741 check_frame 0 49741 NULL
99813 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
99814 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
99815 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
99816 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
99817 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
99818 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
99819 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
99820 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
99821 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
99822 +add_uuid_49831 add_uuid 4 49831 NULL
99823 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
99824 +__btrfs_map_block_49839 __btrfs_map_block 3 49839 NULL
99825 +twl4030_write_49846 twl4030_write 2 49846 NULL
99826 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
99827 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
99828 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
99829 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
99830 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
99831 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
99832 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
99833 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
99834 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
99835 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
99836 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
99837 +__module_alloc_50004 __module_alloc 1 50004 NULL
99838 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
99839 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
99840 +isdn_read_50021 isdn_read 3 50021 NULL
99841 +rbd_req_write_50041 rbd_req_write 4-5 50041 NULL
99842 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
99843 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
99844 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
99845 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
99846 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
99847 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
99848 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
99849 +read_file_slot_50111 read_file_slot 3 50111 NULL
99850 +copy_items_50140 copy_items 6 50140 NULL
99851 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
99852 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
99853 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
99854 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
99855 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
99856 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
99857 +odev_update_50169 odev_update 2 50169 NULL
99858 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
99859 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
99860 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
99861 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
99862 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
99863 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
99864 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
99865 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
99866 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
99867 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
99868 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
99869 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
99870 +do_launder_page_50329 do_launder_page 0 50329 NULL
99871 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
99872 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
99873 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
99874 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
99875 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
99876 +tpm_read_50344 tpm_read 3 50344 NULL
99877 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
99878 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
99879 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
99880 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
99881 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
99882 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
99883 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
99884 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
99885 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
99886 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
99887 +tps65217_update_bits_50472 tps65217_update_bits 2 50472 NULL
99888 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
99889 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
99890 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
99891 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
99892 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
99893 +pcf50633_reg_set_bit_mask_50544 pcf50633_reg_set_bit_mask 2 50544 NULL
99894 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
99895 +fat_readpages_50582 fat_readpages 4 50582 NULL
99896 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
99897 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
99898 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
99899 +__ffs_50625 __ffs 0 50625 NULL
99900 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
99901 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
99902 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
99903 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
99904 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
99905 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
99906 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
99907 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
99908 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
99909 +skb_padto_50759 skb_padto 2 50759 NULL
99910 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
99911 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
99912 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
99913 +tpm_write_50798 tpm_write 3 50798 NULL
99914 +tun_do_read_50800 tun_do_read 4 50800 NULL
99915 +write_flush_50803 write_flush 3 50803 NULL
99916 +dvb_play_50814 dvb_play 3 50814 NULL
99917 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
99918 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
99919 +pstore_mkfile_50830 pstore_mkfile 5 50830 NULL
99920 +dma_attach_50831 dma_attach 6-7 50831 NULL
99921 +SetArea_50835 SetArea 4 50835 NULL nohasharray
99922 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
99923 +self_check_write_50856 self_check_write 5 50856 NULL
99924 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
99925 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
99926 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
99927 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
99928 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
99929 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
99930 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
99931 +sock_bindtodevice_50942 sock_bindtodevice 3 50942 NULL
99932 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
99933 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
99934 +timeout_write_50991 timeout_write 3 50991 NULL
99935 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL nohasharray
99936 +wm8903_gpio_direction_out_50995 wm8903_gpio_direction_out 2 50995 &wm831x_irq_map_50995
99937 +proc_write_51003 proc_write 3 51003 NULL
99938 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
99939 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
99940 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
99941 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
99942 +dump_midi_51040 dump_midi 3 51040 NULL
99943 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
99944 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
99945 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
99946 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
99947 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
99948 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
99949 +lm3533_als_get_current_51120 lm3533_als_get_current 2 51120 NULL
99950 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
99951 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
99952 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
99953 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
99954 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
99955 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
99956 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
99957 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
99958 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
99959 +tipc_send_51238 tipc_send 4 51238 NULL
99960 +drm_property_create_51239 drm_property_create 4 51239 NULL
99961 +st_read_51251 st_read 3 51251 NULL
99962 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
99963 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
99964 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
99965 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
99966 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
99967 +fd_do_readv_51297 fd_do_readv 3 51297 NULL
99968 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
99969 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
99970 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
99971 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
99972 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
99973 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
99974 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
99975 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
99976 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
99977 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
99978 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
99979 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
99980 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
99981 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
99982 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
99983 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
99984 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
99985 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
99986 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
99987 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
99988 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
99989 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
99990 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
99991 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
99992 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
99993 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
99994 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
99995 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
99996 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
99997 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
99998 +sel_write_access_51704 sel_write_access 3 51704 NULL
99999 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100000 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100001 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100002 +msg_set_51725 msg_set 3 51725 NULL
100003 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
100004 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100005 +get_user_pages_fast_51751 get_user_pages_fast 0 51751 NULL
100006 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100007 +if_write_51756 if_write 3 51756 NULL
100008 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100009 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100010 +__fswab32_51781 __fswab32 0 51781 NULL
100011 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100012 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100013 +wm2000_write_51834 wm2000_write 2 51834 NULL
100014 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100015 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100016 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100017 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100018 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100019 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100020 +user_read_51881 user_read 3 51881 NULL
100021 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100022 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100023 +iio_read_first_n_sw_rb_51911 iio_read_first_n_sw_rb 2 51911 NULL
100024 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100025 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100026 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100027 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100028 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100029 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100030 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100031 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100032 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100033 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
100034 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100035 +rdmalt_52022 rdmalt 0 52022 NULL
100036 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100037 +override_release_52032 override_release 2 52032 NULL
100038 +end_port_52042 end_port 0 52042 NULL
100039 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100040 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100041 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100042 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100043 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100044 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100045 +retry_count_read_52129 retry_count_read 3 52129 NULL
100046 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
100047 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100048 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100049 +htable_size_52148 htable_size 0-1 52148 NULL
100050 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100051 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100052 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100053 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100054 +print_prefix_52176 print_prefix 0 52176 NULL
100055 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100056 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100057 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100058 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100059 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100060 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100061 +mpol_to_str_52293 mpol_to_str 2 52293 NULL
100062 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100063 +read_file_reset_52310 read_file_reset 3 52310 NULL
100064 +ssd1307fb_write_52315 ssd1307fb_write 3 52315 NULL
100065 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100066 +hwflags_read_52318 hwflags_read 3 52318 NULL
100067 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
100068 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100069 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100070 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100071 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100072 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
100073 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100074 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100075 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100076 +pcf50633_reg_clear_bits_52407 pcf50633_reg_clear_bits 2 52407 NULL
100077 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100078 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100079 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100080 +delay_status_52431 delay_status 5 52431 NULL
100081 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100082 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100083 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100084 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100085 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100086 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100087 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100088 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100089 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100090 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100091 +emit_code_52583 emit_code 0-3 52583 NULL
100092 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
100093 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100094 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
100095 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100096 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100097 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100098 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100099 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100100 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100101 +alloc_extent_buffer_52824 alloc_extent_buffer 3 52824 NULL
100102 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100103 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100104 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100105 +twlreg_write_52880 twlreg_write 3 52880 NULL
100106 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100107 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100108 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100109 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100110 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100111 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100112 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100113 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100114 +send_packet_52960 send_packet 4 52960 NULL
100115 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100116 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 NULL
100117 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100118 +num_node_state_52989 num_node_state 0 52989 NULL
100119 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100120 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100121 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100122 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100123 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100124 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100125 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100126 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100127 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100128 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100129 +verity_status_53120 verity_status 5 53120 NULL
100130 +line6_dumpreq_initbuf_53123 line6_dumpreq_initbuf 3 53123 NULL
100131 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100132 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100133 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100134 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100135 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100136 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100137 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100138 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100139 +lirc_buffer_init_53282 lirc_buffer_init 3-2 53282 NULL
100140 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100141 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100142 +vm_mmap_53339 vm_mmap 0 53339 NULL
100143 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100144 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100145 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100146 +wm8996_gpio_set_53421 wm8996_gpio_set 2 53421 NULL
100147 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100148 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100149 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100150 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100151 +n2_run_53459 n2_run 3 53459 NULL
100152 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100153 +wm831x_write_53469 wm831x_write 2 53469 NULL
100154 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100155 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100156 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100157 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100158 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100159 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100160 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100161 +check_acl_53512 check_acl 0 53512 NULL
100162 +set_registers_53582 set_registers 3 53582 NULL
100163 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100164 +__readw_53594 __readw 0 53594 NULL
100165 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
100166 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100167 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100168 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100169 +_preload_range_53676 _preload_range 2-3 53676 NULL
100170 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100171 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100172 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 NULL nohasharray
100173 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
100174 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100175 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100176 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100177 +wdm_write_53735 wdm_write 3 53735 NULL
100178 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100179 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100180 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100181 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100182 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100183 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100184 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100185 +regmap_raw_write_53803 regmap_raw_write 4-2 53803 NULL
100186 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100187 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100188 +cpumask_next_zero_53835 cpumask_next_zero 1 53835 NULL
100189 +pms_read_53873 pms_read 3 53873 NULL
100190 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100191 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100192 +proc_file_read_53905 proc_file_read 3 53905 NULL
100193 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
100194 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100195 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100196 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100197 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100198 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100199 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100200 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100201 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100202 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100203 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100204 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100205 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100206 +_malloc_54077 _malloc 1 54077 NULL
100207 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100208 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100209 +create_xattr_54106 create_xattr 5 54106 NULL
100210 +strn_len_54122 strn_len 0 54122 NULL
100211 +isku_receive_54130 isku_receive 4 54130 NULL
100212 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100213 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100214 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100215 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100216 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100217 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100218 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100219 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100220 +reada_add_block_54247 reada_add_block 2 54247 NULL
100221 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100222 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100223 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100224 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100225 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100226 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100227 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100228 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100229 +sprintf_54306 sprintf 0 54306 NULL
100230 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100231 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100232 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100233 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100234 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100235 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100236 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100237 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100238 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100239 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100240 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100241 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100242 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100243 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100244 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100245 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100246 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100247 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100248 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
100249 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100250 +viacam_read_54526 viacam_read 3 54526 NULL
100251 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100252 +setsockopt_54539 setsockopt 5 54539 NULL
100253 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100254 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100255 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100256 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100257 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100258 +irq_of_parse_and_map_54646 irq_of_parse_and_map 0 54646 NULL
100259 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100260 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100261 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100262 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100263 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100264 +evm_read_key_54674 evm_read_key 3 54674 NULL
100265 +resource_string_54699 resource_string 0 54699 NULL
100266 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100267 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100268 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100269 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100270 +kzalloc_54740 kzalloc 1 54740 NULL
100271 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100272 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100273 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100274 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100275 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100276 +domain_init_54797 domain_init 2 54797 NULL
100277 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100278 +nfsd_write_54809 nfsd_write 6 54809 NULL
100279 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100280 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100281 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100282 +write_rio_54837 write_rio 3 54837 NULL
100283 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100284 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100285 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100286 +printer_read_54851 printer_read 3 54851 NULL
100287 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100288 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100289 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100290 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100291 +lm3533_led_get_lv_reg_54900 lm3533_led_get_lv_reg 0-2 54900 NULL
100292 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100293 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100294 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100295 +add_port_54941 add_port 2 54941 NULL
100296 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100297 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100298 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100299 +c4_add_card_54968 c4_add_card 3 54968 NULL
100300 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100301 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100302 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100303 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
100304 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100305 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100306 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100307 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100308 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100309 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL
100310 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100311 +corrupt_data_55120 corrupt_data 0 55120 NULL
100312 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100313 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100314 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100315 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100316 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100317 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100318 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100319 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100320 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL nohasharray
100321 +pcf50633_gpio_set_55209 pcf50633_gpio_set 2 55209 &ht40allow_map_read_55209
100322 +ssd1307fb_write_cmd_array_55211 ssd1307fb_write_cmd_array 3 55211 NULL nohasharray
100323 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 &ssd1307fb_write_cmd_array_55211
100324 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100325 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100326 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100327 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100328 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100329 +ptrace_request_55288 ptrace_request 3 55288 NULL
100330 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100331 +rbd_create_rw_ops_55297 rbd_create_rw_ops 1 55297 NULL
100332 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100333 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 NULL
100334 +vme_user_read_55338 vme_user_read 3 55338 NULL
100335 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100336 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100337 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100338 +__send_to_port_55383 __send_to_port 3 55383 NULL
100339 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100340 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100341 +alloc_skb_55439 alloc_skb 1 55439 NULL
100342 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100343 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100344 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100345 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100346 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100347 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100348 +wm5100_gpio_direction_out_55497 wm5100_gpio_direction_out 2 55497 NULL
100349 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100350 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100351 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100352 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100353 +ea_get_55522 ea_get 0 55522 NULL
100354 +buffer_size_55534 buffer_size 0 55534 NULL
100355 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100356 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100357 +add_partition_55588 add_partition 2 55588 NULL
100358 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100359 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
100360 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
100361 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
100362 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
100363 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
100364 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
100365 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
100366 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
100367 +read_oldmem_55658 read_oldmem 3 55658 NULL
100368 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
100369 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
100370 +get_info_55681 get_info 3 55681 NULL
100371 +arizona_gpio_direction_in_55690 arizona_gpio_direction_in 2 55690 NULL
100372 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
100373 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
100374 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
100375 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
100376 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 3-2 55738 NULL
100377 +set_local_name_55757 set_local_name 4 55757 NULL
100378 +btrfs_init_new_buffer_55761 btrfs_init_new_buffer 4 55761 NULL
100379 +strlen_55778 strlen 0 55778 NULL nohasharray
100380 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
100381 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
100382 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
100383 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
100384 +btrfs_find_create_tree_block_55812 btrfs_find_create_tree_block 3 55812 NULL
100385 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
100386 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
100387 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
100388 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
100389 +hsc_write_55875 hsc_write 3 55875 NULL
100390 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
100391 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
100392 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
100393 +handle_response_55951 handle_response 5 55951 NULL
100394 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
100395 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
100396 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
100397 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
100398 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
100399 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
100400 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
100401 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
100402 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
100403 +map_addr_56144 map_addr 7 56144 NULL
100404 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
100405 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
100406 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
100407 +skb_headroom_56200 skb_headroom 0 56200 NULL
100408 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
100409 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
100410 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
100411 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
100412 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
100413 +scrub_setup_recheck_block_56245 scrub_setup_recheck_block 4-3 56245 NULL
100414 +fd_copyin_56247 fd_copyin 3 56247 NULL
100415 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
100416 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
100417 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
100418 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
100419 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
100420 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
100421 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
100422 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
100423 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
100424 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
100425 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
100426 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
100427 +tps80031_ext_power_req_config_56353 tps80031_ext_power_req_config 3-4-5 56353 NULL
100428 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
100429 +dev_read_56369 dev_read 3 56369 NULL
100430 +alloc_dummy_extent_buffer_56374 alloc_dummy_extent_buffer 2 56374 NULL
100431 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
100432 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
100433 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
100434 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
100435 +store_msg_56417 store_msg 3 56417 NULL
100436 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
100437 +ec_dbgfs_cmd_read_56431 ec_dbgfs_cmd_read 3 56431 NULL
100438 +fl_create_56435 fl_create 5 56435 NULL
100439 +gnttab_map_56439 gnttab_map 2 56439 NULL
100440 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
100441 +set_connectable_56458 set_connectable 4 56458 NULL
100442 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
100443 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
100444 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
100445 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
100446 +ip_options_get_56538 ip_options_get 4 56538 NULL
100447 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
100448 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
100449 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
100450 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
100451 +event_filter_write_56609 event_filter_write 3 56609 NULL
100452 +gather_array_56641 gather_array 3 56641 NULL
100453 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
100454 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
100455 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
100456 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
100457 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
100458 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
100459 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
100460 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
100461 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
100462 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
100463 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
100464 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
100465 +do_syslog_56807 do_syslog 3 56807 NULL
100466 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
100467 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
100468 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
100469 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
100470 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
100471 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
100472 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
100473 +strcspn_56913 strcspn 0 56913 NULL
100474 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
100475 +check_header_56930 check_header 2 56930 NULL
100476 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
100477 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
100478 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
100479 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
100480 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
100481 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
100482 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
100483 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
100484 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
100485 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
100486 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
100487 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
100488 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
100489 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
100490 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
100491 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
100492 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
100493 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
100494 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
100495 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
100496 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
100497 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
100498 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
100499 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
100500 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
100501 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
100502 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
100503 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
100504 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
100505 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
100506 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
100507 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
100508 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
100509 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
100510 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
100511 +fw_file_size_57307 fw_file_size 0 57307 NULL
100512 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
100513 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
100514 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
100515 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
100516 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
100517 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
100518 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
100519 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
100520 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
100521 +read_file_blob_57406 read_file_blob 3 57406 NULL
100522 +enclosure_register_57412 enclosure_register 3 57412 NULL
100523 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
100524 +wm831x_gpio_set_debounce_57428 wm831x_gpio_set_debounce 2 57428 NULL
100525 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
100526 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
100527 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
100528 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
100529 +ReadReg_57453 ReadReg 0 57453 NULL
100530 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
100531 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
100532 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
100533 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
100534 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
100535 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
100536 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
100537 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
100538 +skb_headlen_57501 skb_headlen 0 57501 NULL
100539 +copy_in_user_57502 copy_in_user 3 57502 NULL
100540 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
100541 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
100542 +init_tag_map_57515 init_tag_map 3 57515 NULL
100543 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
100544 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
100545 +inode_permission_57531 inode_permission 0 57531 NULL
100546 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
100547 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
100548 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
100549 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
100550 +lp8788_update_bits_57600 lp8788_update_bits 2 57600 NULL
100551 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
100552 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
100553 +tps65217_reg_write_57623 tps65217_reg_write 2 57623 NULL nohasharray
100554 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 &tps65217_reg_write_57623
100555 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
100556 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
100557 +mem_read_57631 mem_read 3 57631 NULL
100558 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
100559 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
100560 +r3964_write_57662 r3964_write 4 57662 NULL
100561 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
100562 +__lgwrite_57669 __lgwrite 4 57669 NULL
100563 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
100564 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
100565 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
100566 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
100567 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
100568 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
100569 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
100570 +ld2_57794 ld2 0 57794 NULL
100571 +ivtv_read_57796 ivtv_read 3 57796 NULL
100572 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
100573 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
100574 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
100575 +copy_to_user_57835 copy_to_user 3 57835 NULL
100576 +flash_read_57843 flash_read 3 57843 NULL
100577 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
100578 +ad5380_info_to_reg_57905 ad5380_info_to_reg 0 57905 NULL
100579 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
100580 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
100581 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
100582 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
100583 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
100584 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
100585 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
100586 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
100587 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
100588 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
100589 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
100590 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
100591 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
100592 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
100593 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
100594 +mc13783_write_58033 mc13783_write 2 58033 NULL
100595 +mce_async_out_58056 mce_async_out 3 58056 NULL
100596 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
100597 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
100598 +cm4040_write_58079 cm4040_write 3 58079 NULL
100599 +udi_log_event_58105 udi_log_event 3 58105 NULL
100600 +savemem_58129 savemem 3 58129 NULL
100601 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
100602 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
100603 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
100604 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
100605 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
100606 +btrfs_mksubvol_58240 btrfs_mksubvol 3 58240 NULL
100607 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
100608 +read_file_debug_58256 read_file_debug 3 58256 NULL
100609 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
100610 +profile_load_58267 profile_load 3 58267 NULL
100611 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
100612 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
100613 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
100614 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
100615 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
100616 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
100617 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
100618 +ieee80211_send_probe_req_58337 ieee80211_send_probe_req 4-6 58337 NULL
100619 +next_pidmap_58347 next_pidmap 2 58347 NULL
100620 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
100621 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
100622 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
100623 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
100624 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
100625 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
100626 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
100627 +capabilities_read_58457 capabilities_read 3 58457 NULL
100628 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
100629 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
100630 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
100631 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
100632 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
100633 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
100634 +wm831x_reg_write_58489 wm831x_reg_write 2 58489 NULL
100635 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
100636 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
100637 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
100638 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
100639 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
100640 +xip_file_read_58592 xip_file_read 3 58592 NULL
100641 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
100642 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
100643 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
100644 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
100645 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
100646 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
100647 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
100648 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
100649 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
100650 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
100651 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
100652 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
100653 +acpi_map_58725 acpi_map 1-2 58725 NULL
100654 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
100655 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
100656 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
100657 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
100658 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
100659 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
100660 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
100661 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
100662 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
100663 +ep_read_58813 ep_read 3 58813 NULL
100664 +command_write_58841 command_write 3 58841 NULL
100665 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
100666 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
100667 +hw_write_58881 hw_write 2 58881 NULL
100668 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
100669 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
100670 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
100671 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
100672 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
100673 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
100674 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
100675 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
100676 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
100677 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
100678 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
100679 +ep_write_59008 ep_write 3 59008 NULL
100680 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
100681 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
100682 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
100683 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
100684 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
100685 +da9052_gpio_direction_input_59062 da9052_gpio_direction_input 2 59062 NULL
100686 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
100687 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
100688 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
100689 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
100690 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
100691 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
100692 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
100693 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
100694 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
100695 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
100696 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
100697 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
100698 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
100699 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
100700 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
100701 +dt3155_read_59226 dt3155_read 3 59226 NULL
100702 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
100703 +rbd_do_request_59239 rbd_do_request 6-7 59239 NULL
100704 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
100705 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
100706 +nla_len_59258 nla_len 0 59258 NULL
100707 +da9055_reg_update_59280 da9055_reg_update 2 59280 NULL
100708 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
100709 +fd_copyout_59323 fd_copyout 3 59323 NULL
100710 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
100711 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
100712 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 NULL
100713 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
100714 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
100715 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
100716 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
100717 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
100718 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
100719 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
100720 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
100721 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
100722 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
100723 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
100724 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
100725 +rds_pin_pages_59507 rds_pin_pages 0 59507 NULL
100726 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
100727 +tunables_write_59563 tunables_write 3 59563 NULL
100728 +memdup_user_59590 memdup_user 2 59590 NULL
100729 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
100730 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
100731 +mtrr_write_59622 mtrr_write 3 59622 NULL
100732 +ip_vs_icmp_xmit_59624 ip_vs_icmp_xmit 4 59624 NULL
100733 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
100734 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
100735 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
100736 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
100737 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
100738 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
100739 +wm8400_write_59675 wm8400_write 2 59675 NULL
100740 +sriov_enable_59689 sriov_enable 2 59689 NULL
100741 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
100742 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
100743 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
100744 +wm8996_gpio_direction_in_59739 wm8996_gpio_direction_in 2 59739 NULL
100745 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
100746 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
100747 +strnlen_59746 strnlen 0 59746 NULL
100748 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
100749 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
100750 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
100751 +sec_reg_update_59771 sec_reg_update 2 59771 NULL
100752 +venus_remove_59781 venus_remove 4 59781 NULL
100753 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
100754 +ipw_write_59807 ipw_write 3 59807 NULL
100755 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
100756 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
100757 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
100758 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
100759 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
100760 +tun_put_user_59849 tun_put_user 4 59849 NULL
100761 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
100762 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
100763 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
100764 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
100765 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
100766 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 NULL nohasharray
100767 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 &compat_ipmi_ioctl_59956
100768 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
100769 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
100770 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
100771 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
100772 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
100773 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
100774 +register_device_60015 register_device 2-3 60015 NULL
100775 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
100776 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
100777 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
100778 +ceph_calc_raw_layout_60035 ceph_calc_raw_layout 4 60035 NULL
100779 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
100780 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
100781 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
100782 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
100783 +load_module_60056 load_module 2 60056 NULL nohasharray
100784 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 &load_module_60056
100785 +compat_writev_60063 compat_writev 3 60063 NULL
100786 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 8-6 60064 NULL
100787 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
100788 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
100789 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
100790 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
100791 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
100792 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
100793 +init_state_60165 init_state 2 60165 NULL
100794 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
100795 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
100796 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
100797 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
100798 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
100799 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
100800 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
100801 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
100802 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
100803 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL
100804 +lp8788_select_buck_vout_addr_60241 lp8788_select_buck_vout_addr 0 60241 NULL
100805 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
100806 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
100807 +printer_write_60276 printer_write 3 60276 NULL
100808 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
100809 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
100810 +getDataLength_60301 getDataLength 0 60301 NULL
100811 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
100812 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
100813 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
100814 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
100815 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
100816 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
100817 +driver_names_read_60399 driver_names_read 3 60399 NULL
100818 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
100819 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
100820 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
100821 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
100822 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
100823 +rx_data_60442 rx_data 4 60442 NULL
100824 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
100825 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
100826 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
100827 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
100828 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
100829 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
100830 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
100831 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
100832 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
100833 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
100834 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
100835 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
100836 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
100837 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
100838 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
100839 +init_data_container_60709 init_data_container 1 60709 NULL
100840 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
100841 +raid_status_60755 raid_status 5 60755 NULL
100842 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
100843 +opticon_write_60775 opticon_write 4 60775 NULL
100844 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
100845 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
100846 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
100847 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
100848 +alloc_irq_from_60868 alloc_irq_from 1 60868 NULL
100849 +generic_writepages_60871 generic_writepages 0 60871 NULL
100850 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
100851 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
100852 +wm8962_gpio_set_60894 wm8962_gpio_set 2 60894 NULL
100853 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
100854 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
100855 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
100856 +pti_char_write_60960 pti_char_write 3 60960 NULL
100857 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
100858 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
100859 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
100860 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
100861 +symtab_init_61050 symtab_init 2 61050 NULL
100862 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
100863 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
100864 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
100865 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
100866 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
100867 +get_derived_key_61100 get_derived_key 4 61100 NULL
100868 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
100869 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
100870 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
100871 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
100872 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
100873 +__vmalloc_61168 __vmalloc 1 61168 NULL
100874 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
100875 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
100876 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
100877 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
100878 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
100879 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
100880 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
100881 +sys_add_key_61288 sys_add_key 4 61288 NULL
100882 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
100883 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
100884 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
100885 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
100886 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
100887 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
100888 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
100889 +change_xattr_61390 change_xattr 5 61390 NULL
100890 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
100891 +irq_create_of_mapping_61428 irq_create_of_mapping 0 61428 NULL
100892 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
100893 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
100894 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
100895 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
100896 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
100897 +mc13xxx_reg_write_61490 mc13xxx_reg_write 2 61490 NULL
100898 +erst_errno_61526 erst_errno 0 61526 NULL
100899 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
100900 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
100901 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
100902 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
100903 +seq_open_private_61589 seq_open_private 3 61589 NULL
100904 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
100905 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
100906 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
100907 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
100908 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
100909 +ieee80211_rx_bss_info_61630 ieee80211_rx_bss_info 3 61630 NULL
100910 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
100911 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
100912 +resize_stripes_61650 resize_stripes 2 61650 NULL
100913 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
100914 +insert_one_name_61668 insert_one_name 7 61668 NULL
100915 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
100916 +lock_loop_61681 lock_loop 1 61681 NULL
100917 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
100918 +filter_read_61692 filter_read 3 61692 NULL
100919 +iov_length_61716 iov_length 0 61716 NULL
100920 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
100921 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
100922 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
100923 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
100924 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
100925 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
100926 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
100927 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
100928 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
100929 +get_fw_name_61874 get_fw_name 3 61874 NULL
100930 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
100931 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
100932 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
100933 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
100934 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
100935 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
100936 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
100937 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
100938 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
100939 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
100940 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
100941 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
100942 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
100943 +cow_file_range_61979 cow_file_range 3 61979 NULL
100944 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
100945 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
100946 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
100947 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
100948 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
100949 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
100950 +do_pselect_62061 do_pselect 1 62061 NULL
100951 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
100952 +__next_gcwq_cpu_62078 __next_gcwq_cpu 1 62078 NULL
100953 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
100954 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
100955 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
100956 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
100957 +ql_status_62135 ql_status 5 62135 NULL
100958 +video_usercopy_62151 video_usercopy 2 62151 NULL
100959 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
100960 +_irq_to_addr_62183 _irq_to_addr 0-1 62183 NULL
100961 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
100962 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
100963 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
100964 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
100965 +allocate_partition_62245 allocate_partition 4 62245 NULL
100966 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
100967 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
100968 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
100969 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
100970 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
100971 +subseq_list_62332 subseq_list 3-0 62332 NULL
100972 +flash_write_62354 flash_write 3 62354 NULL
100973 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
100974 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
100975 +altera_irscan_62396 altera_irscan 2 62396 NULL
100976 +set_ssp_62411 set_ssp 4 62411 NULL
100977 +tscadc_writel_62426 tscadc_writel 2 62426 NULL
100978 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
100979 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
100980 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
100981 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
100982 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
100983 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
100984 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
100985 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
100986 +debugfs_read_62535 debugfs_read 3 62535 NULL
100987 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
100988 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
100989 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
100990 +get_subdir_62581 get_subdir 3 62581 NULL
100991 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
100992 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
100993 +get_desc_base_62617 get_desc_base 0 62617 NULL
100994 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
100995 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
100996 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
100997 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
100998 +wm8994_gpio_direction_in_62649 wm8994_gpio_direction_in 2 62649 NULL
100999 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101000 +write_62671 write 3 62671 NULL
101001 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101002 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101003 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101004 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101005 +rdm_62719 rdm 0 62719 NULL
101006 +key_replays_read_62746 key_replays_read 3 62746 NULL
101007 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101008 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101009 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101010 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101011 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101012 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101013 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101014 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101015 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101016 +aoechr_write_62883 aoechr_write 3 62883 NULL nohasharray
101017 +em28xx_init_isoc_62883 em28xx_init_isoc 4 62883 &aoechr_write_62883
101018 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101019 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101020 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101021 +getdqbuf_62908 getdqbuf 1 62908 NULL
101022 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101023 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
101024 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
101025 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101026 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101027 +unlink1_63059 unlink1 3 63059 NULL
101028 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101029 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101030 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101031 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101032 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101033 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
101034 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
101035 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101036 +vme_master_read_63221 vme_master_read 0 63221 NULL
101037 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101038 +ptp_read_63251 ptp_read 4 63251 NULL
101039 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
101040 +raid5_resize_63306 raid5_resize 2 63306 NULL
101041 +proc_info_read_63344 proc_info_read 3 63344 NULL
101042 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101043 +idmouse_read_63374 idmouse_read 3 63374 NULL
101044 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101045 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101046 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101047 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101048 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101049 +kone_send_63435 kone_send 4 63435 NULL
101050 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101051 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101052 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101053 +read_kcore_63488 read_kcore 3 63488 NULL
101054 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101055 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101056 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101057 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101058 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101059 +kvm_write_guest_page_63555 kvm_write_guest_page 5 63555 &dbg_leb_write_63555
101060 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101061 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101062 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101063 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101064 +module_alloc_63630 module_alloc 1 63630 NULL
101065 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101066 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101067 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101068 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101069 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101070 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101071 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101072 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101073 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101074 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101075 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101076 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101077 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101078 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101079 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101080 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
101081 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101082 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101083 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101084 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101085 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101086 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101087 +sel_write_load_63830 sel_write_load 3 63830 NULL
101088 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101089 +ieee80211_if_fmt_channel_type_63855 ieee80211_if_fmt_channel_type 3 63855 NULL
101090 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101091 +divas_write_63901 divas_write 3 63901 NULL
101092 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101093 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101094 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101095 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101096 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101097 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101098 +__team_options_register_63941 __team_options_register 3 63941 NULL
101099 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101100 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101101 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101102 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101103 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101104 +kmemdup_64015 kmemdup 2 64015 NULL
101105 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 NULL
101106 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101107 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101108 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101109 +get_u8_64076 get_u8 0 64076 NULL
101110 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101111 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101112 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101113 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101114 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101115 +init_bch_64130 init_bch 1-2 64130 NULL
101116 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101117 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101118 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101119 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101120 +read_pulse_64227 read_pulse 0-3 64227 NULL
101121 +header_len_64232 header_len 0 64232 NULL
101122 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101123 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101124 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101125 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101126 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101127 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101128 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101129 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101130 +ffz_64324 ffz 0 64324 NULL
101131 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101132 +ts_write_64336 ts_write 3 64336 NULL
101133 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101134 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101135 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101136 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101137 +ilo_write_64378 ilo_write 3 64378 NULL
101138 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101139 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101140 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101141 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101142 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101143 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101144 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101145 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101146 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101147 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL
101148 +ieee80211_ie_build_ht_cap_64443 ieee80211_ie_build_ht_cap 0 64443 NULL
101149 +cap_capable_64462 cap_capable 0 64462 NULL
101150 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101151 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101152 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101153 +remove_uuid_64505 remove_uuid 4 64505 NULL
101154 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101155 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101156 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101157 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101158 +__spi_sync_64561 __spi_sync 0 64561 NULL
101159 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101160 +fanotify_write_64623 fanotify_write 3 64623 NULL
101161 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101162 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101163 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101164 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101165 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101166 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101167 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101168 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101169 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101170 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101171 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101172 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101173 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101174 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101175 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101176 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101177 +twl6040_reg_write_64790 twl6040_reg_write 2 64790 NULL
101178 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101179 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101180 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101181 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101182 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101183 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101184 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101185 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101186 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101187 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101188 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101189 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101190 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101191 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101192 +pskb_pull_65005 pskb_pull 2 65005 NULL
101193 +unifi_write_65012 unifi_write 3 65012 NULL
101194 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101195 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101196 +insert_dent_65034 insert_dent 7 65034 NULL
101197 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101198 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101199 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101200 +make_idx_node_65068 make_idx_node 0 65068 NULL
101201 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101202 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101203 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
101204 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101205 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101206 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101207 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101208 +print_endpoint_stat_65232 print_endpoint_stat 0-4-3 65232 NULL
101209 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101210 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101211 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101212 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101213 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
101214 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101215 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101216 +get_var_len_65304 get_var_len 0 65304 NULL
101217 +unpack_array_65318 unpack_array 0 65318 NULL
101218 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101219 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101220 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101221 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101222 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101223 +strchr_65372 strchr 0 65372 NULL
101224 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
101225 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101226 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101227 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101228 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101229 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101230 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101231 +pn533_init_target_frame_65438 pn533_init_target_frame 3 65438 NULL
101232 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101233 +regmap_write_65478 regmap_write 2 65478 NULL
101234 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101235 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101236 +alloc_dr_65495 alloc_dr 2 65495 NULL
101237 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101238 new file mode 100644
101239 index 0000000..9db0d0e
101240 --- /dev/null
101241 +++ b/tools/gcc/size_overflow_plugin.c
101242 @@ -0,0 +1,2114 @@
101243 +/*
101244 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101245 + * Licensed under the GPL v2, or (at your option) v3
101246 + *
101247 + * Homepage:
101248 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101249 + *
101250 + * Documentation:
101251 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101252 + *
101253 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101254 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101255 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101256 + *
101257 + * Usage:
101258 + * $ 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
101259 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101260 + */
101261 +
101262 +#include "gcc-plugin.h"
101263 +#include "config.h"
101264 +#include "system.h"
101265 +#include "coretypes.h"
101266 +#include "tree.h"
101267 +#include "tree-pass.h"
101268 +#include "intl.h"
101269 +#include "plugin-version.h"
101270 +#include "tm.h"
101271 +#include "toplev.h"
101272 +#include "function.h"
101273 +#include "tree-flow.h"
101274 +#include "plugin.h"
101275 +#include "gimple.h"
101276 +#include "diagnostic.h"
101277 +#include "cfgloop.h"
101278 +
101279 +#if BUILDING_GCC_VERSION >= 4008
101280 +#define TODO_dump_func 0
101281 +#endif
101282 +
101283 +struct size_overflow_hash {
101284 + const struct size_overflow_hash * const next;
101285 + const char * const name;
101286 + const unsigned int param;
101287 +};
101288 +
101289 +#include "size_overflow_hash.h"
101290 +
101291 +enum mark {
101292 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101293 +};
101294 +
101295 +enum err_code_conditions {
101296 + CAST_ONLY, FROM_CONST
101297 +};
101298 +
101299 +static unsigned int call_count = 0;
101300 +
101301 +#define __unused __attribute__((__unused__))
101302 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101303 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101304 +#define BEFORE_STMT true
101305 +#define AFTER_STMT false
101306 +#define CREATE_NEW_VAR NULL_TREE
101307 +#define CODES_LIMIT 32
101308 +#define MAX_PARAM 31
101309 +#define MY_STMT GF_PLF_1
101310 +#define NO_CAST_CHECK GF_PLF_2
101311 +#define FROM_ARG true
101312 +#define FROM_RET false
101313 +
101314 +#if BUILDING_GCC_VERSION == 4005
101315 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101316 +#endif
101317 +
101318 +int plugin_is_GPL_compatible;
101319 +void debug_gimple_stmt(gimple gs);
101320 +
101321 +static tree expand(struct pointer_set_t *visited, tree lhs);
101322 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101323 +static tree report_size_overflow_decl;
101324 +static const_tree const_char_ptr_type_node;
101325 +static unsigned int handle_function(void);
101326 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101327 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101328 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101329 +static void print_missing_msg(tree func, unsigned int argnum);
101330 +
101331 +static struct plugin_info size_overflow_plugin_info = {
101332 + .version = "20130410beta",
101333 + .help = "no-size-overflow\tturn off size overflow checking\n",
101334 +};
101335 +
101336 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101337 +{
101338 + unsigned int arg_count;
101339 + enum tree_code code = TREE_CODE(*node);
101340 +
101341 + switch (code) {
101342 + case FUNCTION_DECL:
101343 + arg_count = type_num_arguments(TREE_TYPE(*node));
101344 + break;
101345 + case FUNCTION_TYPE:
101346 + case METHOD_TYPE:
101347 + arg_count = type_num_arguments(*node);
101348 + break;
101349 + default:
101350 + *no_add_attrs = true;
101351 + error("%s: %qE attribute only applies to functions", __func__, name);
101352 + return NULL_TREE;
101353 + }
101354 +
101355 + for (; args; args = TREE_CHAIN(args)) {
101356 + tree position = TREE_VALUE(args);
101357 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101358 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101359 + *no_add_attrs = true;
101360 + }
101361 + }
101362 + return NULL_TREE;
101363 +}
101364 +
101365 +static const char* get_asm_name(tree node)
101366 +{
101367 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
101368 +}
101369 +
101370 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101371 +{
101372 + unsigned int arg_count, arg_num;
101373 + enum tree_code code = TREE_CODE(*node);
101374 +
101375 + switch (code) {
101376 + case FUNCTION_DECL:
101377 + arg_count = type_num_arguments(TREE_TYPE(*node));
101378 + break;
101379 + case FUNCTION_TYPE:
101380 + case METHOD_TYPE:
101381 + arg_count = type_num_arguments(*node);
101382 + break;
101383 + case FIELD_DECL:
101384 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
101385 + if (arg_num != 0) {
101386 + *no_add_attrs = true;
101387 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
101388 + }
101389 + return NULL_TREE;
101390 + default:
101391 + *no_add_attrs = true;
101392 + error("%qE attribute only applies to functions", name);
101393 + return NULL_TREE;
101394 + }
101395 +
101396 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
101397 + return NULL_TREE;
101398 +
101399 + for (; args; args = TREE_CHAIN(args)) {
101400 + tree position = TREE_VALUE(args);
101401 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
101402 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
101403 + *no_add_attrs = true;
101404 + }
101405 + }
101406 + return NULL_TREE;
101407 +}
101408 +
101409 +static struct attribute_spec size_overflow_attr = {
101410 + .name = "size_overflow",
101411 + .min_length = 1,
101412 + .max_length = -1,
101413 + .decl_required = true,
101414 + .type_required = false,
101415 + .function_type_required = false,
101416 + .handler = handle_size_overflow_attribute,
101417 +#if BUILDING_GCC_VERSION >= 4007
101418 + .affects_type_identity = false
101419 +#endif
101420 +};
101421 +
101422 +static struct attribute_spec intentional_overflow_attr = {
101423 + .name = "intentional_overflow",
101424 + .min_length = 1,
101425 + .max_length = -1,
101426 + .decl_required = true,
101427 + .type_required = false,
101428 + .function_type_required = false,
101429 + .handler = handle_intentional_overflow_attribute,
101430 +#if BUILDING_GCC_VERSION >= 4007
101431 + .affects_type_identity = false
101432 +#endif
101433 +};
101434 +
101435 +static void register_attributes(void __unused *event_data, void __unused *data)
101436 +{
101437 + register_attribute(&size_overflow_attr);
101438 + register_attribute(&intentional_overflow_attr);
101439 +}
101440 +
101441 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
101442 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
101443 +{
101444 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
101445 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
101446 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
101447 +
101448 + unsigned int m = 0x57559429;
101449 + unsigned int n = 0x5052acdb;
101450 + const unsigned int *key4 = (const unsigned int *)key;
101451 + unsigned int h = len;
101452 + unsigned int k = len + seed + n;
101453 + unsigned long long p;
101454 +
101455 + while (len >= 8) {
101456 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
101457 + len -= 8;
101458 + }
101459 + if (len >= 4) {
101460 + cwmixb(key4[0]) key4 += 1;
101461 + len -= 4;
101462 + }
101463 + if (len)
101464 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
101465 + cwmixb(h ^ (k + n));
101466 + return k ^ h;
101467 +
101468 +#undef cwfold
101469 +#undef cwmixa
101470 +#undef cwmixb
101471 +}
101472 +
101473 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
101474 +{
101475 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
101476 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
101477 + return fn ^ codes;
101478 +}
101479 +
101480 +static inline tree get_original_function_decl(tree fndecl)
101481 +{
101482 + if (DECL_ABSTRACT_ORIGIN(fndecl))
101483 + return DECL_ABSTRACT_ORIGIN(fndecl);
101484 + return fndecl;
101485 +}
101486 +
101487 +static inline gimple get_def_stmt(const_tree node)
101488 +{
101489 + gcc_assert(node != NULL_TREE);
101490 + if (TREE_CODE(node) != SSA_NAME)
101491 + return NULL;
101492 + return SSA_NAME_DEF_STMT(node);
101493 +}
101494 +
101495 +static unsigned char get_tree_code(const_tree type)
101496 +{
101497 + switch (TREE_CODE(type)) {
101498 + case ARRAY_TYPE:
101499 + return 0;
101500 + case BOOLEAN_TYPE:
101501 + return 1;
101502 + case ENUMERAL_TYPE:
101503 + return 2;
101504 + case FUNCTION_TYPE:
101505 + return 3;
101506 + case INTEGER_TYPE:
101507 + return 4;
101508 + case POINTER_TYPE:
101509 + return 5;
101510 + case RECORD_TYPE:
101511 + return 6;
101512 + case UNION_TYPE:
101513 + return 7;
101514 + case VOID_TYPE:
101515 + return 8;
101516 + case REAL_TYPE:
101517 + return 9;
101518 + case VECTOR_TYPE:
101519 + return 10;
101520 + case REFERENCE_TYPE:
101521 + return 11;
101522 + case OFFSET_TYPE:
101523 + return 12;
101524 + case COMPLEX_TYPE:
101525 + return 13;
101526 + default:
101527 + debug_tree((tree)type);
101528 + gcc_unreachable();
101529 + }
101530 +}
101531 +
101532 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
101533 +{
101534 + gcc_assert(type != NULL_TREE);
101535 +
101536 + while (type && len < CODES_LIMIT) {
101537 + tree_codes[len] = get_tree_code(type);
101538 + len++;
101539 + type = TREE_TYPE(type);
101540 + }
101541 + return len;
101542 +}
101543 +
101544 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
101545 +{
101546 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
101547 + enum tree_code code = TREE_CODE(type);
101548 + size_t len = 0;
101549 +
101550 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
101551 +
101552 + arg = TYPE_ARG_TYPES(type);
101553 + // skip builtins __builtin_constant_p
101554 + if (!arg && DECL_BUILT_IN(fndecl))
101555 + return 0;
101556 +
101557 + if (TREE_CODE_CLASS(code) == tcc_type)
101558 + result = type;
101559 + else
101560 + result = DECL_RESULT(fndecl);
101561 +
101562 + gcc_assert(result != NULL_TREE);
101563 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
101564 +
101565 + if (arg == NULL_TREE) {
101566 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
101567 + arg_field = DECL_ARGUMENT_FLD(fndecl);
101568 + if (arg_field == NULL_TREE)
101569 + return 0;
101570 + arg = TREE_TYPE(arg_field);
101571 + len = add_type_codes(arg, tree_codes, len);
101572 + gcc_assert(len != 0);
101573 + return len;
101574 + }
101575 +
101576 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
101577 + while (arg && len < CODES_LIMIT) {
101578 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
101579 + arg = TREE_CHAIN(arg);
101580 + }
101581 +
101582 + gcc_assert(len != 0);
101583 + return len;
101584 +}
101585 +
101586 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
101587 +{
101588 + unsigned int hash;
101589 + const struct size_overflow_hash *entry;
101590 + unsigned char tree_codes[CODES_LIMIT];
101591 + size_t len;
101592 + const char *func_name;
101593 +
101594 + fndecl = get_original_function_decl(fndecl);
101595 + len = get_function_decl(fndecl, tree_codes);
101596 + if (len == 0)
101597 + return NULL;
101598 +
101599 + func_name = get_asm_name(fndecl);
101600 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
101601 +
101602 + entry = size_overflow_hash[hash];
101603 + while (entry) {
101604 + if (!strcmp(entry->name, func_name))
101605 + return entry;
101606 + entry = entry->next;
101607 + }
101608 +
101609 + return NULL;
101610 +}
101611 +
101612 +static bool is_bool(const_tree node)
101613 +{
101614 + const_tree type;
101615 +
101616 + if (node == NULL_TREE)
101617 + return false;
101618 +
101619 + type = TREE_TYPE(node);
101620 + if (!INTEGRAL_TYPE_P(type))
101621 + return false;
101622 + if (TREE_CODE(type) == BOOLEAN_TYPE)
101623 + return true;
101624 + if (TYPE_PRECISION(type) == 1)
101625 + return true;
101626 + return false;
101627 +}
101628 +
101629 +static bool skip_types(const_tree var)
101630 +{
101631 + tree type;
101632 +
101633 + if (is_gimple_constant(var))
101634 + return true;
101635 +
101636 + switch (TREE_CODE(var)) {
101637 + case ADDR_EXPR:
101638 +#if BUILDING_GCC_VERSION >= 4006
101639 + case MEM_REF:
101640 +#endif
101641 + case ARRAY_REF:
101642 + case BIT_FIELD_REF:
101643 + case INDIRECT_REF:
101644 + case TARGET_MEM_REF:
101645 + return true;
101646 + case PARM_DECL:
101647 + case VAR_DECL:
101648 + case COMPONENT_REF:
101649 + return false;
101650 + default:
101651 + break;
101652 + }
101653 +
101654 + gcc_assert(TREE_CODE(var) == SSA_NAME);
101655 +
101656 + type = TREE_TYPE(var);
101657 + switch (TREE_CODE(type)) {
101658 + case INTEGER_TYPE:
101659 + case ENUMERAL_TYPE:
101660 + return false;
101661 + case BOOLEAN_TYPE:
101662 + return is_bool(var);
101663 + default:
101664 + break;
101665 + }
101666 +
101667 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
101668 +
101669 + type = TREE_TYPE(type);
101670 + gcc_assert(type != NULL_TREE);
101671 + switch (TREE_CODE(type)) {
101672 + case RECORD_TYPE:
101673 + case POINTER_TYPE:
101674 + case ARRAY_TYPE:
101675 + return true;
101676 + case VOID_TYPE:
101677 + case INTEGER_TYPE:
101678 + case UNION_TYPE:
101679 + return false;
101680 + default:
101681 + break;
101682 + }
101683 +
101684 + debug_tree((tree)var);
101685 + gcc_unreachable();
101686 +}
101687 +
101688 +static unsigned int find_arg_number(const_tree arg, tree func)
101689 +{
101690 + tree var;
101691 + unsigned int argnum = 1;
101692 +
101693 + if (TREE_CODE(arg) == SSA_NAME)
101694 + arg = SSA_NAME_VAR(arg);
101695 +
101696 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
101697 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
101698 + continue;
101699 + if (!skip_types(var))
101700 + return argnum;
101701 + }
101702 +
101703 + return 0;
101704 +}
101705 +
101706 +static tree create_new_var(tree type)
101707 +{
101708 + tree new_var = create_tmp_var(type, "cicus");
101709 +
101710 +#if BUILDING_GCC_VERSION <= 4007
101711 + add_referenced_var(new_var);
101712 + mark_sym_for_renaming(new_var);
101713 +#endif
101714 + return new_var;
101715 +}
101716 +
101717 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
101718 +{
101719 + gimple assign;
101720 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
101721 + tree type = TREE_TYPE(rhs1);
101722 + tree lhs = create_new_var(type);
101723 +
101724 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
101725 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
101726 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101727 +
101728 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
101729 + update_stmt(assign);
101730 + gimple_set_plf(assign, MY_STMT, true);
101731 + return assign;
101732 +}
101733 +
101734 +static tree cast_a_tree(tree type, tree var)
101735 +{
101736 + gcc_assert(type != NULL_TREE);
101737 + gcc_assert(var != NULL_TREE);
101738 + gcc_assert(fold_convertible_p(type, var));
101739 +
101740 + return fold_convert(type, var);
101741 +}
101742 +
101743 +static tree get_lhs(const_gimple stmt)
101744 +{
101745 + switch (gimple_code(stmt)) {
101746 + case GIMPLE_ASSIGN:
101747 + return gimple_get_lhs(stmt);
101748 + case GIMPLE_PHI:
101749 + return gimple_phi_result(stmt);
101750 + case GIMPLE_CALL:
101751 + return gimple_call_lhs(stmt);
101752 + default:
101753 + return NULL_TREE;
101754 + }
101755 +}
101756 +
101757 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
101758 +{
101759 + const_gimple def_stmt = get_def_stmt(rhs);
101760 +
101761 + if (force)
101762 + return false;
101763 +
101764 + if (is_gimple_constant(rhs))
101765 + return false;
101766 +
101767 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
101768 + return false;
101769 +
101770 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
101771 + return false;
101772 +
101773 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
101774 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
101775 + return false;
101776 +
101777 + return true;
101778 +}
101779 +
101780 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
101781 +{
101782 + gimple assign, def_stmt;
101783 +
101784 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
101785 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
101786 + gcc_unreachable();
101787 +
101788 + def_stmt = get_def_stmt(rhs);
101789 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
101790 + return def_stmt;
101791 +
101792 + if (lhs == CREATE_NEW_VAR)
101793 + lhs = create_new_var(dst_type);
101794 +
101795 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
101796 +
101797 + if (!gsi_end_p(*gsi)) {
101798 + location_t loc = gimple_location(gsi_stmt(*gsi));
101799 + gimple_set_location(assign, loc);
101800 + }
101801 +
101802 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
101803 +
101804 + if (before)
101805 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
101806 + else
101807 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
101808 + update_stmt(assign);
101809 + gimple_set_plf(assign, MY_STMT, true);
101810 +
101811 + return assign;
101812 +}
101813 +
101814 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
101815 +{
101816 + gimple_stmt_iterator gsi;
101817 + tree lhs;
101818 + const_gimple new_stmt;
101819 +
101820 + if (rhs == NULL_TREE)
101821 + return NULL_TREE;
101822 +
101823 + gsi = gsi_for_stmt(stmt);
101824 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
101825 +
101826 + lhs = get_lhs(new_stmt);
101827 + gcc_assert(lhs != NULL_TREE);
101828 + return lhs;
101829 +}
101830 +
101831 +static tree cast_to_TI_type(gimple stmt, tree node)
101832 +{
101833 + gimple_stmt_iterator gsi;
101834 + gimple cast_stmt;
101835 + tree type = TREE_TYPE(node);
101836 +
101837 + if (types_compatible_p(type, intTI_type_node))
101838 + return node;
101839 +
101840 + gsi = gsi_for_stmt(stmt);
101841 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
101842 + return gimple_get_lhs(cast_stmt);
101843 +}
101844 +
101845 +static void check_function_hash(const_gimple stmt)
101846 +{
101847 + tree func;
101848 + const struct size_overflow_hash *hash;
101849 +
101850 + if (gimple_code(stmt) != GIMPLE_CALL)
101851 + return;
101852 +
101853 + func = gimple_call_fndecl(stmt);
101854 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
101855 + if (func == NULL_TREE)
101856 + return;
101857 +
101858 + hash = get_function_hash(func);
101859 + if (!hash)
101860 + print_missing_msg(func, 0);
101861 +}
101862 +
101863 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
101864 +{
101865 + tree lhs, new_lhs;
101866 + gimple_stmt_iterator gsi;
101867 +
101868 + if (rhs1 == NULL_TREE) {
101869 + debug_gimple_stmt(oldstmt);
101870 + error("%s: rhs1 is NULL_TREE", __func__);
101871 + gcc_unreachable();
101872 + }
101873 +
101874 + switch (gimple_code(oldstmt)) {
101875 + case GIMPLE_ASM:
101876 + lhs = rhs1;
101877 + break;
101878 + case GIMPLE_CALL:
101879 + lhs = gimple_call_lhs(oldstmt);
101880 + break;
101881 + case GIMPLE_ASSIGN:
101882 + lhs = gimple_get_lhs(oldstmt);
101883 + break;
101884 + default:
101885 + debug_gimple_stmt(oldstmt);
101886 + gcc_unreachable();
101887 + }
101888 +
101889 + gsi = gsi_for_stmt(oldstmt);
101890 + pointer_set_insert(visited, oldstmt);
101891 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
101892 + basic_block next_bb, cur_bb;
101893 + const_edge e;
101894 +
101895 + gcc_assert(before == false);
101896 + gcc_assert(stmt_can_throw_internal(oldstmt));
101897 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
101898 + gcc_assert(!gsi_end_p(gsi));
101899 +
101900 + cur_bb = gimple_bb(oldstmt);
101901 + next_bb = cur_bb->next_bb;
101902 + e = find_edge(cur_bb, next_bb);
101903 + gcc_assert(e != NULL);
101904 + gcc_assert(e->flags & EDGE_FALLTHRU);
101905 +
101906 + gsi = gsi_after_labels(next_bb);
101907 + gcc_assert(!gsi_end_p(gsi));
101908 +
101909 + before = true;
101910 + oldstmt = gsi_stmt(gsi);
101911 + }
101912 +
101913 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
101914 + return new_lhs;
101915 +}
101916 +
101917 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
101918 +{
101919 + gimple stmt;
101920 + gimple_stmt_iterator gsi;
101921 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
101922 +
101923 + if (gimple_plf(oldstmt, MY_STMT))
101924 + return lhs;
101925 +
101926 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
101927 + rhs1 = gimple_assign_rhs1(oldstmt);
101928 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
101929 + }
101930 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
101931 + rhs2 = gimple_assign_rhs2(oldstmt);
101932 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
101933 + }
101934 +
101935 + stmt = gimple_copy(oldstmt);
101936 + gimple_set_location(stmt, gimple_location(oldstmt));
101937 + gimple_set_plf(stmt, MY_STMT, true);
101938 +
101939 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
101940 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
101941 +
101942 + size_overflow_type = get_size_overflow_type(oldstmt, node);
101943 +
101944 + new_var = create_new_var(size_overflow_type);
101945 + new_var = make_ssa_name(new_var, stmt);
101946 + gimple_set_lhs(stmt, new_var);
101947 +
101948 + if (rhs1 != NULL_TREE)
101949 + gimple_assign_set_rhs1(stmt, rhs1);
101950 +
101951 + if (rhs2 != NULL_TREE)
101952 + gimple_assign_set_rhs2(stmt, rhs2);
101953 +#if BUILDING_GCC_VERSION >= 4007
101954 + if (rhs3 != NULL_TREE)
101955 + gimple_assign_set_rhs3(stmt, rhs3);
101956 +#endif
101957 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
101958 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
101959 +
101960 + gsi = gsi_for_stmt(oldstmt);
101961 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
101962 + update_stmt(stmt);
101963 + pointer_set_insert(visited, oldstmt);
101964 + return gimple_get_lhs(stmt);
101965 +}
101966 +
101967 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
101968 +{
101969 + basic_block first_bb;
101970 + gimple assign;
101971 + gimple_stmt_iterator gsi;
101972 +
101973 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
101974 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
101975 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
101976 +
101977 + gsi = gsi_start_bb(first_bb);
101978 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
101979 + return gimple_get_lhs(assign);
101980 +}
101981 +
101982 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
101983 +{
101984 + gimple_stmt_iterator gsi;
101985 + const_gimple assign;
101986 + gimple def_stmt = get_def_stmt(new_arg);
101987 +
101988 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
101989 + gsi = gsi_after_labels(gimple_bb(def_stmt));
101990 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
101991 + } else {
101992 + gsi = gsi_for_stmt(def_stmt);
101993 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
101994 + }
101995 +
101996 + return gimple_get_lhs(assign);
101997 +}
101998 +
101999 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102000 +{
102001 + basic_block bb;
102002 + gimple_stmt_iterator gsi;
102003 + const_gimple assign, def_stmt;
102004 +
102005 + def_stmt = get_def_stmt(arg);
102006 + bb = gimple_bb(def_stmt);
102007 + gcc_assert(bb->index != 0);
102008 + gsi = gsi_after_labels(bb);
102009 +
102010 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102011 + return gimple_get_lhs(assign);
102012 +}
102013 +
102014 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102015 +{
102016 + tree size_overflow_type;
102017 + const_gimple def_stmt = get_def_stmt(arg);
102018 +
102019 + if (phi_ssa_name != NULL_TREE)
102020 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102021 +
102022 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102023 +
102024 + if (new_arg != NULL_TREE) {
102025 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102026 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102027 + }
102028 +
102029 + switch(gimple_code(def_stmt)) {
102030 + case GIMPLE_PHI:
102031 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102032 + case GIMPLE_NOP:
102033 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102034 + default:
102035 + debug_gimple_stmt((gimple)def_stmt);
102036 + gcc_unreachable();
102037 + }
102038 +}
102039 +
102040 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102041 +{
102042 + basic_block bb;
102043 + gimple phi;
102044 + gimple_seq seq;
102045 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102046 +
102047 + bb = gsi_bb(gsi);
102048 +
102049 + phi = create_phi_node(result, bb);
102050 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102051 + seq = phi_nodes(bb);
102052 + gsi = gsi_last(seq);
102053 + gsi_remove(&gsi, false);
102054 +
102055 + gsi = gsi_for_stmt(oldstmt);
102056 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102057 + gimple_set_bb(phi, bb);
102058 + gimple_set_plf(phi, MY_STMT, true);
102059 + return phi;
102060 +}
102061 +
102062 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102063 +{
102064 + gimple new_phi = NULL;
102065 + gimple oldstmt = get_def_stmt(orig_result);
102066 + tree phi_ssa_name = NULL_TREE;
102067 + unsigned int i;
102068 +
102069 + pointer_set_insert(visited, oldstmt);
102070 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102071 + tree arg, new_arg;
102072 +
102073 + arg = gimple_phi_arg_def(oldstmt, i);
102074 +
102075 + new_arg = expand(visited, arg);
102076 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102077 + if (i == 0) {
102078 + phi_ssa_name = new_arg;
102079 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102080 + }
102081 +
102082 + gcc_assert(new_phi != NULL);
102083 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102084 + }
102085 +
102086 + gcc_assert(new_phi != NULL);
102087 + update_stmt(new_phi);
102088 + return gimple_phi_result(new_phi);
102089 +}
102090 +
102091 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102092 +{
102093 + const_gimple assign;
102094 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102095 + tree origtype = TREE_TYPE(orig_rhs);
102096 +
102097 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102098 +
102099 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102100 + return gimple_get_lhs(assign);
102101 +}
102102 +
102103 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102104 +{
102105 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102106 + enum machine_mode lhs_mode, rhs_mode;
102107 + gimple def_stmt = get_def_stmt(no_const_rhs);
102108 +
102109 + if (!gimple_assign_cast_p(def_stmt))
102110 + return false;
102111 +
102112 + rhs1 = gimple_assign_rhs1(def_stmt);
102113 + lhs = gimple_get_lhs(def_stmt);
102114 + rhs1_type = TREE_TYPE(rhs1);
102115 + lhs_type = TREE_TYPE(lhs);
102116 + rhs_mode = TYPE_MODE(rhs1_type);
102117 + lhs_mode = TYPE_MODE(lhs_type);
102118 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102119 + return false;
102120 +
102121 + return true;
102122 +}
102123 +
102124 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102125 +{
102126 + tree rhs1 = gimple_assign_rhs1(stmt);
102127 + tree lhs = gimple_get_lhs(stmt);
102128 + const_tree rhs1_type = TREE_TYPE(rhs1);
102129 + const_tree lhs_type = TREE_TYPE(lhs);
102130 +
102131 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102132 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102133 +
102134 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102135 +}
102136 +
102137 +static bool no_uses(tree node)
102138 +{
102139 + imm_use_iterator imm_iter;
102140 + use_operand_p use_p;
102141 +
102142 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102143 + const_gimple use_stmt = USE_STMT(use_p);
102144 + if (use_stmt == NULL)
102145 + return true;
102146 + if (is_gimple_debug(use_stmt))
102147 + continue;
102148 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102149 + continue;
102150 + return false;
102151 + }
102152 + return true;
102153 +}
102154 +
102155 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102156 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102157 +{
102158 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102159 + gimple def_stmt = get_def_stmt(lhs);
102160 +
102161 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102162 + return false;
102163 +
102164 + rhs1 = gimple_assign_rhs1(def_stmt);
102165 + rhs_type = TREE_TYPE(rhs1);
102166 + lhs_type = TREE_TYPE(lhs);
102167 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102168 + return false;
102169 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102170 + return false;
102171 +
102172 + def_stmt = get_def_stmt(rhs1);
102173 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102174 + return false;
102175 +
102176 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102177 + return false;
102178 +
102179 + rhs1 = gimple_assign_rhs1(def_stmt);
102180 + rhs2 = gimple_assign_rhs2(def_stmt);
102181 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102182 + return false;
102183 +
102184 + if (is_gimple_constant(rhs2))
102185 + not_const_rhs = rhs1;
102186 + else
102187 + not_const_rhs = rhs2;
102188 +
102189 + return no_uses(not_const_rhs);
102190 +}
102191 +
102192 +static bool skip_lhs_cast_check(const_gimple stmt)
102193 +{
102194 + const_tree rhs = gimple_assign_rhs1(stmt);
102195 + const_gimple def_stmt = get_def_stmt(rhs);
102196 +
102197 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102198 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102199 + return true;
102200 +
102201 + if (is_const_plus_unsigned_signed_truncation(rhs))
102202 + return true;
102203 +
102204 + return false;
102205 +}
102206 +
102207 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102208 +{
102209 + bool cast_lhs, cast_rhs;
102210 + tree lhs = gimple_get_lhs(stmt);
102211 + tree rhs = gimple_assign_rhs1(stmt);
102212 + const_tree lhs_type = TREE_TYPE(lhs);
102213 + const_tree rhs_type = TREE_TYPE(rhs);
102214 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102215 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102216 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102217 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102218 +
102219 + static bool check_lhs[3][4] = {
102220 + // ss su us uu
102221 + { false, true, true, false }, // lhs > rhs
102222 + { false, false, false, false }, // lhs = rhs
102223 + { true, true, true, true }, // lhs < rhs
102224 + };
102225 +
102226 + static bool check_rhs[3][4] = {
102227 + // ss su us uu
102228 + { true, false, true, true }, // lhs > rhs
102229 + { true, false, true, true }, // lhs = rhs
102230 + { true, false, true, true }, // lhs < rhs
102231 + };
102232 +
102233 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102234 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102235 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102236 +
102237 + if (lhs_size > rhs_size) {
102238 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102239 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102240 + } else if (lhs_size == rhs_size) {
102241 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102242 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102243 + } else {
102244 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102245 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102246 + }
102247 +
102248 + if (!cast_lhs && !cast_rhs)
102249 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102250 +
102251 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102252 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102253 +
102254 + if (cast_rhs)
102255 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102256 +
102257 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102258 +}
102259 +
102260 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102261 +{
102262 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102263 +
102264 + if (gimple_plf(stmt, MY_STMT))
102265 + return lhs;
102266 +
102267 + rhs1 = gimple_assign_rhs1(stmt);
102268 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102269 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102270 +
102271 + new_rhs1 = expand(visited, rhs1);
102272 +
102273 + if (new_rhs1 == NULL_TREE)
102274 + return create_cast_assign(visited, stmt);
102275 +
102276 + if (gimple_plf(stmt, NO_CAST_CHECK))
102277 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102278 +
102279 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102280 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102281 +
102282 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102283 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102284 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102285 + }
102286 +
102287 + if (!gimple_assign_cast_p(stmt))
102288 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102289 +
102290 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102291 +}
102292 +
102293 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102294 +{
102295 + tree rhs1, lhs = gimple_get_lhs(stmt);
102296 + gimple def_stmt = get_def_stmt(lhs);
102297 +
102298 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102299 + rhs1 = gimple_assign_rhs1(def_stmt);
102300 +
102301 + if (is_gimple_constant(rhs1))
102302 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102303 +
102304 + switch (TREE_CODE(rhs1)) {
102305 + case SSA_NAME:
102306 + return handle_unary_rhs(visited, def_stmt);
102307 + case ARRAY_REF:
102308 + case BIT_FIELD_REF:
102309 + case ADDR_EXPR:
102310 + case COMPONENT_REF:
102311 + case INDIRECT_REF:
102312 +#if BUILDING_GCC_VERSION >= 4006
102313 + case MEM_REF:
102314 +#endif
102315 + case TARGET_MEM_REF:
102316 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102317 + case PARM_DECL:
102318 + case VAR_DECL:
102319 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102320 +
102321 + default:
102322 + debug_gimple_stmt(def_stmt);
102323 + debug_tree(rhs1);
102324 + gcc_unreachable();
102325 + }
102326 +}
102327 +
102328 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102329 +{
102330 + gimple cond_stmt;
102331 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102332 +
102333 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102334 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102335 + update_stmt(cond_stmt);
102336 +}
102337 +
102338 +static tree create_string_param(tree string)
102339 +{
102340 + tree i_type, a_type;
102341 + const int length = TREE_STRING_LENGTH(string);
102342 +
102343 + gcc_assert(length > 0);
102344 +
102345 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102346 + a_type = build_array_type(char_type_node, i_type);
102347 +
102348 + TREE_TYPE(string) = a_type;
102349 + TREE_CONSTANT(string) = 1;
102350 + TREE_READONLY(string) = 1;
102351 +
102352 + return build1(ADDR_EXPR, ptr_type_node, string);
102353 +}
102354 +
102355 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
102356 +{
102357 + gimple func_stmt;
102358 + const_gimple def_stmt;
102359 + const_tree loc_line;
102360 + tree loc_file, ssa_name, current_func;
102361 + expanded_location xloc;
102362 + char *ssa_name_buf;
102363 + int len;
102364 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
102365 +
102366 + def_stmt = get_def_stmt(arg);
102367 + xloc = expand_location(gimple_location(def_stmt));
102368 +
102369 + if (!gimple_has_location(def_stmt)) {
102370 + xloc = expand_location(gimple_location(stmt));
102371 + if (!gimple_has_location(stmt))
102372 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102373 + }
102374 +
102375 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
102376 +
102377 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
102378 + loc_file = create_string_param(loc_file);
102379 +
102380 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
102381 + current_func = create_string_param(current_func);
102382 +
102383 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
102384 + call_count++;
102385 + 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);
102386 + gcc_assert(len > 0);
102387 + ssa_name = build_string(len + 1, ssa_name_buf);
102388 + free(ssa_name_buf);
102389 + ssa_name = create_string_param(ssa_name);
102390 +
102391 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
102392 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
102393 +
102394 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
102395 +}
102396 +
102397 +static void __unused print_the_code_insertions(const_gimple stmt)
102398 +{
102399 + location_t loc = gimple_location(stmt);
102400 +
102401 + inform(loc, "Integer size_overflow check applied here.");
102402 +}
102403 +
102404 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
102405 +{
102406 + basic_block cond_bb, join_bb, bb_true;
102407 + edge e;
102408 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102409 +
102410 + cond_bb = gimple_bb(stmt);
102411 + if (before)
102412 + gsi_prev(&gsi);
102413 + if (gsi_end_p(gsi))
102414 + e = split_block_after_labels(cond_bb);
102415 + else
102416 + e = split_block(cond_bb, gsi_stmt(gsi));
102417 + cond_bb = e->src;
102418 + join_bb = e->dest;
102419 + e->flags = EDGE_FALSE_VALUE;
102420 + e->probability = REG_BR_PROB_BASE;
102421 +
102422 + bb_true = create_empty_bb(cond_bb);
102423 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
102424 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
102425 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
102426 +
102427 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102428 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
102429 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
102430 +
102431 + if (current_loops != NULL) {
102432 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
102433 + add_bb_to_loop(bb_true, cond_bb->loop_father);
102434 + }
102435 +
102436 + insert_cond(cond_bb, arg, cond_code, type_value);
102437 + insert_cond_result(bb_true, stmt, arg, min);
102438 +
102439 +// print_the_code_insertions(stmt);
102440 +}
102441 +
102442 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
102443 +{
102444 + const_tree rhs_type = TREE_TYPE(rhs);
102445 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
102446 +
102447 + gcc_assert(rhs_type != NULL_TREE);
102448 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
102449 + return;
102450 +
102451 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
102452 +
102453 + if (is_const_plus_unsigned_signed_truncation(rhs))
102454 + return;
102455 +
102456 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
102457 + // typemax (-1) < typemin (0)
102458 + if (TREE_OVERFLOW(type_max))
102459 + return;
102460 +
102461 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
102462 +
102463 + cast_rhs_type = TREE_TYPE(cast_rhs);
102464 + type_max_type = TREE_TYPE(type_max);
102465 + type_min_type = TREE_TYPE(type_min);
102466 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
102467 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
102468 +
102469 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
102470 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
102471 +}
102472 +
102473 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
102474 +{
102475 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
102476 + return false;
102477 + if (!is_gimple_constant(rhs))
102478 + return false;
102479 + return true;
102480 +}
102481 +
102482 +static tree get_def_stmt_rhs(const_tree var)
102483 +{
102484 + tree rhs1, def_stmt_rhs1;
102485 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
102486 +
102487 + def_stmt = get_def_stmt(var);
102488 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
102489 +
102490 + rhs1 = gimple_assign_rhs1(def_stmt);
102491 + rhs1_def_stmt = get_def_stmt(rhs1);
102492 + if (!gimple_assign_cast_p(rhs1_def_stmt))
102493 + return rhs1;
102494 +
102495 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102496 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
102497 +
102498 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
102499 + case GIMPLE_CALL:
102500 + case GIMPLE_NOP:
102501 + case GIMPLE_ASM:
102502 + case GIMPLE_PHI:
102503 + return def_stmt_rhs1;
102504 + case GIMPLE_ASSIGN:
102505 + return rhs1;
102506 + default:
102507 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
102508 + gcc_unreachable();
102509 + }
102510 +}
102511 +
102512 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
102513 +{
102514 + tree new_rhs, orig_rhs;
102515 + void (*gimple_assign_set_rhs)(gimple, tree);
102516 + tree rhs1 = gimple_assign_rhs1(stmt);
102517 + tree rhs2 = gimple_assign_rhs2(stmt);
102518 + tree lhs = gimple_get_lhs(stmt);
102519 +
102520 + if (!check_overflow)
102521 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102522 +
102523 + if (change_rhs == NULL_TREE)
102524 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102525 +
102526 + if (new_rhs2 == NULL_TREE) {
102527 + orig_rhs = rhs1;
102528 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
102529 + } else {
102530 + orig_rhs = rhs2;
102531 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
102532 + }
102533 +
102534 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
102535 +
102536 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
102537 + gimple_assign_set_rhs(stmt, new_rhs);
102538 + update_stmt(stmt);
102539 +
102540 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102541 +}
102542 +
102543 +static bool is_subtraction_special(const_gimple stmt)
102544 +{
102545 + gimple rhs1_def_stmt, rhs2_def_stmt;
102546 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
102547 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
102548 + const_tree rhs1 = gimple_assign_rhs1(stmt);
102549 + const_tree rhs2 = gimple_assign_rhs2(stmt);
102550 +
102551 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
102552 + return false;
102553 +
102554 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
102555 +
102556 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
102557 + return false;
102558 +
102559 + rhs1_def_stmt = get_def_stmt(rhs1);
102560 + rhs2_def_stmt = get_def_stmt(rhs2);
102561 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
102562 + return false;
102563 +
102564 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
102565 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
102566 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
102567 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
102568 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
102569 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
102570 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
102571 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
102572 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
102573 + return false;
102574 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
102575 + return false;
102576 +
102577 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
102578 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
102579 + return true;
102580 +}
102581 +
102582 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
102583 +{
102584 + tree new_rhs1, new_rhs2;
102585 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
102586 + gimple assign, stmt = get_def_stmt(lhs);
102587 + tree rhs1 = gimple_assign_rhs1(stmt);
102588 + tree rhs2 = gimple_assign_rhs2(stmt);
102589 +
102590 + if (!is_subtraction_special(stmt))
102591 + return NULL_TREE;
102592 +
102593 + new_rhs1 = expand(visited, rhs1);
102594 + new_rhs2 = expand(visited, rhs2);
102595 +
102596 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
102597 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
102598 +
102599 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
102600 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
102601 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
102602 + }
102603 +
102604 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
102605 + new_lhs = gimple_get_lhs(assign);
102606 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
102607 +
102608 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102609 +}
102610 +
102611 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
102612 +{
102613 + const_gimple def_stmt;
102614 +
102615 + if (TREE_CODE(rhs) != SSA_NAME)
102616 + return false;
102617 +
102618 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
102619 + return false;
102620 +
102621 + def_stmt = get_def_stmt(rhs);
102622 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
102623 + return false;
102624 +
102625 + return true;
102626 +}
102627 +
102628 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
102629 +{
102630 + tree rhs1, rhs2, new_lhs;
102631 + gimple def_stmt = get_def_stmt(lhs);
102632 + tree new_rhs1 = NULL_TREE;
102633 + tree new_rhs2 = NULL_TREE;
102634 +
102635 + rhs1 = gimple_assign_rhs1(def_stmt);
102636 + rhs2 = gimple_assign_rhs2(def_stmt);
102637 +
102638 + /* no DImode/TImode division in the 32/64 bit kernel */
102639 + switch (gimple_assign_rhs_code(def_stmt)) {
102640 + case RDIV_EXPR:
102641 + case TRUNC_DIV_EXPR:
102642 + case CEIL_DIV_EXPR:
102643 + case FLOOR_DIV_EXPR:
102644 + case ROUND_DIV_EXPR:
102645 + case TRUNC_MOD_EXPR:
102646 + case CEIL_MOD_EXPR:
102647 + case FLOOR_MOD_EXPR:
102648 + case ROUND_MOD_EXPR:
102649 + case EXACT_DIV_EXPR:
102650 + case POINTER_PLUS_EXPR:
102651 + case BIT_AND_EXPR:
102652 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102653 + default:
102654 + break;
102655 + }
102656 +
102657 + new_lhs = handle_integer_truncation(visited, lhs);
102658 + if (new_lhs != NULL_TREE)
102659 + return new_lhs;
102660 +
102661 + if (TREE_CODE(rhs1) == SSA_NAME)
102662 + new_rhs1 = expand(visited, rhs1);
102663 + if (TREE_CODE(rhs2) == SSA_NAME)
102664 + new_rhs2 = expand(visited, rhs2);
102665 +
102666 + if (is_a_neg_overflow(def_stmt, rhs2))
102667 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
102668 + if (is_a_neg_overflow(def_stmt, rhs1))
102669 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
102670 +
102671 +
102672 + if (is_a_constant_overflow(def_stmt, rhs2))
102673 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
102674 + if (is_a_constant_overflow(def_stmt, rhs1))
102675 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
102676 +
102677 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
102678 +}
102679 +
102680 +#if BUILDING_GCC_VERSION >= 4007
102681 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
102682 +{
102683 + if (is_gimple_constant(rhs))
102684 + return cast_a_tree(size_overflow_type, rhs);
102685 + if (TREE_CODE(rhs) != SSA_NAME)
102686 + return NULL_TREE;
102687 + return expand(visited, rhs);
102688 +}
102689 +
102690 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
102691 +{
102692 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
102693 + gimple def_stmt = get_def_stmt(lhs);
102694 +
102695 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
102696 +
102697 + rhs1 = gimple_assign_rhs1(def_stmt);
102698 + rhs2 = gimple_assign_rhs2(def_stmt);
102699 + rhs3 = gimple_assign_rhs3(def_stmt);
102700 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
102701 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
102702 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
102703 +
102704 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
102705 +}
102706 +#endif
102707 +
102708 +static tree get_size_overflow_type(gimple stmt, const_tree node)
102709 +{
102710 + const_tree type;
102711 + tree new_type;
102712 +
102713 + gcc_assert(node != NULL_TREE);
102714 +
102715 + type = TREE_TYPE(node);
102716 +
102717 + if (gimple_plf(stmt, MY_STMT))
102718 + return TREE_TYPE(node);
102719 +
102720 + switch (TYPE_MODE(type)) {
102721 + case QImode:
102722 + new_type = intHI_type_node;
102723 + break;
102724 + case HImode:
102725 + new_type = intSI_type_node;
102726 + break;
102727 + case SImode:
102728 + new_type = intDI_type_node;
102729 + break;
102730 + case DImode:
102731 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102732 + new_type = intDI_type_node;
102733 + else
102734 + new_type = intTI_type_node;
102735 + break;
102736 + default:
102737 + debug_tree((tree)node);
102738 + error("%s: unsupported gcc configuration.", __func__);
102739 + gcc_unreachable();
102740 + }
102741 +
102742 + if (TYPE_QUALS(type) != 0)
102743 + return build_qualified_type(new_type, TYPE_QUALS(type));
102744 + return new_type;
102745 +}
102746 +
102747 +static tree expand_visited(gimple def_stmt)
102748 +{
102749 + const_gimple next_stmt;
102750 + gimple_stmt_iterator gsi;
102751 + enum gimple_code code = gimple_code(def_stmt);
102752 +
102753 + if (code == GIMPLE_ASM)
102754 + return NULL_TREE;
102755 +
102756 + gsi = gsi_for_stmt(def_stmt);
102757 + gsi_next(&gsi);
102758 +
102759 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
102760 + return NULL_TREE;
102761 + gcc_assert(!gsi_end_p(gsi));
102762 + next_stmt = gsi_stmt(gsi);
102763 +
102764 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
102765 + return NULL_TREE;
102766 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
102767 +
102768 + return get_lhs(next_stmt);
102769 +}
102770 +
102771 +static tree expand(struct pointer_set_t *visited, tree lhs)
102772 +{
102773 + gimple def_stmt;
102774 +
102775 + if (skip_types(lhs))
102776 + return NULL_TREE;
102777 +
102778 + def_stmt = get_def_stmt(lhs);
102779 +
102780 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102781 + return NULL_TREE;
102782 +
102783 + if (gimple_plf(def_stmt, MY_STMT))
102784 + return lhs;
102785 +
102786 + if (pointer_set_contains(visited, def_stmt))
102787 + return expand_visited(def_stmt);
102788 +
102789 + switch (gimple_code(def_stmt)) {
102790 + case GIMPLE_PHI:
102791 + return handle_phi(visited, lhs);
102792 + case GIMPLE_CALL:
102793 + case GIMPLE_ASM:
102794 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102795 + case GIMPLE_ASSIGN:
102796 + switch (gimple_num_ops(def_stmt)) {
102797 + case 2:
102798 + return handle_unary_ops(visited, def_stmt);
102799 + case 3:
102800 + return handle_binary_ops(visited, lhs);
102801 +#if BUILDING_GCC_VERSION >= 4007
102802 + case 4:
102803 + return handle_ternary_ops(visited, lhs);
102804 +#endif
102805 + }
102806 + default:
102807 + debug_gimple_stmt(def_stmt);
102808 + error("%s: unknown gimple code", __func__);
102809 + gcc_unreachable();
102810 + }
102811 +}
102812 +
102813 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
102814 +{
102815 + const_gimple assign;
102816 + tree orig_type = TREE_TYPE(orig_node);
102817 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102818 +
102819 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102820 + return gimple_get_lhs(assign);
102821 +}
102822 +
102823 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
102824 +{
102825 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
102826 + update_stmt(stmt);
102827 +}
102828 +
102829 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
102830 +{
102831 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
102832 + update_stmt(stmt);
102833 +}
102834 +
102835 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
102836 +{
102837 + tree arg;
102838 + const_tree origarg;
102839 +
102840 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
102841 + return true;
102842 +
102843 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
102844 + while (origarg && *argnum) {
102845 + (*argnum)--;
102846 + origarg = TREE_CHAIN(origarg);
102847 + }
102848 +
102849 + gcc_assert(*argnum == 0);
102850 +
102851 + gcc_assert(origarg != NULL_TREE);
102852 + *argnum = 0;
102853 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
102854 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
102855 + return true;
102856 + return false;
102857 +}
102858 +
102859 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
102860 +{
102861 + gimple phi = get_def_stmt(result);
102862 + unsigned int i, n = gimple_phi_num_args(phi);
102863 +
102864 + if (!phi)
102865 + return MARK_NO;
102866 +
102867 + pointer_set_insert(visited, phi);
102868 + for (i = 0; i < n; i++) {
102869 + enum mark marked;
102870 + const_tree arg = gimple_phi_arg_def(phi, i);
102871 + marked = pre_expand(visited, search_err_code, arg);
102872 + if (marked != MARK_NO)
102873 + return marked;
102874 + }
102875 + return MARK_NO;
102876 +}
102877 +
102878 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102879 +{
102880 + gimple def_stmt = get_def_stmt(lhs);
102881 + const_tree rhs;
102882 +
102883 + if (!def_stmt)
102884 + return MARK_NO;
102885 +
102886 + rhs = gimple_assign_rhs1(def_stmt);
102887 +
102888 + def_stmt = get_def_stmt(rhs);
102889 + if (is_gimple_constant(rhs))
102890 + search_err_code[FROM_CONST] = true;
102891 +
102892 + return pre_expand(visited, search_err_code, rhs);
102893 +}
102894 +
102895 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
102896 +{
102897 + gimple def_stmt = get_def_stmt(lhs);
102898 + const_tree rhs1, rhs2;
102899 + enum mark marked;
102900 +
102901 + if (!def_stmt)
102902 + return MARK_NO;
102903 +
102904 + search_err_code[CAST_ONLY] = false;
102905 +
102906 + rhs1 = gimple_assign_rhs1(def_stmt);
102907 + rhs2 = gimple_assign_rhs2(def_stmt);
102908 + marked = pre_expand(visited, search_err_code, rhs1);
102909 + if (marked != MARK_NO)
102910 + return marked;
102911 + return pre_expand(visited, search_err_code, rhs2);
102912 +}
102913 +
102914 +static const_tree search_field_decl(const_tree comp_ref)
102915 +{
102916 + const_tree field = NULL_TREE;
102917 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
102918 +
102919 + for (i = 0; i < len; i++) {
102920 + field = TREE_OPERAND(comp_ref, i);
102921 + if (TREE_CODE(field) == FIELD_DECL)
102922 + break;
102923 + }
102924 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
102925 + return field;
102926 +}
102927 +
102928 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
102929 +{
102930 + const_tree attr, p;
102931 +
102932 + // 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);
102933 + if (fndecl == NULL_TREE)
102934 + return MARK_NO;
102935 +
102936 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
102937 + if (!attr || !TREE_VALUE(attr))
102938 + return MARK_NO;
102939 +
102940 + p = TREE_VALUE(attr);
102941 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
102942 + return MARK_TURN_OFF;
102943 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
102944 + return MARK_NOT_INTENTIONAL;
102945 + if (argnum == 0) {
102946 + gcc_assert(current_function_decl == fndecl);
102947 + return MARK_NO;
102948 + }
102949 +
102950 + do {
102951 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
102952 + return MARK_YES;
102953 + p = TREE_CHAIN(p);
102954 + } while (p);
102955 +
102956 + return MARK_NO;
102957 +}
102958 +
102959 +static void print_missing_msg(tree func, unsigned int argnum)
102960 +{
102961 + unsigned int new_hash;
102962 + size_t len;
102963 + unsigned char tree_codes[CODES_LIMIT];
102964 + location_t loc;
102965 + const char *curfunc;
102966 +
102967 + func = get_original_function_decl(func);
102968 + loc = DECL_SOURCE_LOCATION(func);
102969 + curfunc = get_asm_name(func);
102970 +
102971 + len = get_function_decl(func, tree_codes);
102972 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
102973 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
102974 +}
102975 +
102976 +static unsigned int search_missing_attribute(const_tree arg)
102977 +{
102978 + unsigned int argnum;
102979 + const struct size_overflow_hash *hash;
102980 + const_tree type = TREE_TYPE(arg);
102981 + tree func = get_original_function_decl(current_function_decl);
102982 +
102983 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
102984 +
102985 + if (TREE_CODE(type) == POINTER_TYPE)
102986 + return 0;
102987 +
102988 + argnum = find_arg_number(arg, func);
102989 + if (argnum == 0)
102990 + return 0;
102991 +
102992 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
102993 + return argnum;
102994 +
102995 + hash = get_function_hash(func);
102996 + if (!hash || !(hash->param & (1U << argnum))) {
102997 + print_missing_msg(func, argnum);
102998 + return 0;
102999 + }
103000 + return argnum;
103001 +}
103002 +
103003 +static enum mark is_already_marked(const_tree lhs)
103004 +{
103005 + unsigned int argnum;
103006 + const_tree fndecl;
103007 +
103008 + argnum = search_missing_attribute(lhs);
103009 + fndecl = get_original_function_decl(current_function_decl);
103010 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103011 + return MARK_YES;
103012 + return MARK_NO;
103013 +}
103014 +
103015 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103016 +{
103017 + const_gimple def_stmt;
103018 +
103019 + if (skip_types(lhs))
103020 + return MARK_NO;
103021 +
103022 + if (TREE_CODE(lhs) == PARM_DECL)
103023 + return is_already_marked(lhs);
103024 +
103025 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103026 + const_tree field, attr;
103027 +
103028 + field = search_field_decl(lhs);
103029 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103030 + if (!attr || !TREE_VALUE(attr))
103031 + return MARK_NO;
103032 + return MARK_YES;
103033 + }
103034 +
103035 + def_stmt = get_def_stmt(lhs);
103036 +
103037 + if (!def_stmt)
103038 + return MARK_NO;
103039 +
103040 + if (pointer_set_contains(visited, def_stmt))
103041 + return MARK_NO;
103042 +
103043 + switch (gimple_code(def_stmt)) {
103044 + case GIMPLE_NOP:
103045 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103046 + return is_already_marked(lhs);
103047 + return MARK_NO;
103048 + case GIMPLE_PHI:
103049 + return walk_phi(visited, search_err_code, lhs);
103050 + case GIMPLE_CALL:
103051 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103052 + return MARK_TURN_OFF;
103053 + check_function_hash(def_stmt);
103054 + return MARK_NO;
103055 + case GIMPLE_ASM:
103056 + search_err_code[CAST_ONLY] = false;
103057 + return MARK_NO;
103058 + case GIMPLE_ASSIGN:
103059 + switch (gimple_num_ops(def_stmt)) {
103060 + case 2:
103061 + return walk_unary_ops(visited, search_err_code, lhs);
103062 + case 3:
103063 + return walk_binary_ops(visited, search_err_code, lhs);
103064 + }
103065 + default:
103066 + debug_gimple_stmt((gimple)def_stmt);
103067 + error("%s: unknown gimple code", __func__);
103068 + gcc_unreachable();
103069 + }
103070 +}
103071 +
103072 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103073 +static bool skip_asm(const_tree arg)
103074 +{
103075 + gimple def_stmt = get_def_stmt(arg);
103076 +
103077 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103078 + return false;
103079 +
103080 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103081 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103082 +}
103083 +
103084 +/*
103085 +0</MARK_YES: no dup, search attributes (so, int)
103086 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103087 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103088 +*/
103089 +
103090 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103091 +{
103092 + struct pointer_set_t *visited;
103093 + enum mark is_marked, is_found;
103094 + location_t loc;
103095 + bool search_err_code[2] = {true, false};
103096 +
103097 + is_marked = mark_status(current_function_decl, 0);
103098 + if (is_marked == MARK_TURN_OFF)
103099 + return true;
103100 +
103101 + is_marked = mark_status(fndecl, argnum + 1);
103102 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103103 + return true;
103104 +
103105 + visited = pointer_set_create();
103106 + is_found = pre_expand(visited, search_err_code, arg);
103107 + pointer_set_destroy(visited);
103108 +
103109 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103110 + return true;
103111 +
103112 + if (where == FROM_ARG && skip_asm(arg))
103113 + return true;
103114 +
103115 + if (is_found == MARK_TURN_OFF)
103116 + return true;
103117 +
103118 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103119 + return true;
103120 +
103121 + if (is_found == MARK_YES) {
103122 + loc = DECL_SOURCE_LOCATION(fndecl);
103123 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103124 + return true;
103125 + }
103126 + return false;
103127 +}
103128 +
103129 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103130 +{
103131 + struct pointer_set_t *visited;
103132 + tree arg, new_arg;
103133 + bool match;
103134 +
103135 + if (argnum == 0)
103136 + return;
103137 +
103138 + argnum--;
103139 +
103140 + match = get_function_arg(&argnum, fndecl);
103141 + if (!match)
103142 + return;
103143 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103144 + arg = gimple_call_arg(stmt, argnum);
103145 + if (arg == NULL_TREE)
103146 + return;
103147 +
103148 + if (skip_types(arg))
103149 + return;
103150 +
103151 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103152 + return;
103153 +
103154 + visited = pointer_set_create();
103155 + new_arg = expand(visited, arg);
103156 + pointer_set_destroy(visited);
103157 +
103158 + if (new_arg == NULL_TREE)
103159 + return;
103160 +
103161 + change_function_arg(stmt, arg, argnum, new_arg);
103162 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103163 +}
103164 +
103165 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103166 +{
103167 + tree p = TREE_VALUE(attr);
103168 + do {
103169 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103170 + p = TREE_CHAIN(p);
103171 + } while (p);
103172 +}
103173 +
103174 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103175 +{
103176 + unsigned int num;
103177 + const struct size_overflow_hash *hash;
103178 +
103179 + hash = get_function_hash(fndecl);
103180 + if (!hash)
103181 + return;
103182 +
103183 + for (num = 0; num <= MAX_PARAM; num++)
103184 + if (hash->param & (1U << num))
103185 + handle_function_arg(stmt, fndecl, num);
103186 +}
103187 +
103188 +static bool check_return_value(void)
103189 +{
103190 + const struct size_overflow_hash *hash;
103191 +
103192 + hash = get_function_hash(current_function_decl);
103193 + if (!hash || !(hash->param & 1U << 0))
103194 + return false;
103195 +
103196 + return true;
103197 +}
103198 +
103199 +static void handle_return_value(gimple ret_stmt)
103200 +{
103201 + struct pointer_set_t *visited;
103202 + tree ret, new_ret;
103203 +
103204 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103205 + return;
103206 +
103207 + ret = gimple_return_retval(ret_stmt);
103208 +
103209 + if (skip_types(ret))
103210 + return;
103211 +
103212 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103213 + return;
103214 +
103215 + visited = pointer_set_create();
103216 + new_ret = expand(visited, ret);
103217 + pointer_set_destroy(visited);
103218 +
103219 + change_function_return(ret_stmt, ret, new_ret);
103220 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103221 +}
103222 +
103223 +static void set_plf_false(void)
103224 +{
103225 + basic_block bb;
103226 +
103227 + FOR_ALL_BB(bb) {
103228 + gimple_stmt_iterator si;
103229 +
103230 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103231 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103232 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103233 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103234 + }
103235 +}
103236 +
103237 +static unsigned int handle_function(void)
103238 +{
103239 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103240 + bool check_ret;
103241 +
103242 + set_plf_false();
103243 +
103244 + check_ret = check_return_value();
103245 +
103246 + do {
103247 + gimple_stmt_iterator gsi;
103248 + next = bb->next_bb;
103249 +
103250 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103251 + tree fndecl, attr;
103252 + gimple stmt = gsi_stmt(gsi);
103253 +
103254 + if (check_ret)
103255 + handle_return_value(stmt);
103256 +
103257 + if (!(is_gimple_call(stmt)))
103258 + continue;
103259 + fndecl = gimple_call_fndecl(stmt);
103260 + if (fndecl == NULL_TREE)
103261 + continue;
103262 + if (gimple_call_num_args(stmt) == 0)
103263 + continue;
103264 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103265 + if (!attr || !TREE_VALUE(attr))
103266 + handle_function_by_hash(stmt, fndecl);
103267 + else
103268 + handle_function_by_attribute(stmt, attr, fndecl);
103269 + gsi = gsi_for_stmt(stmt);
103270 + next = gimple_bb(stmt)->next_bb;
103271 + }
103272 + bb = next;
103273 + } while (bb);
103274 + return 0;
103275 +}
103276 +
103277 +static struct gimple_opt_pass size_overflow_pass = {
103278 + .pass = {
103279 + .type = GIMPLE_PASS,
103280 + .name = "size_overflow",
103281 +#if BUILDING_GCC_VERSION >= 4008
103282 + .optinfo_flags = OPTGROUP_NONE,
103283 +#endif
103284 + .gate = NULL,
103285 + .execute = handle_function,
103286 + .sub = NULL,
103287 + .next = NULL,
103288 + .static_pass_number = 0,
103289 + .tv_id = TV_NONE,
103290 + .properties_required = PROP_cfg,
103291 + .properties_provided = 0,
103292 + .properties_destroyed = 0,
103293 + .todo_flags_start = 0,
103294 + .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
103295 + }
103296 +};
103297 +
103298 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103299 +{
103300 + tree fntype;
103301 +
103302 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103303 +
103304 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103305 + fntype = build_function_type_list(void_type_node,
103306 + const_char_ptr_type_node,
103307 + unsigned_type_node,
103308 + const_char_ptr_type_node,
103309 + const_char_ptr_type_node,
103310 + NULL_TREE);
103311 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103312 +
103313 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103314 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103315 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103316 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103317 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103318 +}
103319 +
103320 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103321 +{
103322 + int i;
103323 + const char * const plugin_name = plugin_info->base_name;
103324 + const int argc = plugin_info->argc;
103325 + const struct plugin_argument * const argv = plugin_info->argv;
103326 + bool enable = true;
103327 +
103328 + struct register_pass_info size_overflow_pass_info = {
103329 + .pass = &size_overflow_pass.pass,
103330 + .reference_pass_name = "ssa",
103331 + .ref_pass_instance_number = 1,
103332 + .pos_op = PASS_POS_INSERT_AFTER
103333 + };
103334 +
103335 + if (!plugin_default_version_check(version, &gcc_version)) {
103336 + error(G_("incompatible gcc/plugin versions"));
103337 + return 1;
103338 + }
103339 +
103340 + for (i = 0; i < argc; ++i) {
103341 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103342 + enable = false;
103343 + continue;
103344 + }
103345 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103346 + }
103347 +
103348 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103349 + if (enable) {
103350 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103351 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103352 + }
103353 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103354 +
103355 + return 0;
103356 +}
103357 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
103358 new file mode 100644
103359 index 0000000..ac2901e
103360 --- /dev/null
103361 +++ b/tools/gcc/stackleak_plugin.c
103362 @@ -0,0 +1,327 @@
103363 +/*
103364 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
103365 + * Licensed under the GPL v2
103366 + *
103367 + * Note: the choice of the license means that the compilation process is
103368 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103369 + * but for the kernel it doesn't matter since it doesn't link against
103370 + * any of the gcc libraries
103371 + *
103372 + * gcc plugin to help implement various PaX features
103373 + *
103374 + * - track lowest stack pointer
103375 + *
103376 + * TODO:
103377 + * - initialize all local variables
103378 + *
103379 + * BUGS:
103380 + * - none known
103381 + */
103382 +#include "gcc-plugin.h"
103383 +#include "config.h"
103384 +#include "system.h"
103385 +#include "coretypes.h"
103386 +#include "tree.h"
103387 +#include "tree-pass.h"
103388 +#include "flags.h"
103389 +#include "intl.h"
103390 +#include "toplev.h"
103391 +#include "plugin.h"
103392 +//#include "expr.h" where are you...
103393 +#include "diagnostic.h"
103394 +#include "plugin-version.h"
103395 +#include "tm.h"
103396 +#include "function.h"
103397 +#include "basic-block.h"
103398 +#include "gimple.h"
103399 +#include "rtl.h"
103400 +#include "emit-rtl.h"
103401 +
103402 +#if BUILDING_GCC_VERSION >= 4008
103403 +#define TODO_dump_func 0
103404 +#endif
103405 +
103406 +extern void print_gimple_stmt(FILE *, gimple, int, int);
103407 +
103408 +int plugin_is_GPL_compatible;
103409 +
103410 +static int track_frame_size = -1;
103411 +static const char track_function[] = "pax_track_stack";
103412 +static const char check_function[] = "pax_check_alloca";
103413 +static bool init_locals;
103414 +
103415 +static struct plugin_info stackleak_plugin_info = {
103416 + .version = "201302112000",
103417 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
103418 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
103419 +};
103420 +
103421 +static bool gate_stackleak_track_stack(void);
103422 +static unsigned int execute_stackleak_tree_instrument(void);
103423 +static unsigned int execute_stackleak_final(void);
103424 +
103425 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
103426 + .pass = {
103427 + .type = GIMPLE_PASS,
103428 + .name = "stackleak_tree_instrument",
103429 +#if BUILDING_GCC_VERSION >= 4008
103430 + .optinfo_flags = OPTGROUP_NONE,
103431 +#endif
103432 + .gate = gate_stackleak_track_stack,
103433 + .execute = execute_stackleak_tree_instrument,
103434 + .sub = NULL,
103435 + .next = NULL,
103436 + .static_pass_number = 0,
103437 + .tv_id = TV_NONE,
103438 + .properties_required = PROP_gimple_leh | PROP_cfg,
103439 + .properties_provided = 0,
103440 + .properties_destroyed = 0,
103441 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103442 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103443 + }
103444 +};
103445 +
103446 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
103447 + .pass = {
103448 + .type = RTL_PASS,
103449 + .name = "stackleak_final",
103450 +#if BUILDING_GCC_VERSION >= 4008
103451 + .optinfo_flags = OPTGROUP_NONE,
103452 +#endif
103453 + .gate = gate_stackleak_track_stack,
103454 + .execute = execute_stackleak_final,
103455 + .sub = NULL,
103456 + .next = NULL,
103457 + .static_pass_number = 0,
103458 + .tv_id = TV_NONE,
103459 + .properties_required = 0,
103460 + .properties_provided = 0,
103461 + .properties_destroyed = 0,
103462 + .todo_flags_start = 0,
103463 + .todo_flags_finish = TODO_dump_func
103464 + }
103465 +};
103466 +
103467 +static bool gate_stackleak_track_stack(void)
103468 +{
103469 + return track_frame_size >= 0;
103470 +}
103471 +
103472 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
103473 +{
103474 + gimple check_alloca;
103475 + tree fntype, fndecl, alloca_size;
103476 +
103477 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
103478 + fndecl = build_fn_decl(check_function, fntype);
103479 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103480 +
103481 + // insert call to void pax_check_alloca(unsigned long size)
103482 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
103483 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
103484 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
103485 +}
103486 +
103487 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
103488 +{
103489 + gimple track_stack;
103490 + tree fntype, fndecl;
103491 +
103492 + fntype = build_function_type_list(void_type_node, NULL_TREE);
103493 + fndecl = build_fn_decl(track_function, fntype);
103494 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
103495 +
103496 + // insert call to void pax_track_stack(void)
103497 + track_stack = gimple_build_call(fndecl, 0);
103498 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
103499 +}
103500 +
103501 +#if BUILDING_GCC_VERSION == 4005
103502 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
103503 +{
103504 + tree fndecl;
103505 +
103506 + if (!is_gimple_call(stmt))
103507 + return false;
103508 + fndecl = gimple_call_fndecl(stmt);
103509 + if (!fndecl)
103510 + return false;
103511 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
103512 + return false;
103513 +// print_node(stderr, "pax", fndecl, 4);
103514 + return DECL_FUNCTION_CODE(fndecl) == code;
103515 +}
103516 +#endif
103517 +
103518 +static bool is_alloca(gimple stmt)
103519 +{
103520 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
103521 + return true;
103522 +
103523 +#if BUILDING_GCC_VERSION >= 4007
103524 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
103525 + return true;
103526 +#endif
103527 +
103528 + return false;
103529 +}
103530 +
103531 +static unsigned int execute_stackleak_tree_instrument(void)
103532 +{
103533 + basic_block bb, entry_bb;
103534 + bool prologue_instrumented = false, is_leaf = true;
103535 +
103536 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
103537 +
103538 + // 1. loop through BBs and GIMPLE statements
103539 + FOR_EACH_BB(bb) {
103540 + gimple_stmt_iterator gsi;
103541 +
103542 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103543 + gimple stmt;
103544 +
103545 + stmt = gsi_stmt(gsi);
103546 +
103547 + if (is_gimple_call(stmt))
103548 + is_leaf = false;
103549 +
103550 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
103551 + if (!is_alloca(stmt))
103552 + continue;
103553 +
103554 + // 2. insert stack overflow check before each __builtin_alloca call
103555 + stackleak_check_alloca(&gsi);
103556 +
103557 + // 3. insert track call after each __builtin_alloca call
103558 + stackleak_add_instrumentation(&gsi);
103559 + if (bb == entry_bb)
103560 + prologue_instrumented = true;
103561 + }
103562 + }
103563 +
103564 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
103565 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
103566 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
103567 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
103568 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
103569 + return 0;
103570 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
103571 + return 0;
103572 +
103573 + // 4. insert track call at the beginning
103574 + if (!prologue_instrumented) {
103575 + gimple_stmt_iterator gsi;
103576 +
103577 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103578 + if (dom_info_available_p(CDI_DOMINATORS))
103579 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103580 + gsi = gsi_start_bb(bb);
103581 + stackleak_add_instrumentation(&gsi);
103582 + }
103583 +
103584 + return 0;
103585 +}
103586 +
103587 +static unsigned int execute_stackleak_final(void)
103588 +{
103589 + rtx insn, next;
103590 +
103591 + if (cfun->calls_alloca)
103592 + return 0;
103593 +
103594 + // keep calls only if function frame is big enough
103595 + if (get_frame_size() >= track_frame_size)
103596 + return 0;
103597 +
103598 + // 1. find pax_track_stack calls
103599 + for (insn = get_insns(); insn; insn = next) {
103600 + // 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))
103601 + rtx body;
103602 +
103603 + next = NEXT_INSN(insn);
103604 + if (!CALL_P(insn))
103605 + continue;
103606 + body = PATTERN(insn);
103607 + if (GET_CODE(body) != CALL)
103608 + continue;
103609 + body = XEXP(body, 0);
103610 + if (GET_CODE(body) != MEM)
103611 + continue;
103612 + body = XEXP(body, 0);
103613 + if (GET_CODE(body) != SYMBOL_REF)
103614 + continue;
103615 + if (strcmp(XSTR(body, 0), track_function))
103616 + continue;
103617 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103618 + // 2. delete call
103619 + delete_insn_and_edges(insn);
103620 +#if BUILDING_GCC_VERSION >= 4007
103621 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
103622 + insn = next;
103623 + next = NEXT_INSN(insn);
103624 + delete_insn_and_edges(insn);
103625 + }
103626 +#endif
103627 + }
103628 +
103629 +// print_simple_rtl(stderr, get_insns());
103630 +// print_rtl(stderr, get_insns());
103631 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
103632 +
103633 + return 0;
103634 +}
103635 +
103636 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103637 +{
103638 + const char * const plugin_name = plugin_info->base_name;
103639 + const int argc = plugin_info->argc;
103640 + const struct plugin_argument * const argv = plugin_info->argv;
103641 + int i;
103642 + struct register_pass_info stackleak_tree_instrument_pass_info = {
103643 + .pass = &stackleak_tree_instrument_pass.pass,
103644 +// .reference_pass_name = "tree_profile",
103645 + .reference_pass_name = "optimized",
103646 + .ref_pass_instance_number = 1,
103647 + .pos_op = PASS_POS_INSERT_BEFORE
103648 + };
103649 + struct register_pass_info stackleak_final_pass_info = {
103650 + .pass = &stackleak_final_rtl_opt_pass.pass,
103651 + .reference_pass_name = "final",
103652 + .ref_pass_instance_number = 1,
103653 + .pos_op = PASS_POS_INSERT_BEFORE
103654 + };
103655 +
103656 + if (!plugin_default_version_check(version, &gcc_version)) {
103657 + error(G_("incompatible gcc/plugin versions"));
103658 + return 1;
103659 + }
103660 +
103661 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
103662 +
103663 + for (i = 0; i < argc; ++i) {
103664 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
103665 + if (!argv[i].value) {
103666 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103667 + continue;
103668 + }
103669 + track_frame_size = atoi(argv[i].value);
103670 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
103671 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103672 + continue;
103673 + }
103674 + if (!strcmp(argv[i].key, "initialize-locals")) {
103675 + if (argv[i].value) {
103676 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103677 + continue;
103678 + }
103679 + init_locals = true;
103680 + continue;
103681 + }
103682 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103683 + }
103684 +
103685 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
103686 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
103687 +
103688 + return 0;
103689 +}
103690 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
103691 new file mode 100644
103692 index 0000000..41770fc
103693 --- /dev/null
103694 +++ b/tools/gcc/structleak_plugin.c
103695 @@ -0,0 +1,272 @@
103696 +/*
103697 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
103698 + * Licensed under the GPL v2
103699 + *
103700 + * Note: the choice of the license means that the compilation process is
103701 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103702 + * but for the kernel it doesn't matter since it doesn't link against
103703 + * any of the gcc libraries
103704 + *
103705 + * gcc plugin to forcibly initialize certain local variables that could
103706 + * otherwise leak kernel stack to userland if they aren't properly initialized
103707 + * by later code
103708 + *
103709 + * Homepage: http://pax.grsecurity.net/
103710 + *
103711 + * Usage:
103712 + * $ # for 4.5/4.6/C based 4.7
103713 + * $ 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
103714 + * $ # for C++ based 4.7/4.8+
103715 + * $ 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
103716 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
103717 + *
103718 + * TODO: eliminate redundant initializers
103719 + * increase type coverage
103720 + */
103721 +
103722 +#include "gcc-plugin.h"
103723 +#include "config.h"
103724 +#include "system.h"
103725 +#include "coretypes.h"
103726 +#include "tree.h"
103727 +#include "tree-pass.h"
103728 +#include "intl.h"
103729 +#include "plugin-version.h"
103730 +#include "tm.h"
103731 +#include "toplev.h"
103732 +#include "function.h"
103733 +#include "tree-flow.h"
103734 +#include "plugin.h"
103735 +#include "gimple.h"
103736 +#include "diagnostic.h"
103737 +#include "cfgloop.h"
103738 +#include "langhooks.h"
103739 +
103740 +#if BUILDING_GCC_VERSION >= 4008
103741 +#define TODO_dump_func 0
103742 +#endif
103743 +
103744 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
103745 +
103746 +// unused type flag in all versions 4.5-4.8
103747 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
103748 +
103749 +int plugin_is_GPL_compatible;
103750 +void debug_gimple_stmt(gimple gs);
103751 +
103752 +static struct plugin_info structleak_plugin_info = {
103753 + .version = "201304082245",
103754 + .help = "disable\tdo not activate plugin\n",
103755 +};
103756 +
103757 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103758 +{
103759 + *no_add_attrs = true;
103760 +
103761 + // check for types? for now accept everything linux has to offer
103762 + if (TREE_CODE(*node) != FIELD_DECL)
103763 + return NULL_TREE;
103764 +
103765 + *no_add_attrs = false;
103766 + return NULL_TREE;
103767 +}
103768 +
103769 +static struct attribute_spec user_attr = {
103770 + .name = "user",
103771 + .min_length = 0,
103772 + .max_length = 0,
103773 + .decl_required = false,
103774 + .type_required = false,
103775 + .function_type_required = false,
103776 + .handler = handle_user_attribute,
103777 +#if BUILDING_GCC_VERSION >= 4007
103778 + .affects_type_identity = true
103779 +#endif
103780 +};
103781 +
103782 +static void register_attributes(void *event_data, void *data)
103783 +{
103784 + register_attribute(&user_attr);
103785 +// register_attribute(&force_attr);
103786 +}
103787 +
103788 +static tree get_field_type(tree field)
103789 +{
103790 + return strip_array_types(TREE_TYPE(field));
103791 +}
103792 +
103793 +static bool is_userspace_type(tree type)
103794 +{
103795 + tree field;
103796 +
103797 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
103798 + tree fieldtype = get_field_type(field);
103799 + enum tree_code code = TREE_CODE(fieldtype);
103800 +
103801 + if (code == RECORD_TYPE || code == UNION_TYPE)
103802 + if (is_userspace_type(fieldtype))
103803 + return true;
103804 +
103805 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
103806 + return true;
103807 + }
103808 + return false;
103809 +}
103810 +
103811 +static void finish_type(void *event_data, void *data)
103812 +{
103813 + tree type = (tree)event_data;
103814 +
103815 + if (TYPE_USERSPACE(type))
103816 + return;
103817 +
103818 + if (is_userspace_type(type))
103819 + TYPE_USERSPACE(type) = 1;
103820 +}
103821 +
103822 +static void initialize(tree var)
103823 +{
103824 + basic_block bb;
103825 + gimple_stmt_iterator gsi;
103826 + tree initializer;
103827 + gimple init_stmt;
103828 +
103829 + // this is the original entry bb before the forced split
103830 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
103831 +
103832 + // first check if the variable is already initialized, warn otherwise
103833 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103834 + gimple stmt = gsi_stmt(gsi);
103835 + tree rhs1 = gimple_assign_rhs1(stmt);
103836 +
103837 + // we're looking for an assignment of a single rhs...
103838 + if (!gimple_assign_single_p(stmt))
103839 + continue;
103840 +#if BUILDING_GCC_VERSION >= 4007
103841 + // ... of a non-clobbering expression...
103842 + if (TREE_CLOBBER_P(rhs1))
103843 + continue;
103844 +#endif
103845 + // ... to our variable...
103846 + if (gimple_get_lhs(stmt) != var)
103847 + continue;
103848 + // if it's an initializer then we're good
103849 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
103850 + return;
103851 + }
103852 +
103853 + // build the initializer expression
103854 + initializer = build_constructor(TREE_TYPE(var), NULL);
103855 +
103856 + // build the initializer stmt
103857 + init_stmt = gimple_build_assign(var, initializer);
103858 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
103859 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
103860 + update_stmt(init_stmt);
103861 +}
103862 +
103863 +static unsigned int handle_function(void)
103864 +{
103865 + basic_block bb;
103866 + unsigned int ret = 0;
103867 + tree var;
103868 +
103869 +#if BUILDING_GCC_VERSION == 4005
103870 + tree vars;
103871 +#else
103872 + unsigned int i;
103873 +#endif
103874 +
103875 + // split the first bb where we can put the forced initializers
103876 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103877 + if (dom_info_available_p(CDI_DOMINATORS))
103878 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103879 +
103880 + // enumarate all local variables and forcibly initialize our targets
103881 +#if BUILDING_GCC_VERSION == 4005
103882 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
103883 + var = TREE_VALUE(vars);
103884 +#else
103885 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
103886 +#endif
103887 + tree type = TREE_TYPE(var);
103888 +
103889 + gcc_assert(DECL_P(var));
103890 + if (!auto_var_in_fn_p(var, current_function_decl))
103891 + continue;
103892 +
103893 + // only care about structure types
103894 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
103895 + continue;
103896 +
103897 + // if the type is of interest, examine the variable
103898 + if (TYPE_USERSPACE(type))
103899 + initialize(var);
103900 + }
103901 +
103902 + return ret;
103903 +}
103904 +
103905 +static struct gimple_opt_pass structleak_pass = {
103906 + .pass = {
103907 + .type = GIMPLE_PASS,
103908 + .name = "structleak",
103909 +#if BUILDING_GCC_VERSION >= 4008
103910 + .optinfo_flags = OPTGROUP_NONE,
103911 +#endif
103912 + .gate = NULL,
103913 + .execute = handle_function,
103914 + .sub = NULL,
103915 + .next = NULL,
103916 + .static_pass_number = 0,
103917 + .tv_id = TV_NONE,
103918 + .properties_required = PROP_cfg,
103919 + .properties_provided = 0,
103920 + .properties_destroyed = 0,
103921 + .todo_flags_start = 0,
103922 + .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
103923 + }
103924 +};
103925 +
103926 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103927 +{
103928 + int i;
103929 + const char * const plugin_name = plugin_info->base_name;
103930 + const int argc = plugin_info->argc;
103931 + const struct plugin_argument * const argv = plugin_info->argv;
103932 + bool enable = true;
103933 +
103934 + struct register_pass_info structleak_pass_info = {
103935 + .pass = &structleak_pass.pass,
103936 + .reference_pass_name = "ssa",
103937 + .ref_pass_instance_number = 1,
103938 + .pos_op = PASS_POS_INSERT_AFTER
103939 + };
103940 +
103941 + if (!plugin_default_version_check(version, &gcc_version)) {
103942 + error(G_("incompatible gcc/plugin versions"));
103943 + return 1;
103944 + }
103945 +
103946 + if (strcmp(lang_hooks.name, "GNU C")) {
103947 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
103948 + enable = false;
103949 + }
103950 +
103951 + for (i = 0; i < argc; ++i) {
103952 + if (!strcmp(argv[i].key, "disable")) {
103953 + enable = false;
103954 + continue;
103955 + }
103956 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103957 + }
103958 +
103959 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
103960 + if (enable) {
103961 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
103962 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
103963 + }
103964 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103965 +
103966 + return 0;
103967 +}
103968 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
103969 index 6789d78..4afd019e 100644
103970 --- a/tools/perf/util/include/asm/alternative-asm.h
103971 +++ b/tools/perf/util/include/asm/alternative-asm.h
103972 @@ -5,4 +5,7 @@
103973
103974 #define altinstruction_entry #
103975
103976 + .macro pax_force_retaddr rip=0, reload=0
103977 + .endm
103978 +
103979 #endif
103980 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
103981 index 96b919d..c49bb74 100644
103982 --- a/tools/perf/util/include/linux/compiler.h
103983 +++ b/tools/perf/util/include/linux/compiler.h
103984 @@ -18,4 +18,12 @@
103985 #define __force
103986 #endif
103987
103988 +#ifndef __size_overflow
103989 +# define __size_overflow(...)
103990 +#endif
103991 +
103992 +#ifndef __intentional_overflow
103993 +# define __intentional_overflow(...)
103994 +#endif
103995 +
103996 #endif
103997 diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c
103998 index cfb7e4d..52058f0 100644
103999 --- a/virt/kvm/ioapic.c
104000 +++ b/virt/kvm/ioapic.c
104001 @@ -73,9 +73,12 @@ static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic,
104002 u32 redir_index = (ioapic->ioregsel - 0x10) >> 1;
104003 u64 redir_content;
104004
104005 - ASSERT(redir_index < IOAPIC_NUM_PINS);
104006 + if (redir_index < IOAPIC_NUM_PINS)
104007 + redir_content =
104008 + ioapic->redirtbl[redir_index].bits;
104009 + else
104010 + redir_content = ~0ULL;
104011
104012 - redir_content = ioapic->redirtbl[redir_index].bits;
104013 result = (ioapic->ioregsel & 0x1) ?
104014 (redir_content >> 32) & 0xffffffff :
104015 redir_content & 0xffffffff;
104016 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104017 index 1cd693a..f4a7b20 100644
104018 --- a/virt/kvm/kvm_main.c
104019 +++ b/virt/kvm/kvm_main.c
104020 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104021
104022 static cpumask_var_t cpus_hardware_enabled;
104023 static int kvm_usage_count = 0;
104024 -static atomic_t hardware_enable_failed;
104025 +static atomic_unchecked_t hardware_enable_failed;
104026
104027 struct kmem_cache *kvm_vcpu_cache;
104028 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104029
104030 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104031 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104032 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104033 +static struct preempt_ops kvm_preempt_ops = {
104034 + .sched_in = kvm_sched_in,
104035 + .sched_out = kvm_sched_out,
104036 +};
104037
104038 struct dentry *kvm_debugfs_dir;
104039
104040 @@ -731,7 +736,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104041 /* We can read the guest memory with __xxx_user() later on. */
104042 if (user_alloc &&
104043 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104044 - !access_ok(VERIFY_WRITE,
104045 + !__access_ok(VERIFY_WRITE,
104046 (void __user *)(unsigned long)mem->userspace_addr,
104047 mem->memory_size)))
104048 goto out;
104049 @@ -1783,7 +1788,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104050 return 0;
104051 }
104052
104053 -static struct file_operations kvm_vcpu_fops = {
104054 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104055 .release = kvm_vcpu_release,
104056 .unlocked_ioctl = kvm_vcpu_ioctl,
104057 #ifdef CONFIG_COMPAT
104058 @@ -2304,7 +2309,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104059 return 0;
104060 }
104061
104062 -static struct file_operations kvm_vm_fops = {
104063 +static file_operations_no_const kvm_vm_fops __read_only = {
104064 .release = kvm_vm_release,
104065 .unlocked_ioctl = kvm_vm_ioctl,
104066 #ifdef CONFIG_COMPAT
104067 @@ -2402,7 +2407,7 @@ out:
104068 return r;
104069 }
104070
104071 -static struct file_operations kvm_chardev_ops = {
104072 +static file_operations_no_const kvm_chardev_ops __read_only = {
104073 .unlocked_ioctl = kvm_dev_ioctl,
104074 .compat_ioctl = kvm_dev_ioctl,
104075 .llseek = noop_llseek,
104076 @@ -2428,7 +2433,7 @@ static void hardware_enable_nolock(void *junk)
104077
104078 if (r) {
104079 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104080 - atomic_inc(&hardware_enable_failed);
104081 + atomic_inc_unchecked(&hardware_enable_failed);
104082 printk(KERN_INFO "kvm: enabling virtualization on "
104083 "CPU%d failed\n", cpu);
104084 }
104085 @@ -2482,10 +2487,10 @@ static int hardware_enable_all(void)
104086
104087 kvm_usage_count++;
104088 if (kvm_usage_count == 1) {
104089 - atomic_set(&hardware_enable_failed, 0);
104090 + atomic_set_unchecked(&hardware_enable_failed, 0);
104091 on_each_cpu(hardware_enable_nolock, NULL, 1);
104092
104093 - if (atomic_read(&hardware_enable_failed)) {
104094 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104095 hardware_disable_all_nolock();
104096 r = -EBUSY;
104097 }
104098 @@ -2843,7 +2848,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104099 kvm_arch_vcpu_put(vcpu);
104100 }
104101
104102 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104103 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104104 struct module *module)
104105 {
104106 int r;
104107 @@ -2879,7 +2884,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104108 if (!vcpu_align)
104109 vcpu_align = __alignof__(struct kvm_vcpu);
104110 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104111 - 0, NULL);
104112 + SLAB_USERCOPY, NULL);
104113 if (!kvm_vcpu_cache) {
104114 r = -ENOMEM;
104115 goto out_free_3;
104116 @@ -2889,9 +2894,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104117 if (r)
104118 goto out_free;
104119
104120 + pax_open_kernel();
104121 kvm_chardev_ops.owner = module;
104122 kvm_vm_fops.owner = module;
104123 kvm_vcpu_fops.owner = module;
104124 + pax_close_kernel();
104125
104126 r = misc_register(&kvm_dev);
104127 if (r) {
104128 @@ -2901,9 +2908,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104129
104130 register_syscore_ops(&kvm_syscore_ops);
104131
104132 - kvm_preempt_ops.sched_in = kvm_sched_in;
104133 - kvm_preempt_ops.sched_out = kvm_sched_out;
104134 -
104135 r = kvm_init_debug();
104136 if (r) {
104137 printk(KERN_ERR "kvm: create debugfs files failed\n");